Jump to content

_WinAPI_SetWindowLong and $GWL_STYLE/$GWL_EXSTYLE


Recommended Posts

So this is a part of my code:

_WinAPI_SetWindowLong($wh, $GWL_STYLE, 0x94000000)
_WinAPI_SetWindowLong($wh, $GWL_EXSTYLE, 0x00040000)
_WinAPI_UpdateWindow($wh)

Now, my problem with some windows like games using 3D as content, I think it's because I directly overwrite any other flags that these windows have by totally replacing the values at the STYLE and EXSTYLE indexes, with these. It does the trick of removing the title, border and making the window appear on top of the taskbar when covering the whole screen, but how can I instead apply the flag for removal of title and border + the ontop flag, rather than completely overwriting the current flags?

Just an example; if the flags for style are 2, 4, 8, e.g. where 8 is title and border, the windows may have values of 12, 14, e.g. so then I'd like to remove 8 so we get 4 and 2 respectively; instead of doing like I currently do, totally resetting the value.

I am not quite sure how I should use _WinAPI_GetWindowLong($wh, $GWL_STYLE) then how do I remove the flag for title and border? Hmm...

*Edit*

The reason for this thread is because with my current code windows act weird, the 3D content acts like there is a title and border, so the mouse cursor has an offset, i.e. I have to click below a button in the game to actually click it, since with the title offset the game then interprets the mouse being over the button, while without the title the height shifts so there is a loss of visual sync between 3D and mouse pointer. :oops:

Also, do I really need _WinAPI_UpdateWindow at all? Just curious, not sure what it does exactly. :D

Edited by vladinator
Link to comment
Share on other sites

;Use BiXOR to Remove Styles & BitOR to add styles
$Style = _WinAPI_GetWindowLong($wh, $GWL_STYLE) ;Capture Existing Style
$ExStyle = _WinAPI_GetWindowLong($wh, $GWL_EXSTYLE) ;Capture Existing ExStyle
If BitAND($Style, $WS_SIZEBOX) = $WS_SIZEBOX Then ;if $WS_SIZEBOX IS Set
_WinAPI_SetWindowLong($wh, $GWL_STYLE, BitXOR($Style, $WS_SIZEBOX)) ;REMOVE $WS_SIZEBOX
EndIf
If BitAND($ExStyle, $WS_EX_TOPMOST) <> $WS_EX_TOPMOST Then ;if $WS_EX_TOPMOST is NOT Set
_WinAPI_SetWindowLong($wh, $GWL_EXSTYLE, BitOr($ExStyle, $WS_EX_TOPMOST)) ;ADD $WS_EX_TOPMOST
EndIf

Link to comment
Share on other sites

Thanks mate!

BiXOR to remove flag

BitOR to add flag

BitAND($bits, $flag) == $flag ; to check if the flag is there

BitAND($bits, $flag) <> $flag ; to check if the flag is missing

You may encounter unexpected results if you use "==" instead of "=" because "==" performs a String Comparison, not a numeric comparison.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...