Don't know anything about window handles


My problem is that I do not know what how to change this. It says ‘You should use Handle instead’. Does this mean it is safe for me to just simply replace any instance of the text ‘WinHWND’ with ‘Handle’? This may be right but I just want to be safe. And btw, this is highlighted under the deprecated items category.

Here is the code which I am using (I believe it was written by Alex Restrepo; I cannot be certain):

#pragma unused set
  #if TargetWin32
    Dim oldFlags as Integer
    Dim newFlags as Integer
    Dim styleFlags As Integer
    Const SWP_NOSIZE = &H1
    Const SWP_NOMOVE = &H2
    Const SWP_NOZORDER = &H4
    Const GWL_STYLE = -16
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (hwnd As Integer,  _
    nIndex As Integer) As Integer
    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (hwnd As Integer, _
    nIndex As Integer, dwNewLong As Integer) As Integer
    Declare Function SetWindowPos Lib "user32" (hwnd as Integer, hWndInstertAfter as Integer, _
    x as Integer, y as Integer, cx as Integer, cy as Integer, flags as Integer) as Integer
    oldFlags = GetWindowLong(w.WinHWND, GWL_STYLE)
    if not set then
      newFlags = BitwiseAnd( oldFlags, Bitwise.OnesComplement( flag ) )
      newFlags = BitwiseOr( oldFlags, flag )
    styleFlags = SetWindowLong( w.WinHWND, GWL_STYLE, newFlags )
    styleFlags = SetWindowPos( w.WinHWND, 0, 0, 0, 0, 0, SWP_NOMOVE +_
    #pragma unused w
    #pragma unused flag

What are ‘window handles’ for anyway? I have no knowledge or experience with the user32 declare function thingy-ma-bob, as far as I can remember.


Per the message, use “Handle”. “WinHWND” is deprecated.

AFAIK handles are used exclusively for declares and are the integer value of the ptr to the object in memory. If you cast them to a ptr they can be used with cocoa declares (and linux and windows declares) to modify the look and functionality of controls or windows themselves.