Faced a problem - the hook is triggered and the window appears at the desired coordinates, but after a split second it moves to the last position (apparently after window creating in the code there is a call to SetWindowPos)
Code: Select all
Global Hook
Procedure CBTProc(nCode, wParam, lParam)
Protected *CBT.CBT_CREATEWND
Protected *PCS.CREATESTRUCT
Protected ClassName.s{#MAX_PATH}
Select nCode
Case #HCBT_CREATEWND
*CBT = lParam : *PCS = *CBT\lpcs
If *PCS\lpszClass = 32770 ; simpler than > If GetClassName_(wParam, @ClassName, #MAX_PATH-1) : If ClassName = "#32770"
Debug "Found!"
*PCS\x = 100
*PCS\y = 100
EndIf
EndSelect
; If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx
If nCode < 0
ProcedureReturn CallNextHookEx_(Hook, nCode, wParam, lParam)
Else
; For HCBT_CREATEWND return value must be 0 to allow the operation, or 1 to prevent it
ProcedureReturn #False
EndIf
EndProcedure
Hook = SetWindowsHookEx_ (#WH_CBT, @CBTProc() , 0, GetCurrentThreadId_())
OpenFileRequester( "" , "" , "" , 0 )
If Hook : UnhookWindowsHookEx_( Hook ) : EndIf
#HCBT_MOVESIZE doesn't work here.
Tested on Win7x64.
Is there a way to fix it without install another hook for messages (I consider this an overcomplication) or it's the only way?
I will be glad to any working examples.