Code: Alles auswählen
EnableExplicit
Enumeration
#Wnd_Main
EndEnumeration
Enumeration
#Cnt_Window
;:Exit Button
#Btn_Exit
#Img_BtnExit
;:Minimize Button
#Btn_Minimize
#Img_BtnMinimize
;:Draw Header
#Header
#Img_Header
;:Window Title
#Titel
;:Draw Footer
#Footer
#Img_Footer
;:Font
#Fnt_SegoeUI12
EndEnumeration
;:Define Colors
#Wnd_Color = $353535 ; dark grey
#Col_Header = $FFFFFF ; white
#Col_Footer = $808080 ; mid grey
#Col_Text = $666667 ; black grey
#Col_Container = $F0F0F0 ; silver grey
;:Window size
#Wnd_Width = 400 ; px
#Wnd_Height = 500 ; px
LoadFont(#Fnt_SegoeUI12, "Segoe Ui", 16, #PB_Font_HighQuality)
Define Event, EventType
Procedure DropShadow(Window)
; (WindowsAPI) - Generiert bei einem randlosen Fenster einen Schatten
If IsWindow(Window)
SetClassLongPtr_(WindowID(Window), #GCL_STYLE, #CS_DROPSHADOW)
EndIf
EndProcedure
Procedure SystemButtons()
;EXIT BUTTON
CreateImage(#Btn_Exit, 60, 60)
StartDrawing(ImageOutput(#Btn_Exit))
FillArea(1, 1, -1, #Col_Header)
Line(3, 56, 54, -54, #Col_Text)
Line(3, 4, 54, 54, #Col_Text)
StopDrawing()
ImageGadget(#Img_BtnExit, WindowWidth(0)-61, 1, 60, 60, ImageID(#Btn_Exit))
;MINIMIZE BUTTON
CreateImage(#Btn_Minimize, 40, 20)
StartDrawing(ImageOutput(#Btn_Minimize))
FillArea(1, 1, -1, #Col_Header)
Line(0, 19, 40, 1, #Col_Text)
StopDrawing()
ImageGadget(#Img_BtnMinimize, WindowWidth(0)-110, 37, 40, 40, ImageID(#Btn_Minimize))
EndProcedure
Procedure main()
OpenWindow(#Wnd_Main, 510, 311, #Wnd_Width, #Wnd_Height, " ", #PB_Window_BorderLess|#PB_Window_ScreenCentered|#PB_Window_Invisible)
SetWindowColor(#Wnd_Main, #Wnd_Color)
DropShadow(#Wnd_Main)
;HEADER
CreateImage(#Img_Header, WindowWidth(#Wnd_Main)-2, 60, 32, #Col_Header)
StartDrawing(ImageOutput(#Img_Header))
Box(0, 1, OutputWidth(), OutputHeight(), #Col_Header)
StopDrawing()
ImageGadget(#Header, 1, 1, 0, 0, ImageID(#Img_Header))
;disable to make it possible: grab with LMB Down
DisableGadget(#Header, #True)
;Set Window Title
TextGadget(#Titel, 10, 14, 160, 30, "Custom Window", #SS_CENTER)
SetGadgetColor(#Titel, #PB_Gadget_BackColor, #Col_Header)
SetGadgetColor(#Titel, #PB_Gadget_FrontColor, #Col_Text)
SetGadgetFont(#Titel, FontID(#Fnt_SegoeUI12))
;Add all Gadgets here
ContainerGadget(#Cnt_Window, 1, 62, WindowWidth(#Wnd_Main)-2, WindowHeight(#Wnd_Main)-94, #PB_Container_BorderLess)
SetGadgetColor(#Cnt_Window, #PB_Gadget_BackColor, #Col_Container)
;-
CloseGadgetList()
;Footer
CreateImage(#Img_Footer, WindowWidth(#Wnd_Main)-2, 30, 32, #Col_Footer)
ImageGadget(#Footer, 1, WindowHeight(#Wnd_Main)-31, 0, 0, ImageID(#Img_Footer))
SystemButtons()
HideWindow(#Wnd_Main, #False)
EndProcedure
main()
Repeat
Event = WaitWindowEvent()
EventType = EventType()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
;Exit
Case #Img_BtnExit
End
;Minimize
Case #Img_BtnMinimize
If EventType = #PB_EventType_LeftClick
SetWindowState(#Wnd_Main, #PB_Window_Minimize)
EndIf
EndSelect
;DRAG WITH MOUSE
Case #WM_LBUTTONDOWN
If WindowMouseX(#Wnd_Main) >= 0 And WindowMouseX(#Wnd_Main) <= WindowWidth(#Wnd_Main)-2 And WindowMouseY(#Wnd_Main) >= 0 And WindowMouseY(#Wnd_Main) <= 61
SendMessage_(WindowID(#Wnd_Main), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
EndSelect
;ESC exit program
If GetAsyncKeyState_(#VK_ESCAPE)
End
EndIf
ForEver