Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Getting Data from User32.dll

Author
Message
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 10th Nov 2013 15:42
Hello everybody,

I need to get some data from the user32.dll for some general window & display functions.

I found this to get the data for the window borders and titlebar:

Works like a charm! Got screen size dragging and resolutions all working.

Now I need to get the info of the window, when the window is maximised (in windowed mode) to do the same. The above data does not fit. Anyone knows?

If anyone got a list, or another form of reference for possible more data I could get from the user32.dll, you'd make me very happy!

Thanks!

Regards Sph!nx
www.mental-image.net
Broken_Code
14
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 10th Nov 2013 17:21
Tagging in for MailBack.
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Nov 2013 20:12
When the window is maximized, it covers your entire screen, minus the height of the task bar / whatever that thing at the bottom of the screen is called. The borders of the window also disappear, leaving your client rect as (DESKTOP WIDTH, DESKTOP HEIGHT - TASKBAR HEIGHT - WINDOW CAPTION BAR HEIGHT).
So those are the values you want to search for I guess


"Why do programmers get Halloween and Christmas mixed up?"
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 10th Nov 2013 21:24
Hey Rudolpho,

Exactly, I tried those from the snippet I provided in the first post. It works for (non maximised) windows. When the window is maximised, the captionbar is probably a bit smaller as well, because I cannot use those values to perfectly fit the render screen...

So, I need to extract them, from the dll (cause of differences in themes and such)... Got an idea how?

Regards Sph!nx
www.mental-image.net
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Nov 2013 21:55
Have you tried SM_CXFULLSCREEN (16) and SM_CYFULLSCREEN (17) with GetSystemMetrics?
Their names hint thats their purpose and they return 1980x1018 for me, which seems reasonable in a 1980x1080 display mode.


"Why do programmers get Halloween and Christmas mixed up?"
Le Verdier
13
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 10th Nov 2013 22:42
Try: "IsZoomed" function

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633531(v=vs.85).aspx

Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 10th Nov 2013 23:25 Edited at: 10th Nov 2013 23:26
@ Rudolpho
It would seem that way, but I get an error, about 32 but not support in that mode... which is odd, never had that one before.

@ Le Verdier
Dont need to detect if it is in windowed, maximised state. Got that covered, but thanks.

Regards Sph!nx
www.mental-image.net
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Nov 2013 23:38
What exact error message are you getting?
That shouldn't happen, are you sure it isn't something else causing it?

Does this also fail? (Just made some minor changes to your own snippet).



"Why do programmers get Halloween and Christmas mixed up?"
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 10th Nov 2013 23:49 Edited at: 10th Nov 2013 23:52
Yeah, I did it exactly like that. It is followed by a function that changes the resolution like so:

and then another function reloads all lost media.

Pretty straight forward I think. I can switch between fullscreen and windowed, drag the window edges and everything adapts the resolution just fine... except for maximised.

The error is:
Quote: "Runtime Error 1507 - Display using 32 bit is not supported by available hardware at line 95"


Well, it's definitely not my hardware...

Regards Sph!nx
www.mental-image.net
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Nov 2013 23:52
Oh, well you know you have to scale the display mode up to the nearest supported one, right?
Setting a display mode like 1920x1018x32 will most likely fail on any machine; use 1920x1080 instead
For the case of a maximized you want to set the display mode to your desktop dimensions, since those reflect the currently enabled display mode.


"Why do programmers get Halloween and Christmas mixed up?"
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 10th Nov 2013 23:56 Edited at: 10th Nov 2013 23:58
That was the first thing I tried and just tried it again to be sure.

It seems to work fine. Text is displayed right, but that's hardly an indication so I also use an image with a fine 1x1 'scanline'. It does load right and all, but still shows a slight crop in maximised window. I believe it only affects height, because the window does have a titlebar/captionbar.

Regards Sph!nx
www.mental-image.net

Login to post a reply

Server time is: 2025-05-16 20:51:32
Your offset time is: 2025-05-16 20:51:32