hooking windows dialog box?

Windows specific forum
Damion12
User
User
Posts: 81
Joined: Tue Oct 30, 2012 1:39 am

hooking windows dialog box?

Post by Damion12 »

I have the windows file-browser dialog up, but I wish to know when it's being moved & when it's stopped moving.
I tried a simple callback with #wm_move & #wm_moving but they didn't seem to get fired. Is there a way to hook windows dialogs?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4659
Joined: Sun Apr 12, 2009 6:27 am

Re: hooking windows dialog box?

Post by RASHAD »

Hi
You can use it with :
- OpenFileRequester()
- SaveFileRequester()
- MessageRequester()

- FontRequester() ;US OS
Title$ = "Font"

- ColorRequester() ;US OS
Title$ = "Color"

Code: Select all

Global Title$

Procedure FBrowser(Parameter)
  Repeat
    hwnd = FindWindow_("#32770",Title$)
  Until hwnd
  Repeat
    GetWindowRect_(hwnd,r.RECT)
    If GetAsyncKeyState_(#VK_LBUTTON) = 32768 And r\left <> oldleft
      Debug "Moving"
      oldleft = r\left
      flag = 1
    ElseIf GetAsyncKeyState_(#VK_LBUTTON) = 32768 And (r\right - r\left <> oldwidth Or r\bottom -r\top <> oldheight)
      Debug "Sizing"
      oldwidth = r\right - r\left
      oldheight = r\bottom -r\top
      flag = 1
    ElseIf GetAsyncKeyState_(#VK_LBUTTON) = 0 And flag = 1
      Debug "Stopped"
      flag = 0
    EndIf
  ForEver
EndProcedure

Thread = CreateThread(@FBrowser(), 0)

Title$ = "Please choose file to load"
File$ = OpenFileRequester(Title$, "", "", 0)
If File$
  Debug File$ 
  KillThread(Thread)
EndIf
Egypt my love
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: hooking windows dialog box?

Post by chi »

Code: Select all

Global hook, wndProc

Procedure HookCallback(hWnd, Msg, wParam, lParam)
  Select Msg
      
    Case #WM_WINDOWPOSCHANGED
      *wp.WINDOWPOS = lParam
      Debug "x:" + *wp\x + " y:" + *wp\y + " w:" + *wp\cx + " h:" + *wp\cy
      
  EndSelect
  ProcedureReturn CallWindowProc_(wndProc, hWnd, Msg, wParam, lParam)
EndProcedure

Procedure HookProc(nCode, wParam, lParam)
  Select nCode
      
    Case #HCBT_ACTIVATE
      wndProc = SetWindowLongPtr_(wParam, #GWL_WNDPROC, @HookCallback())
      UnhookWindowsHookEx_(hook)
      ProcedureReturn 0
      
  EndSelect
  ProcedureReturn CallNextHookEx_(hook, nCode, wParam, lParam)
EndProcedure

hook = SetWindowsHookEx_(#WH_CBT, @HookProc(), #Null, GetCurrentThreadId_())
OpenFileRequester("Open", "", "All files (*.*)|*.*", 0)
Et cetera is my worst enemy
Damion12
User
User
Posts: 81
Joined: Tue Oct 30, 2012 1:39 am

Re: hooking windows dialog box?

Post by Damion12 »

Thank you both.
The dialog I'm using is SHBrowseForFolder_() - I'll see if I can adapt/use either method with that.
Thank you for your replies... Sorry for my late reply, had a paper due that took all my attention.
Post Reply