UsedWindow()
- tinman
- PureBasic Expert
- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
UsedWindow()
And anywhere else you can "use" something, it would be nice to be able to find out what number of item is currently being "used".
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
Re: UsedWindow()
EventWindowID()tinman wrote:And anywhere else you can "use" something, it would be nice to be able to find out what number of item is currently being "used".
EventGadgetID()
Does what you want, or maybe i don't understand you question.
ARGENTINA WORLD CHAMPION
Re: UsedWindow()
EventWindowID() and EventGadgetID() only gives you a hint what was used IF there WAS an EVENT.ricardo wrote:EventWindowID()tinman wrote:And anywhere else you can "use" something, it would be nice to be able to find out what number of item is currently being "used".
EventGadgetID()
Does what you want, or maybe i don't understand you question.
I suppose Tinman likes to see a command that tells him what was the last used Window or Gadget or whatever.
Something like a specialized GetFocus for each GUI control

Re: UsedWindow()
But you can store it on a variable.EventWindowID() and EventGadgetID() only gives you a hint what was used IF there WAS an EVENT.
I suppose Tinman likes to see a command that tells him what was the last used Window or Gadget or whatever.
Something like a specialized GetFocus for each GUI control
But maybe he is asking for some command to know the actuall/selected window, i mean with UseWindow()
However, all this info can be stored in a variable
ARGENTINA WORLD CHAMPION
- tinman
- PureBasic Expert
- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Re: UsedWindow()
Yes, it's very easy to do with something like this:ricardo wrote:But maybe he is asking for some command to know the actuall/selected window, i mean with UseWindow()
However, all this info can be stored in a variable
Code: Select all
DefType.l my_used_window : Global my_used_window
Procedure.l mUseWindow(window_number..l)
my_used_window = window_number
ProcedureReturn UseWindow(window_number)
EndProcedure
Procedure.l mUsedWindow()
ProcedureReturn my_used_window
EndProcedure
- I don't know if that is valid, for when I try to use a window that does not exist.
- you could end up in a situation where the value of my_used_window is different from the actual used window, if you are working in threads (although this would also be the case if done in the wrong way in a library)
- I need to do that for every library, which means (at the moment) all code will be included in the program. I assume the libraries would be written in the split format.
- PureBasic exe's are pretty quick, but a few lines of assembly kick the ass off any code written in basic.
Besides, people ask for all sorts of pointless crap here, I thought I'd join in ;)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
try this:
Note: This works only, when you use window-numbers under 101 and when no one of your window is active, the result is -1
GPI
Code: Select all
Procedure UsedWindow()
result=-1
aktiveWindow=GetFocus_()
for i=0 to 100
if aktiveWindow=WindowID()
result=i:i=99999
endif
next
procedurereturn result
endprocedure
GPI
@ GPI
your example will not work.
The WindowID is the hWnd of the OS, and this is never between 0 and 100.
Before, you could use an array, where you store the hWnd/WindowIDs together with the PB #Window number
Johannes
your example will not work.
The WindowID is the hWnd of the OS, and this is never between 0 and 100.
Before, you could use an array, where you store the hWnd/WindowIDs together with the PB #Window number
Code: Select all
Procedure UsedWindow()
result=-1
aktiveWindow=GetFocus_()
for i=0 to 100
if aktiveWindow=window(i):aktiveWindow=i
result=i:i=99999
endif
next
procedurereturn result
endprocedure
@JoRo: yes and no.
I had a little misstake. I write WindowID() instead of WindowID(i). If the Window i is not open, WindowID(i) will return 0.
I had a little misstake. I write WindowID() instead of WindowID(i). If the Window i is not open, WindowID(i) will return 0.
Code: Select all
Procedure UsedWindow()
result=-1
aktiveWindow=GetFocus_()
for i=0 to 100
if aktiveWindow=WindowID(i)
result=i:i=99999
endif
next
procedurereturn result
endprocedure
@ GPI
I think, GetFocus_ delivers the hWnd of every active Window, incl. ChildWindows, and that are the Gadgets.
It is enough to move the mouse over a button and it gets the focus.
It is really not so simple, to get the active Window. In your example , you could store the active Window, Global Variable, it would hold the last change of the active Window.
The array, you are right, is not necessary.
Johannes
I think, GetFocus_ delivers the hWnd of every active Window, incl. ChildWindows, and that are the Gadgets.
It is enough to move the mouse over a button and it gets the focus.
It is really not so simple, to get the active Window. In your example , you could store the active Window, Global Variable, it would hold the last change of the active Window.
The array, you are right, is not necessary.
Johannes
Ok, GetFocus_() isn't the right function, try GetActiveWindow_(). It returns the WindowHandle of the active window, if the program create this window, otherwise 0. Try this:
Code: Select all
OpenWindow(0,0,200,100,100,0,"hallo")
creategadgetlist(WindowID())
ButtonGadget(0,10,10,80,80,"TEST")
OpenWindow(1,200,200,10,10,0,"hallo2")
oldfocus=-1
Repeat
WindowEvent()
x=Getactivewindow_()
If oldfocus<>x
oldfocus=x
Debug oldfocus
EndIf
ForEver
Ok, here are some Used-Functions, that might be Use-full
They all return the OS Handles, no PB Numbers.
What they return is the actual object set by the Use...() function, just like
timnam want's it
The info about these internal variables can be easily got from the
"PureBasic library descriptor.txt" file in the LibrarySDK folder.
Timo

They all return the OS Handles, no PB Numbers.
What they return is the actual object set by the Use...() function, just like
timnam want's it

The info about these internal variables can be easily got from the
"PureBasic library descriptor.txt" file in the LibrarySDK folder.
Code: Select all
Procedure.l UsedWindow() ; returns WindowID() of current used window
!EXTRN _PB_Window_Current
!MOV EAX, dword [_PB_Window_Current]
ProcedureReturn
EndProcedure
Procedure.l UsedFile() ; returns HANDLE of current used File
!EXTRN _PB_File_Current
!MOV EAX, dword [_PB_File_Current]
ProcedureReturn
EndProcedure
Procedure.l UsedFont() ; returns HFONT of current used font
!EXTRN _PB_Font_Current
!MOV EAX, dword [_PB_Font_Current]
ProcedureReturn
EndProcedure
Procedure.l UsedMenu() ; returns HMENU of currenmt used menu
!EXTRN _PB_Menu_Current
!MOV EAX, dword [_PB_Menu_Current]
ProcedureReturn
EndProcedure
Procedure.l UsedDrawingDC() ; returns DC (Device Context) of current drawing operation
!EXTRN _PB_2DDrawing_CurrentDC
!MOV EAX, dword [_PB_2DDrawing_CurrentDC]
ProcedureReturn
EndProcedure
Procedure.l UsedImage() ; returns ImageID() of current used Image
!EXTRN _PB_Image_CurrentObject
!MOV EAX, dword [ _PB_Image_CurrentObject]
ProcedureReturn
EndProcedure
quidquid Latine dictum sit altum videtur
- tinman
- PureBasic Expert
- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Who's that ;pfreak wrote:What they return is the actual object set by the Use...() function, just like timnam want's it :wink:
Besides, it is nothing like what I want. You've just sent some procedures which are *exactly* the same as "WindowID()". I'd like the window number.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)