J'avais besoin pour un programme de pouvoir positionner un "MessageRequester", ou je le voulais, alors j'ai fait ce petit code que je vous partage.
Code : Tout sélectionner
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
DisableASM
EnableExplicit
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Structure MSGBOX
m_Hook.i
m_Left.i
m_Top.i
EndStructure
Global msgbox.MSGBOX
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
#SWVB_DEFAULT = $FFFFFFFF
; **********************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure.i MsgBoxHook(nCode.i, wParam.i, lParam.i)
;
Protected x.l
Protected y.l
Protected nSize.i
Protected tmpHook.i
Protected sBuffer.s
Protected Height.i
Protected Width.i
Protected fHeight.i
Protected fWidth.i
Protected wndRect.rect
tmpHook = CallNextHookEx_(msgbox\m_Hook, nCode, wParam, lParam)
If nCode = #HCBT_ACTIVATE
sBuffer = Space(32)
nSize = GetClassName_(wParam, sBuffer, 32)
If Left(sBuffer, nSize) <> "#32770"
ProcedureReturn #False
EndIf
GetWindowRect_(wParam, wndRect)
Height = (wndRect\bottom - wndRect\top) / 2
Width = (wndRect\right - wndRect\left) / 2
GetWindowRect_(GetParent_(wParam), wndRect)
fHeight = wndRect\top + (wndRect\bottom - wndRect\top) / 2
fWidth = wndRect\left + (wndRect\right - wndRect\left) / 2
If msgbox\m_Left = #SWVB_DEFAULT
x = fWidth - width
Else
x = msgbox\m_Left
EndIf
If msgbox\m_Top = #SWVB_DEFAULT
y = fHeight - height
Else
y = msgbox\m_Top
EndIf
SetWindowPos_(wParam, #HWND_TOP, x, y, 0, 0, #SWP_NOSIZE + #SWP_NOZORDER + #SWP_NOACTIVATE)
UnhookWindowsHookEx_(msgbox\m_Hook)
ProcedureReturn tmpHook
EndIf
EndProcedure
Procedure.i MessageResquestBOX(spromp.s, button.l, stitle.s, left.l, top.l)
;
Protected hInst.i
Protected thread.i
Protected hInstance.i
Protected wndRect.rect
hInstance = GetModuleHandle_(0)
thread = GetCurrentThreadId_()
With msgbox
\m_Hook = SetWindowsHookEx_(#WH_CBT, @MsgBoxHook(), hInst, thread)
\m_Left = left
\m_Top = top
EndWith
ProcedureReturn MessageRequester(stitle, spromp, button)
EndProcedure
; **********************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Debug MessageResquestBOX("Le message...", #PB_MessageRequester_YesNoCancel, "Votre Titre", 300, 800)
End
GallyHC