it is just a tip to make your messagerequester centered with your main window :
Code: Select all
#WIN_MAIN = 0
Global WinMainX, WinMainY, WinMainWidth, WinMainHeight
Procedure RequesterCallBack(hWnd, uMsg, wParam, lParam)
hWnd = FindWindow_(#Null,"Requester Center")
If hWnd
GetWindowRect_(hWnd,cr.RECT)
GetWindowRect_(WindowID(#WIN_MAIN),cr_main.RECT)
WinMainX = WindowX(#WIN_MAIN)
WinMainY = WindowY(#WIN_MAIN)
WinMainWidth = cr_main\right - cr_main\left
WinMainHeight= cr_main\bottom - cr_main\top
width = cr\right - cr\left
height = cr\bottom - cr\top
x = WinMainX + (WinMainWidth - width) /2
y = WinMainY + (WinMainHeight - height) /2
SetWindowPos_(hWnd,0,x,y,0,0,#SWP_NOSIZE|#SWP_NOZORDER)
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(#WIN_MAIN,0,0,320,140,"Main Window",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
SetWindowCallback(@RequesterCallBack())
TextGadget(0,60,40,190,30,"Move the window and clic me",#PB_Text_Center)
ButtonGadget(1,80,80,150,22,"- Clic me -")
Repeat
EventID = WaitWindowEvent(10)
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 1
MessageRequester("Requester Center","Center requester to the Main Window !")
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
