Restored from previous forum. Originally posted by Jose.
;
; Adapted sample Window.pb in samples, to demonstrate the problem
;
#G_EXIT = 1
lwMainWin = OpenWindow(0, 100, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
Debug WindowID()
Debug lwMainWin ; produce same result as WindowID()
Debug WindowID(#G_EXIT) ; returns 0=#G_EXIT
If lwMainWin 0
If CreateGadgetList(WindowID())
ButtonGadget(#G_EXIT,50,50,73,25,"Exit")
EndIf
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case #G_EXIT ; Exit button Clickd
; If Debugger is off, program crashes
CloseWindow(lwMainWin) ; <--- Causes Debugger error message
; Window object number is very High (Over 5000) are you Sure?
; No options available in debug window, only QUIT available.
; CloseWindow(WindowID()) ; <--- Causes Same Error
; CloseWindow(#G_EXIT) ; Works
; CloseWindow(WindowID(#G_EXIT)) ; Works
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
EndIf
MessageRequester("Debugging", "Finished" , 0)
End
; OPenWindow() should return WindowID(#G_EXIT) instead of WindowID()
; or internal windows handle, there must be a reason for this behavior.
; Can some one explain?
; Would be nice in the documentation to distinguish between these two values,
; and also to explain their use in PB.
Thanks
CloseWindow() problem
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
> lwMainWin = OpenWindow(0, ...
> [...]
> CloseWindow(lwMainWin)
Thats wrong.
CloseWindow(0) is right here, because
CloseWindow takes the internal PureBasic
number, like OpenWindow.
OpenWindow(1 .... -> CloseWindow(1)
OpenWindow(15 .. -> CloseWindow(15)
The value returned by OpenWindow and WindowID()
is the Windows OS handle for the Window.
This handle is used to mix PureBasic and Win32API
programming, but isnt needed with plain PureBasic
programming in general.
On Amiga and Linux it isnt the "Windows OS handle", you know...
cya,
...Danilo
(registered PureBasic user)
> lwMainWin = OpenWindow(0, ...
> [...]
> CloseWindow(lwMainWin)
Thats wrong.
CloseWindow(0) is right here, because
CloseWindow takes the internal PureBasic
number, like OpenWindow.
OpenWindow(1 .... -> CloseWindow(1)
OpenWindow(15 .. -> CloseWindow(15)
The value returned by OpenWindow and WindowID()
is the Windows OS handle for the Window.
This handle is used to mix PureBasic and Win32API
programming, but isnt needed with plain PureBasic
programming in general.
On Amiga and Linux it isnt the "Windows OS handle", you know...
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> lwMainWin = OpenWindow(0, [snip]
> CloseWindow(WindowID()) ; <--- Causes Error
Like Danilo said above, you must use CloseWindow with the same number
that you used with OpenWindow. So in the above, you should be using
CloseWindow(0) because you used OpenWindow(0).
PB - Registered PureBasic Coder
> lwMainWin = OpenWindow(0, [snip]
> CloseWindow(WindowID()) ; <--- Causes Error
Like Danilo said above, you must use CloseWindow with the same number
that you used with OpenWindow. So in the above, you should be using
CloseWindow(0) because you used OpenWindow(0).
PB - Registered PureBasic Coder
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Jose.
So the reason for two types of pointers for windows is realy to handle the other OS's.
The docs for WindowID([#Window]) say;
Returns the unique ID which identifie the current window in the operating system. This functions is very useful when another library need a window reference. An optionnal #Window can be specified
It's the optional #Window that I'm interested in, this means that WindowID() will do a look-up to find the Windows handle for an internal PB ID, correct?
As seen in the sample code, this fails, could be a bug.
Thanks
So the reason for two types of pointers for windows is realy to handle the other OS's.
The docs for WindowID([#Window]) say;
Returns the unique ID which identifie the current window in the operating system. This functions is very useful when another library need a window reference. An optionnal #Window can be specified
It's the optional #Window that I'm interested in, this means that WindowID() will do a look-up to find the Windows handle for an internal PB ID, correct?
As seen in the sample code, this fails, could be a bug.
Thanks
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Its not a bug.
WindowID(1) returns the Windows Handle for Window Number 1.
WindowID(2) returns the Windows Handle for Window Number 2.
Its just that CloseWindow() and all other PB-WindowCommands
dont use the Handle returned by WindowID(), but use the
PureBasic internal number... 0, 1, 2, 3, ... and so on.
Use it for a while and you´ll see its not a bug.
Its just logical...
cya,
...Danilo
(registered PureBasic user)
Its not a bug.
WindowID(1) returns the Windows Handle for Window Number 1.
WindowID(2) returns the Windows Handle for Window Number 2.
Its just that CloseWindow() and all other PB-WindowCommands
dont use the Handle returned by WindowID(), but use the
PureBasic internal number... 0, 1, 2, 3, ... and so on.
Use it for a while and you´ll see its not a bug.
Its just logical...
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm