1. Windows - DEVMODE

The following bit of code is supposed to set the screen resolution to 
640X480 but it doesn't change.  (I have my screen set to 1024X768)
This works when I code it in C.  Therefor, I believe I may have the 
wrong offsets for the structure members, but I'm not sure.

dmScreenSettings = allocate(148)  --DEVMODE structure
mem_set(dmScreenSettings,0,148)  --clear smScreenSettings
poke(dmScreenSettings + 36,148)   --dmSize
poke4(dmScreenSettings + 
40,or_all({DM_BITSPERPEL,DM_PELSWIDTH,DM_PELSHEIGHT}))  -- dmFields
poke4(dmScreenSettings + 91, 24)  -- dmBitsPerPel
poke4(dmScreenSettings + 95, 640)   --dmPelWidth
poke4(dmScreenSettings + 99, 480)  --dmPelHeight
if c_func(ChangeDisplaySettingsA,{dmScreenSettings,CDS_FULLSCREEN}) != 
DISP_CHANGE_SUCCESSFUL then
        retval =  message_box("The requested fullscreen mode is not 
supported by\nyour video card. ", "Error", or_bits(MB_OK,MB_ICONSTOP))
end if

new topic     » topic index » view message » categorize

2. Re: Windows - DEVMODE

----- Original Message ----- 
From: "Evan Marshall" <1evan at sbcglobal.net>
To: <EUforum at topica.com>
Subject: Windows - DEVMODE


> 
> 
> The following bit of code is supposed to set the screen resolution to 
> 640X480 but it doesn't change.  (I have my screen set to 1024X768)
> This works when I code it in C.  Therefor, I believe I may have the 
> wrong offsets for the structure members, but I'm not sure.
> 
> dmScreenSettings = allocate(148)  --DEVMODE structure
> mem_set(dmScreenSettings,0,148)  --clear smScreenSettings
> poke(dmScreenSettings + 36,148)   --dmSize
> poke4(dmScreenSettings + 
> 40,or_all({DM_BITSPERPEL,DM_PELSWIDTH,DM_PELSHEIGHT}))  -- dmFields
> poke4(dmScreenSettings + 91, 24)  -- dmBitsPerPel
> poke4(dmScreenSettings + 95, 640)   --dmPelWidth
> poke4(dmScreenSettings + 99, 480)  --dmPelHeight
> if c_func(ChangeDisplaySettingsA,{dmScreenSettings,CDS_FULLSCREEN}) != 
> DISP_CHANGE_SUCCESSFUL then
>         retval =  message_box("The requested fullscreen mode is not 
> supported by\nyour video card. ", "Error", or_bits(MB_OK,MB_ICONSTOP))
> end if

Maybe you do have the offsets incorrect. Here is wha I make them to be...

typedef struct _devicemode {    /* dvmd */
  0    TCHAR  dmDeviceName[32];
 32    WORD   dmSpecVersion;
 34    WORD   dmDriverVersion;
 36    WORD   dmSize;
 38    WORD   dmDriverExtra;
 40    DWORD  dmFields;
 44    short  dmOrientation;
 46    short  dmPaperSize;
 48    short  dmPaperLength;
 50    short  dmPaperWidth;
 52    short  dmScale;
 54    short  dmCopies;
 56    short  dmDefaultSource;
 58    short  dmPrintQuality;
 60    short  dmColor;
 62    short  dmDuplex;
 64    short  dmYResolution;
 66    short  dmTTOption;
 68    short  dmCollate;
 70    TCHAR  dmFormName[32];
102    WORD   dmUnusedPadding;
104    USHORT dmBitsPerPel;
106    DWORD  dmPelsWidth;
110    DWORD  dmPelsHeight;
114    DWORD  dmDisplayFlags;
118    DWORD  dmDisplayFrequency;
122    (sizeof)
} DEVMODE

This is why I use the allot(), fetch() and store() routines in win32lib. These
do the math for me.
-- 
Derek

new topic     » goto parent     » topic index » view message » categorize

3. Re: Windows - DEVMODE

Derek Parnell wrote:

>Maybe you do have the offsets incorrect. Here is wha I make them to be...
>

Thanks, but that didn't work either,  my numbers returned a 
DISP_CHANGE_SUCCESSFUL and yours
returned DISP_CHANGE_BADMODE.

Here's what the  Microsoft SDK reads,

typedef struct _devicemode {
BCHAR dmDeviceName[CCHDEVICENAME];
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; };
    POINTL dmPosition;
    DWORD dmDisplayOrientation;
    DWORD dmDisplayFixedOutput; };
short dmColor;
short dmDuplex;
short dmYResolution;
short dmTTOption;
short dmCollate;
BYTE dmFormName[CCHFORMNAME];
WORD dmLogPixels;
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
union {
    DWORD dmDisplayFlags;
    DWORD dmNup; }
DWORD dmDisplayFrequency;
#if(WINVER >= 0x0400)
    DWORD dmICMMethod;
    DWORD dmICMIntent;
    DWORD dmMediaType;
    DWORD dmDitherType;
    DWORD dmReserved1;
    DWORD dmReserved2;
    #if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
        DWORD dmPanningWidth;
        DWORD dmPanningHeight;
    #endif
#endif /* WINVER >= 0x0400 */ } DEVMODE;

new topic     » goto parent     » topic index » view message » categorize

4. Re: Windows - DEVMODE

> > dmScreenSettings = allocate(148)  --DEVMODE structure
> > mem_set(dmScreenSettings,0,148)  --clear smScreenSettings

I'm not sure setting up a DEVMODE structure this way is ideal ?
The MS docs state that one should use EnumDisplaySettings() to fill in your
DEVMODE structure completely with *valid* values first, and use this
structure when calling ChangeDisplaySettings().
... as it is, you've got a lot of invalid zeroes ( garbage ), in this struc{
Apparently, looping thru EnumDisplaySetting() by incrementing iModeNum, and
checking for 24,640,480... will give you the complete structure you need to
pass (to change), assuming it's a valid mode, without poking...

new topic     » goto parent     » topic index » view message » categorize

5. Re: Windows - DEVMODE

Wolf wrote:

> <SNIP>
>
>I'm not sure setting up a DEVMODE structure this way is ideal ?
>The MS docs state that one should use EnumDisplaySettings() to fill in your
>DEVMODE structure completely with *valid* values first, and use this
>structure when calling ChangeDisplaySettings().
>... as it is, you've got a lot of invalid zeroes ( garbage ), in this struc{
>Apparently, looping thru EnumDisplaySetting() by incrementing iModeNum, and
>checking for 24,640,480... will give you the complete structure you need to
>pass (to change), assuming it's a valid mode, without poking...
>
>  
Thanks.
You could be right, but like I said previously, it works when I do it 
this way in C.  I'll try this and see if it helps.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu