Thanks for the help.
The reason i dont have a window with a border is because i want this to look the same on any version of windows and it will also allow me to put the titlebar on any side of the window.
The code you posted has helped but the close button dosent show after a repaint
Code: Select all
#Window_Constants = #PB_Window_BorderLess | #PB_Window_ScreenCentered
Procedure MouseOver(X,Y,W,H)
X=WindowX()+X:Y=WindowY()+y
GetCursorPos_(mouse.POINT) : MX=mouse\x : MY=mouse\y
If MX > X And MX Y And MY < Y + H
Over = 1
Else
Over = 0
EndIf
Else
Over = 0
EndIf
ProcedureReturn Over
EndProcedure
Procedure CallBack(WindowID.l,Message.l,wParam.l,lParam.l)
Result.l
Result=#PB_ProcessPureBasicEvents
Select Message
Case #PB_EventRepaint
StartDrawing(WindowOutput())
Box(0,0,250,150,RGB(64,64,64))
Box(0,0,249,149,RGB(212,208,200))
Box(1,1,248,148,RGB(128,128,128))
Box(1,1,247,147,RGB(255,255,255))
Box(2,2,246,146,RGB(212,208,200))
Box(3,3,244,18,RGB(10,36,106))
DrawingMode(1)
FrontColor(255,255,255)
Font1=CreateFont_(13,5,1,100,100,0,0,0,1,1,1,1,1,"Tahoma")
DrawingFont(Font1)
FrontColor(128,128,128)
Locate(6,6)
DrawText("Test Window")
FrontColor(255,255,255)
Locate(5,5)
DrawText("Test Window")
StopDrawing()
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(1,0,0,250,150,#Window_Constants,"Test Window")
SetWindowCallback(@CallBack())
If CreatePopupMenu(1)
MenuItem(1,"Move")
MenuBar()
MenuItem(2,"Close Window"+Chr(9)+"Alt+F4")
DisableMenuItem(1,1)
EndIf
If CreateGadgetList(WindowID())
Btn1=ButtonGadget(1,229,5,16,14,"X")
EndIf
AddKeyboardShortcut(1,#PB_Shortcut_Alt | #PB_Shortcut_F4,2)
Repeat
Select WindowEvent()
Case #WM_LBUTTONDOWN
If MouseOver(3,3,227,18)
SendMessage_(WindowID(), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
Case #WM_RBUTTONDOWN
If MouseOver(3,3,227,18)
DisplayPopupMenu(1,WindowID())
EndIf
Case #PB_EventMenu
Select EventMenuID()
Case 1
SendMessage_(WindowID(), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
Case 2
End
EndSelect
EndSelect
ForEver
EndIf