To what extent do i have to understand Windows Programming to write programs in PureBASIC that are Windows Programs?
You dont really need to learn any WinAPI programming to write full windows programs in PB. The WinAPI is supported for use within PB for augmenting your code to have access to more advanced commands. Charles Petzold's book is a great one on the WinAPI and you will learn alot by reading it.
An Example of a program which has been given extra functionality by using a few WinAPI commands:
Code: Select all
Enumeration
#WINDOW_0
#WINDOW_1
#STRING_0
#BUTTON_0
#BUTTON_1
EndEnumeration
Procedure OpenModalWindow()
CallerID = WindowID(#WINDOW_0)
CallerNumber = EventWindowID()
If OpenWindow(#WINDOW_1, 300, 300, 200, 200, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar, "Modal Window")
EnableWindow_(CallerID, #FALSE)
SetWindowPos_(WindowID(#WINDOW_1), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE)
SetForegroundWindow_(WindowID(#WINDOW_1))
If CreateGadgetList(WindowID(#WINDOW_1))
ButtonGadget(#BUTTON_1, 40, 65, 110, 35, "Close")
EndIf
Repeat
EventID.l = WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case #BUTTON_1
Quit = 1
EndSelect
Case #PB_EventCloseWindow
Quit = 1
EndSelect
Until Quit = 1
CloseWindow(#WINDOW_1)
EndIf
EnableWindow_(CallerID, #TRUE)
SetForegroundWindow_(CallerID)
UseWindow(CallerNumber)
EndProcedure
;Open main window
If OpenWindow(#WINDOW_0, 200, 200, 200, 200, #PB_Window_SystemMenu | #PB_Window_TitleBar , "Parent Window")
If CreateGadgetList(WindowID())
ButtonGadget(#BUTTON_0, 40, 65, 110, 35, "open new window")
EndIf
EndIf
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventGadget
GadgetID = EventGadgetID()
If GadgetID = #BUTTON_0
OpenModalWindow()
EndIf
EndIf
Until EventID = #PB_EventCloseWindow
End