Positioning of MessageRequester
Posted: Sun Apr 02, 2006 8:41 pm
Is there a way to position MessageRequester? By default they are ScreenCentered.
Any ideas?
Any ideas?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure SetMessagePos(pos)
Protected x,y,t,hWnd
x = pos>>16 : y = pos & $FFFF
hWnd=0 : t=GetTickCount_()
While hWnd=0
hWnd = FindWindow_(#Null,"Notice")
If GetTickCount_()-t > 500 : Break : EndIf
Delay(1)
Wend
If hWnd : SetWindowPos_(hWnd,0,x,y,0,0,#SWP_NOSIZE|#SWP_NOZORDER) : EndIf
EndProcedure
OpenWindow(0,0,0,320,240,"Test Window",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
ButtonGadget(0,80,180,150,22,"Show Message")
Repeat
EventID = WaitWindowEvent(1)
Select EventID
Case #PB_Event_Gadget
x=20 : y=20 : pos=x<<16+y
CreateThread(@SetMessagePos(),pos)
MessageRequester("Notice","This isn't the center!")
EndSelect
Until EventID = #PB_Event_CloseWindow
Code: Select all
Procedure MsgCallback(hWnd, Message, wParam, lParam)
Select message
Case #WM_WINDOWPOSCHANGING
msgwin=FindWindow_("#32770", #Null) ;No need to loop, we know it's there
If msgwin
SetWindowPos_(msgwin,0,20,20,0,0,#SWP_NOSIZE|#SWP_NOZORDER)
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,320,240,"Test Window",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
ButtonGadget(0,80,200,150,22,"Show Message")
SetWindowCallback(@MsgCallBack())
Repeat
EventID = WaitWindowEvent(1)
Select EventID
Case #PB_Event_Gadget
MessageRequester("Notice","This isn't in the center")
EndSelect
Until EventID = #PB_Event_CloseWindow