Results 1 to 7 of 7

Thread: Sub Classing,.....!

  1. #1
    Guest
    Code:
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Public Const GWL_WNDPROC = (-4)
    Public Const WM_NCLBUTTONDOWN = &HA1
    Public Const WM_NCLBUTTONUP = &HA2
    Public Const HTMAXBUTTON = 9
    Public OldWndProc As Long
    Public TheText  As String
    
    Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        If wMsg = WM_NCLBUTTONDOWN Then
            If wParam = HTMAXBUTTON Then
                TheText = "hello"
            End If
        End If
        WindProc = CallWindowProc(OldWndProc, hwnd, wMsg, wParam, lParam)
    End Function
    
    Public Sub Hook(hwnd As Long)
        OldWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
    End Sub
    
    Public Sub UnHook(hwnd As Long)
        SetWindowLong hwnd, GWL_WNDPROC, OldWndProc
        OldWndProc = 0
    End Sub
    <mindless rambling>
    damnit! I hate it when that happens I typed out the whole message, then hit the escape key(it deletes everything in a textbox)
    </>
    I just recently found out about the wonderful world of subclassing, I modeled this example from Megatrons code to minimize the window to the systray instead of to the taskbar. (my code works BTW, so that isnt what the question is about)

    what else can I have for wParam?
    I have HTMAXBUTTON, but I know that cant be all you can have...

    I would really appreciate some help

    Thanks,
    Dennis.

  2. #2
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Where can I start?

    Code:
    Public Const HTBORDER = 18
    Public Const HTBOTTOM = 15
    Public Const HTBOTTOMLEFT = 16
    Public Const HTBOTTOMRIGHT = 17
    Public Const HTCAPTION = 2
    Public Const HTCLIENT = 1
    Public Const HTCLOSE = 20
    Public Const HTERROR = (-2)
    Public Const HTGROWBOX = 4
    Public Const HTHELP = 21
    Public Const HTHSCROLL = 6
    Public Const HTLEFT = 10
    Public Const HTMAXBUTTON = 9
    Public Const HTMENU = 5
    Public Const HTMINBUTTON = 8
    Public Const HTNOWHERE = 0
    Public Const HTOBJECT = 19
    Public Const HTREDUCE = HTMINBUTTON
    Public Const HTRIGHT = 11
    Public Const HTSIZE = HTGROWBOX
    Public Const HTSIZEFIRST = HTLEFT
    Public Const HTSYSMENU = 3
    Public Const HTTOP = 12
    Public Const HTTOPLEFT = 13
    Public Const HTTOPRIGHT = 14
    Public Const HTTRANSPARENT = (-1)
    Public Const HTVSCROLL = 7
    Public Const HTZOOM = HTMAXBUTTON
    Courgettes.

  3. #3
    Guest
    thanks!

    so is it anything with HT in fornt of it?
    or are there more, without HT?

  4. #4
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    I think they all start with HT, becaue these values are supposed to be used with the WM_NCHitTest message. HT for Hit Test, geddit .

    I think they're all.
    Courgettes.

  5. #5
    Guest
    Usually messages are grouped together with a prefix hence I don't think there are any Non-HT constants.
    Likewise, SC = System Command, WM = Window Message, LB = ListBox, CB = ComboBox etc.

  6. #6
    Guest
    thanks to all of you!!
    subclassing sure does add more functionality than Vb offers, but I thought it did more than this.
    so the wMsg can be anything with WM prefix??

  7. #7
    Guest
    Yes, it can be any message.

    Notice the declaration of SendMessage.
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    We have those exact same parameters in our callback function.
    Code:
    Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    In relation to SendMessage, you can almost call this an "InterceptMessage" function.





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width