No announcement yet.

Windows Hook

  • Filter
  • Time
  • Show
Clear All
new posts

  • Windows Hook

    I am creating a shell app. Essentially, I want to start an exe after a user clicks a button and intercept certain messages, like WM_RESIZE...

    Here is the rough code. My best reference book, Advanced Windows, is in storage.

    #Compile Exe
    #Include "WIN32API.INC"
    #Include "COMMCTRL.INC"
    %IDOK       = 1
    %IDCANCEL   = 2
    %BS_DEFAULT = 1
    $APP_NAME = "Shell"
    CallBack Function OkButton()
        Dim lHandle As Long
        lHandle =Shell("...")
        REM Problem Here.....
        SetWindowsHookEx(3,AppWndProc,lHandle,  0)
    End Function
    CallBack Function CancelButton()
      Dialog End CbHndl, 0
    End Function
    Function PbMain () As Long
      $Register None
      Local hDlg   As Long
      Local result As Long
    ' ** Create a new dialog template
      Dialog New 0, $APP_NAME, ,, 100, 45, %WS_SYSMENU, 0 To hDlg
    ' ** Add controls to it
      Control Add Button, hDlg, %IDOK, "Start", 5, 5, 40, 14, %BS_DEFAULT Call OkButton
      Control Add Button, hDlg, %IDCANCEL, "&Cancel", 50, 5, 40, 14, 0 Call CancelButton
    ' ** Display the dialog
      Dialog Show Modal hDlg To result
    End Function
    Function AppWndProc (ByVal hWnd As Long, ByVal wMsg As Long,ByVal wParam As Long, ByVal lParam As Long) As Long
    End Function
    Thanks In Advance,

    Last edited by Gary Beene; 12 Jul 2014, 08:52 PM. Reason: Code: tags
    It's hard when you're up to your armpits in alligators to remember you came here to drain the swamp.
    President Reagan
    February 10, 1982

  • #2
    I'm not at my DEV PC to check this, but in general, hook functions that are not "local" to your app must be placed into a DLL. Also, you'd need to pass the address of your WndProc, so you'll need to use CODEPTR(). Finally, I recall that the value returned by SHELL() is an instance handle rather than a process handle...

    When I get back to my DEV PC, I'll double check these facts.

    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    mailto:[email protected]