Trying to use ChangeDisplaySettingsEx: call to non-existent function sizeof(dm)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
THX1138
Posts: 63
Joined: 25 Jul 2017, 00:36

Trying to use ChangeDisplaySettingsEx: call to non-existent function sizeof(dm)

05 Dec 2017, 17:07

I tried to use the following code which I got from this thread: https://autohotkey.com/board/topic/9629 ... solutions/ but I get an error about a call to a non-existent function. The code was submitted to the old forum in 2013. Is it incompatible with the current version of AHK?

Code: Select all

#include <_Struct> ;http://www.autohotkey.com/community/viewtopic.php?t=59581
gosub InitStruct
ChangeDisplaySettingsEx( 1, (ClrDep:=32) , (Wid:=1366) , (Hei:=768) , (Hz:=60) )
ChangeDisplaySettingsEx( 2, (ClrDep:=32) , (Wid:=1920) , (Hei:=1080) , (Hz:=60) )
Return

ChangeDisplaySettingsEx( Display, cD, sW, sH, rR ) {
  dm:=new _Struct(DEVICEMODE),dm.dmSize:=sizeof(dm)
  DllCall( "EnumDisplaySettings", Str,"\\.\DISPLAY" Display, UInt,-1, PTR,dM[""] )
  dm.dmFields:=0x5c0000
  dm.dmPelsWidth := sW
  dm.dmPelsHeight := sH
  dm.dmDisplayFrequency := rR
  return DllCall( "ChangeDisplaySettingsEx","Str","\\.\DISPLAY" Display, PTR, dM[""], PTR, 0, UInt,0, UInt, 0 )
}

InitStruct:
global POINTL:="x,y"
global DEVICEMODE :="
  (
  TCHAR dmDeviceName[32]; // CCHDEVICENAME:=32
  WORD  dmSpecVersion;
  WORD  dmDriverVersion;
  WORD  dmSize;
  WORD  dmDriverExtra;
  DWORD dmFields;
  union {
    struct {
      short dmOrientation;
      short dmPaperSize;
      short dmPaperLength;
      short dmPaperWidth;
      short dmScale;
      short dmCopies;
      short dmDefaultSource;
      short dmPrintQuality;
    };
    struct {
      POINTL dmPosition;
      DWORD  dmDisplayOrientation;
      DWORD  dmDisplayFixedOutput;
    };
  };
  short dmColor;
  short dmDuplex;
  short dmYResolution;
  short dmTTOption;
  short dmCollate;
  TCHAR dmFormName[32];
  WORD  dmLogPixels;
  DWORD dmBitsPerPel;
  DWORD dmPelsWidth;
  DWORD dmPelsHeight;
  union {
    DWORD dmDisplayFlags;
    DWORD dmNup;
  };
  DWORD dmDisplayFrequency;
  DWORD dmICMMethod;
  DWORD dmICMIntent;
  DWORD dmMediaType;
  DWORD dmDitherType;
  DWORD dmReserved1;
  DWORD dmReserved2;
  DWORD dmPanningWidth;
  DWORD dmPanningHeight;
)"
Return
Image

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, Google [Bot], Nerafius and 188 guests