Page 1 of 2

Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 2:43 pm
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.

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 2:54 pm
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. ;)

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 2:58 pm
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.

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 3:11 pm
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?

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 3:25 pm
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

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 3:31 pm
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.

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 3:44 pm
by rsts
Thanks PB.

cheers

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 4:57 pm
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.

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 5:20 pm
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

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 9:18 pm
by blueznl
I still don't understand why, what would be the advantage, except for cosmetic reasons?

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 9:26 pm
by netmaestro
Did you read my post? I said it's for cosmetic reasons. :roll:

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 11:22 pm
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?

Re: Optional parameter for OpenWindow - classname

Posted: Sat Aug 21, 2010 11:35 pm
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?

Re: Optional parameter for OpenWindow - classname

Posted: Sun Aug 22, 2010 1:00 am
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.

Re: Optional parameter for OpenWindow - classname

Posted: Sun Aug 22, 2010 7:13 am
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()