RE: Example DLL translation from VBA into Xbasic
Yes, you are right.
Yes, you are right.
Alpha Software Mobile Development Tools: Alpha Anywhere | Alpha TransForm |
. . . declare KERNEL32 LocalAlloc LLL 'this was moved upwards declare KERNEL32 LocalFree LL declarestruct _MESSAGE C128message declare KERNEL32 FormatMessage@FormatMessageA LLLLL(_MESSAGE)LL declarestruct _FILENAME C260filename declarestruct _FILENAMEA C14filenameA . . .
[...] DWORD dmFields; union { 1 struct { short dmOrientation; (2 bytes) short dmPaperSize; (2 bytes) short dmPaperLength; (2 bytes) short dmPaperWidth; (2 bytes) short dmScale; (2 bytes) short dmCopies; (2 bytes) short dmDefaultSource; (2 bytes) short dmPrintQuality; (2 bytes) }; 2 POINTL dmPosition; (structure 2 x long = 8 bytes) 3 DWORD dmDisplayOrientation; (4 bytes) 4 DWORD dmDisplayFixedOutput; (4 bytes) }; [...]
Type POINTL X as Integer (4 bytes) Y as Integer (4 bytes) End type [...] dmFields as INTEGER dmOrientation as CSHORT dmPaperSize as CSHORT dmPaperLength as CSHORT dmPaperWidth as CSHORT dmScale as CSHORT dmCopies as CSHORT dmDefaultSource as CSHORT dmPrintQuality as CSHORT dmPosition {POINTL} (structure 2 x long = 8 bytes) dmDisplayOrientation Integer (4 bytes) dmDisplayFixedOutput Integer (4 bytes) dmColor as CSHORT [...]
The first line is a part of member 1. The second line are the bits and bytes. The thirth shows the bytes you need. ||||| |12345678|12345678|12345678|12345678|12345678|12345678|12345678|12345678| |||
Type POINTL X as Integer (4 bytes) Y as Integer (4 bytes) End type [...] dmFields as INTEGER dmPosition {POINTL} (structure 2 x long = 8 bytes) dmDisplayOrientation Integer (4 bytes and functions as a dummy) dmDisplayFixedOutput Integer (4 bytes and functions as a dummy) dmColor as CSHORT [...]
[...] DWORD dmFields; union { 1 struct { short dmOrientation; (2 bytes) short dmPaperSize; (2 bytes) short dmPaperLength; (2 bytes) short dmPaperWidth; (2 bytes) short dmScale; (2 bytes) short dmCopies; (2 bytes) short dmDefaultSource; (2 bytes) short dmPrintQuality; (2 bytes) }; 2 POINTL dmPosition; (structure 2 x long = 8 bytes) 3 DWORD dmDisplayOrientation; (4 bytes) 4 DWORD dmDisplayFixedOutput; (4 bytes) }; [...]
Type POINTL X as Integer (4 bytes) Y as Integer (4 bytes) End type [...] dmFields as INTEGER dmOrientation as CSHORT dmPaperSize as CSHORT dmPaperLength as CSHORT dmPaperWidth as CSHORT dmScale as CSHORT dmCopies as CSHORT dmDefaultSource as CSHORT dmPrintQuality as CSHORT dmPosition {POINTL} (structure 2 x long = 8 bytes) dmDisplayOrientation Integer (4 bytes) dmDisplayFixedOutput Integer (4 bytes) dmColor as CSHORT [...]
The first line is a part of member 1. The second line are the bits and bytes. The thirth shows the bytes you need. |--dmOrientation--|---dmPapersize---|--dmPaperLength--|--dmPaperWidth---| |12345678|12345678|12345678|12345678|12345678|12345678|12345678|12345678| |--------DevM.dmPosition.X----------|----------DevM.dmPosition.X--------|
Type POINTL X as Integer (4 bytes) Y as Integer (4 bytes) End type [...] dmFields as INTEGER dmPosition {POINTL} (structure 2 x long = 8 bytes) dmDisplayOrientation Integer (4 bytes and functions as a dummy) dmDisplayFixedOutput Integer (4 bytes and functions as a dummy) dmColor as CSHORT [...]
declarestruct charbuf C32charbuf declarestruct CSHORT W1X declarestruct CWORD W1Y type DEVMODE dmDeviceName as charbuf dmSpecVersion as CWORD dmDriverVersion as CWORD dmSize as CWORD dmDriverExtra as CWORD dmFields as INTEGER dmOrientation as CSHORT dmPaperSize as CSHORT dmPaperLength as CSHORT dmPaperWidth as CSHORT dmScale as CSHORT dmCopies as CSHORT dmDefaultSource as CSHORT dmPrintQuality as CSHORT dmColor as CSHORT dmDuplex as CSHORT dmYResolution as CSHORT dmTTOption as CSHORT dmCollate as CSHORT dmFormName as charbuf dmLogPixels as CWORD dmBitsPerPel as INTEGER dmPelsWidth as INTEGER dmPelsHeight as INTEGER dmDisplayFlags as INTEGER dmDisplayFrequency as INTEGER dmICMMethod as INTEGER dmICMIntent as INTEGER dmMediaTYpe as INTEGER dmDitherTYpe as INTEGER dmReserved1 as INTEGER dmReserved2 as INTEGER dmPanningWidth as INTEGER dmPanningHeight as INTEGER end type type POINTL X as INTEGER Y as INTEGER end type type DEVMODA dmDeviceName as charbuf dmSpecVersion as CWORD dmDriverVersion as CWORD dmSize as CWORD dmDriverExtra as CWORD dmFields as INTEGER dmPosition as POINTL dmDummy as POINTL dmColor as CSHORT dmDuplex as CSHORT dmYResolution as CSHORT dmTTOption as CSHORT dmCollate as CSHORT dmFormName as charbuf dmLogPixels as CWORD dmBitsPerPel as INTEGER dmPelsWidth as INTEGER dmPelsHeight as INTEGER dmDisplayFlags as INTEGER dmDisplayFrequency as INTEGER dmICMMethod as INTEGER dmICMIntent as INTEGER dmMediaTYpe as INTEGER dmDitherTYpe as INTEGER dmReserved1 as INTEGER dmReserved2 as INTEGER dmPanningWidth as INTEGER dmPanningHeight as INTEGER end type declare USER32 EnumDisplaySettings@EnumDisplaySettingsA LLL(DEVMODE) declare USER32 EnumDisplaySettingsAlt@EnumDisplaySettingsA LLL(DEVMODA) declare USER32 ChangeDisplaySettings@ChangeDisplaySettingsA L(DEVMODE)L dim DevM as {DEVMODE} dim DevA as {DEVMODA} dlg= {lf}; Select Video Resolution; %str% dim disp as n disp=1 i=0 ; j=0 choices="" while disp > 0 disp= EnumDisplaySettingsAlt(0,i,DevA) i=i+1 if DevA.dmBitsPerPel>8 .and. DevA.dmPelsHeight>400 then j=j+1 choices=choices+"(res:"+DevA.dmBitsPerPel+" bpp at "+DevA.dmPelsWidth+\ " by "+DevA.dmPelsHeight+");"+crlf() end if end while dlg=dlg+crlf()+"{frame=1,"+j+"}"+crlf()+choices+ {lf}; ; %str% result=ui_dlg_box("Supported Video Resolutions",dlg) if result="Cancel" then end end if DevA.dmBitsPerPel=val(word(res,1," ")) DevA.dmPelsWidth = val(word(res,4," ")) DevA.dmPelsHeight= val(word(res,6," ")) CONSTANT DM_PELSWIDTH = hex_to_dec("80000") constant DM_PELSHEIGHT = hex_to_dec("100000") CONSTANT DM_BITSPERPEL = hex_to_dec("40000") DevA.dmFields = DM_PELSWIDTH .or. DM_PELSHEIGHT .or. DM_BITSPERPEL DevA.dmDisplayFrequency=60 b = ChangeDisplaySettings(DevA, 0)
Comment