Page 1 of 1

PB and WindowClass_X

Posted: Thu Aug 01, 2024 10:33 pm
by boddhi
Hello,

Does anyone know how PB assigns class names to apps opened through it.

I see that some are called WindowClass_0, others WindowClass_2, perhaps there are other increments as well?

Thanks for enlightening my foggy brain.

Re: PB and WindowClass_X

Posted: Fri Aug 02, 2024 10:41 am
by Axolotl
Hi boodhi,

here is my explanation (based on observations)
Since all controls under windows are (only) windows, different properties and behaviors are registered by the classes. (see RegisterClassEx function and WNDCLASSEX structure)
You can only assign a class to windows and controls when creating them. (see CreateWindowEx function)
For the main window PB uses a (free selectable) name "WindowClass_0", like

Code: Select all

  Protected hWnd = CreateWindowEx_(0,"WindowClass_0","The title of my window",#WS_OVERLAPPEDWINDOW,x,y,430,430,#Null, #Null, wc\hInstance, #Null)

So the main window name is not tied to specifications from windows, but freely selectable.
I have not yet found an explanation for the different numbers.
If I want to search for my own program via EnumChild(), I always check the "Classname" beforehand so that I don't get any surprises.
I remember that we had a (short) discussion on PB should make the Classname available to us by adding a parameter but Fred (unfortunately) refused.
There are samples of doing it by yourself with CreateWindowEx_.
BTW: The PB-IDE on my system has a Classname == "WindowClass_2" and the "Debug Output - " window uses WindowClass_2242169232944.
Hope this helps, or motivated others to supplement.

Re: PB and WindowClass_X

Posted: Fri Aug 02, 2024 11:12 pm
by boddhi
Axolotl wrote: here is my explanation (based on observations)
Thanks for your explanation.

For my part, after investigation, my conclusion is that numeral suffix corresponds to the constant or variable value or ID returned by #PB_Any at the moment of window creation.
Maybe, certainly, some people knew that, but for me it's a real discovery. :mrgreen:

My application windows have always short numbers because I use constants starting from 0 and the suffix is always the constant value.
Except for the tools in the Tools menu and some other windows, PB uses short numbers too, some examples:
WindowClass_1: Debugger
WindowClass_2: IDE
WindowClass_4: Prefs
WindowClass_10: Compiler options
WindowClass_26: History session

Re: PB and WindowClass_X

Posted: Sat Aug 03, 2024 11:56 am
by mk-soft
Windows only.
Sometimes it is better to have a separate ClassName for the window.
For example, to find a window via the ClassName and not via the window title.

Link: OpenClassWindow

Re: PB and WindowClass_X

Posted: Sat Aug 03, 2024 2:47 pm
by boddhi
mk-soft wrote: Link: OpenClassWindow
Hello,

Thanks for your link. I'll take a deeper look at it :wink:
But, as I'm not a great specialist in Windows APIs, and to make it easier to manage the positioning and resizing of windows/gadgets, I've taken to using the Dialog library.
The result, as you know, is that the class name is automatically assigned by PB, like with classic OpenWindow().

This raises a new (stupid?) question: Can the name of this class be change after the window creation?
PS: It's not a need, just by curiosity.
 

Re: PB and WindowClass_X

Posted: Sat Aug 03, 2024 3:05 pm
by mk-soft
No, that is not possible

Re: PB and WindowClass_X

Posted: Sat Aug 03, 2024 5:45 pm
by boddhi
I suspected as much. :wink:

Thanks.