Optional parameter for OpenWindow - classname

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Optional parameter for OpenWindow - classname

Post by netmaestro »

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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Optional parameter for OpenWindow - classname

Post by PB »

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. ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Optional parameter for OpenWindow - classname

Post by netmaestro »

just hex edit your exe
"just" :?:

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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Optional parameter for OpenWindow - classname

Post by PB »

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?
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.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Optional parameter for OpenWindow - classname

Post by rsts »

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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Optional parameter for OpenWindow - classname

Post by PB »

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 compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Optional parameter for OpenWindow - classname

Post by rsts »

Thanks PB.

cheers
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Optional parameter for OpenWindow - classname

Post by netmaestro »

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
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Optional parameter for OpenWindow - classname

Post by rsts »

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
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Optional parameter for OpenWindow - classname

Post by blueznl »

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... )
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Optional parameter for OpenWindow - classname

Post by netmaestro »

Did you read my post? I said it's for cosmetic reasons. :roll:
BERESHEIT
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Optional parameter for OpenWindow - classname

Post by freak »

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
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Optional parameter for OpenWindow - classname

Post by blueznl »

netmaestro wrote:Did you read my post? I said it's for cosmetic reasons. :roll:
Yeah, I read it, but I just could not believe the reason would be so... euh... :? well, take your pick,I'm sure you can come up with a good description 8)

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... )
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Optional parameter for OpenWindow - classname

Post by netmaestro »

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
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Re: Optional parameter for OpenWindow - classname

Post by hallodri »

You can create a PB window with your classname

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()
Post Reply