Optional parameter for OpenWindow - classname
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Optional parameter for OpenWindow - classname
Currently the classname is chosen by Purebasic using a combination of "WindowClass" + "_<window number>" resulting in names like "WindowClass_0" etc. There is nothing inherently wrong with this and it's effective in having a different classname for each window your application creates, however for people wanting to create and distribute professional-grade software applications, it is rather pedestrian. I would like to have an optional parameter at the end of the OpenWindow parameter list which would allow the PB coder to choose something more descriptive of what the application is, e.g. "AccountsPlus 2.01 Main WindowClass" or such, putting a nice polish on the work.
BERESHEIT
Re: Optional parameter for OpenWindow - classname
Agreed. But I do note that in the meantime, you can just hex edit your
exe and replace that text with your own (short) class name instead.
exe and replace that text with your own (short) class name instead.

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Optional parameter for OpenWindow - classname
"just"just hex edit your exe

Every single time I recompile the program?
And you can't make the string longer safely. A decidedly awkward and mickey-mouse solution imho, but one I've resorted to several times, hence the feature request for a proper one.
BERESHEIT
Re: Optional parameter for OpenWindow - classname
Well, you only need to do it once; not every time of compilation.
Just for when your app goes live to the public, wouldn't you?
Just for when your app goes live to the public, wouldn't you?
Last edited by PB on Sat Aug 21, 2010 3:40 pm, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Optional parameter for OpenWindow - classname
Sounds nice - even if I have to hex-edit it.
Where is the "WindowClass" + "_<window number>" observable to the normal end user? I was unable to locate it unless I used something like windowse.
cheers
Where is the "WindowClass" + "_<window number>" observable to the normal end user? I was unable to locate it unless I used something like windowse.
cheers
Re: Optional parameter for OpenWindow - classname
Window classes are never viewable by normal end users (ie. your grandma).
I suspect netmaestro is more concerned with his peers seeing it, using an
app like you mentioned, that shows all tech specs about a window. There's
a similar thread where someone wanted to hide all "PB_" text in the exe for
much the same reason.
I suspect netmaestro is more concerned with his peers seeing it, using an
app like you mentioned, that shows all tech specs about a window. There's
a similar thread where someone wanted to hide all "PB_" text in the exe for
much the same reason.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Optional parameter for OpenWindow - classname
Thanks PB.
cheers
cheers
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Optional parameter for OpenWindow - classname
I am not concerned on any level about peers or anyone else seeing it and deducing that it was created with Purebasic. I'm proud to say I used Purebasic. The only concern I have is that my perfectly good and reasonable feature request is being polluted with a pointless discussion.
BERESHEIT
Re: Optional parameter for OpenWindow - classname
Sorry Mr Maestro, it was not my intent to dilute the request.
I agree it's a valid feature request. I was merely attempting to gain additional insite.
cheers
I agree it's a valid feature request. I was merely attempting to gain additional insite.
cheers
Re: Optional parameter for OpenWindow - classname
I still don't understand why, what would be the advantage, except for cosmetic reasons?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Optional parameter for OpenWindow - classname
Did you read my post? I said it's for cosmetic reasons. :roll:
BERESHEIT
Re: Optional parameter for OpenWindow - classname
Window classes are just a techincal detail, its not something the typical user knows about (or cares about). So what is the point?
quidquid Latine dictum sit altum videtur
Re: Optional parameter for OpenWindow - classname
Yeah, I read it, but I just could not believe the reason would be so... euh...netmaestro wrote:Did you read my post? I said it's for cosmetic reasons. :roll:


But seriously, who's ever going to see those class names?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Optional parameter for OpenWindow - classname
The thing is that a couple of my wip projects will mostly be evaluated by people of an advanced level and I'd like to put some polish on them. Look at the software offerings of any professional group and you won't see generic classnames. But- if nobody else cares then it likely won't get done. No biggie, I can just make API windows and add gadgets to them as needed. Thanks for reading anyway.
BERESHEIT
Re: Optional parameter for OpenWindow - classname
You can create a PB window with your classname
Example :
Example :
Code: Select all
Import "window.lib"
CompilerIf #PB_Compiler_Unicode
_PB_Window_ProcessEvent(a,b,c,d) As "_PB_Window_ProcessEvent_UNICODE@16"
CompilerElse
_PB_Window_ProcessEvent(a,b,c,d) As "_PB_Window_ProcessEvent@16"
CompilerEndIf
PB_Window_Icon
PB_Window_Cursor
PB_Window_Objects
PB_Object_GetOrAllocateID(*Object,id)
EndImport
Procedure NewOpenWindow(id,x,y,cx,cy,title.s,flags=#WS_VISIBLE|#WS_OVERLAPPEDWINDOW,parent=0)
Protected wnd.wndclass
Protected classname.s = "MY_OWN_CLASS"
Protected *WinObj.integer
Protected hWnd.i
Protected rc.rect
With wnd
\style = #CS_HREDRAW|#CS_VREDRAW
\lpfnWndProc = @_PB_Window_ProcessEvent()
\hInstance = GetModuleHandle_(0)
\hIcon = PB_Window_Icon
\hCursor = PB_Window_Cursor
\lpszClassName = @classname
\hbrBackground = #COLOR_WINDOW
\cbWndExtra = 0
\cbClsExtra = 0
EndWith
If RegisterClass_(wnd)
SetRect_(rc,0,0,cx,cy)
AdjustWindowRectEx_(rc,flags,0,#WS_EX_WINDOWEDGE)
If x = #PB_Ignore Or y = #PB_Ignore
x = #CW_USEDEFAULT
y = #CW_USEDEFAULT
EndIf
hWnd = CreateWindowEx_(#WS_EX_WINDOWEDGE,classname,title,flags,x,y,rc\right-rc\left,rc\bottom-rc\top,parent,0,GetModuleHandle_(0),0)
If hWnd
*WinObj = PB_Object_GetOrAllocateID(PB_Window_Objects,id)
*WinObj\i = hWnd
If id = #PB_Any
SetProp_(hWnd,"Pb_WindowID",*WinObj+1)
Else
SetProp_(hWnd,"Pb_WindowID",id+1)
EndIf
Else
UnregisterClass_(GetModuleHandle_(0),classname)
EndIf
EndIf
If id = #PB_Any
id = *WinObj
Else
id = hWnd
EndIf
ProcedureReturn id
EndProcedure
Procedure Main()
NewOpenWindow(0,#PB_Ignore,#PB_Ignore,200,200,"333")
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndProcedure:Main()