Thanks guys, I think I'm getting the hang of it..
Code: Select all
; // declare,define,enumarate // ------------------------------------ //
Declare Open_Window_0()
Declare JumpLocations()
Declare MyWindowCallback(WindowID, Message, wParam, lParam)
Enumeration:#Window_0:EndEnumeration
Enumeration:#Button_0:EndEnumeration
Enumeration:#StatusBar_0:EndEnumeration
Enumeration:#Image0:EndEnumeration
Global hStatusBar
Quit.b = 0
Dim SB_Fields(2)
Image0 = CatchImage(0, ?Image0)
; // .begin // ------------------------------------------------------ //
Open_Window_0()
SetWindowCallback(@MyWindowCallback())
StatusBarIcon(#StatusBar_0, 0, Image0)
StatusBarIcon(#StatusBar_0, 1, Image0)
StatusBarText(#StatusBar_0, 0, "SIZE:")
StatusBarText(#StatusBar_0, 1, "LOCATION:")
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
GadgetID = EventGadgetID()
If GadgetID = #Button_0
If JumpLocations()
; ok
EndIf
EndIf
EndIf
Until Event = #PB_EventCloseWindow And Quit = 1
FreeStatusBar(#StatusBar_0)
End
; // MyWindowCallback // -------------------------------------------- //
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select WindowID
; Window_0
Case WindowID(#Window_0)
Select Message
Case #WM_MOVE
X = lParam & $FFFF
Y = lParam >> 16
If X > 60000
EnableWindow_(WindowID(#Window_0),#False)
MessageBox_(0,"I'm going back..","tsk tsk",#mb_systemmodal)
If JumpLocations()
EndIf
EnableWindow_(WindowID(#Window_0),#True)
EndIf
StatusBarText(#StatusBar_0, 1, "LOCATION: X: "+Str(X)+" Y: "+Str(Y))
Result = 0
Case #WM_SIZE
X = lParam & $FFFF
Y = lParam >> 16
ww.f = WindowWidth()
SB_Fields(0) = ((ww*50.00)/100.00)
SB_Fields(1) = ww
SendMessage_(hStatusBar,#SB_SETPARTS,2,@SB_Fields())
ResizeGadget(#Button_0,-1,-1,X/2, Y/2)
StatusBarText(#StatusBar_0,0, "SIZE X: " + Str(WindowWidth()) + " Y: " + Str(WindowHeight()))
Result = 0
Case #WM_GETMINMAXINFO ;window is about to be resized
*ptr.MINMAXINFO = lParam
*ptr\ptMinTrackSize\x = 408
*ptr\ptMinTrackSize\y = 227
Result = 0
Case #WM_CLOSE
Quit = 1
End
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
; // Open_Window_0 // ----------------------------------------------- //
Procedure Open_Window_0()
If OpenWindow(#Window_0, 0, 0, 400, 200, #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "My First CallBack")
hStatusBar = CreateStatusBar(#StatusBar_0, WindowID())
If hStatusBar
; ok
EndIf
If CreateGadgetList(WindowID())
ButtonGadget(#Button_0, 5,5, WindowWidth()/2, WindowHeight()/2, "PureBasic")
EndIf
EndIf
AddStatusBarField(WindowWidth()/2)
AddStatusBarField(WindowWidth()/2)
EndProcedure
;// ok, now im just being silly // ---------------------------------- //
Procedure.b JumpLocations()
SW = (GetSystemMetrics_(#SM_CXSCREEN))
SH = (GetSystemMetrics_(#SM_CYSCREEN))
If SetWindowPos_(WindowID(#Window_0), #HWND_TOP, SW/4, SH/4, SW/2, SH/2, #SWP_SHOWWINDOW)
rtn = 1
Else
rtn = 0
EndIf
ProcedureReturn rtn
EndProcedure
; // DataSection // ------------------------------------------------- //
DataSection
Image0:
IncludeBinary "C:\Program Files\NSIS\Contrib\Graphics\Icons\box-install.ico"
EndDataSection