#PB_Window_MaximizeGadget value wrong ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

#PB_Window_MaximizeGadget value wrong ?

Post by luis »

Windows only.

When you create a PB Window specifying #PB_Window_MinimizeGadget there is a min button and the window is not resizable. It's ok since you didn't specify the #PB_Window_SizeGadget flag.

If you create the window again but specifying #PB_Window_MaximizeGadget there is a max button but the window is now resizable.

Why ?

I think there is a bug with the #PB_Window_MaximizeGadget value, since it has the #WS_SIZEBOX bit set.

Code: Select all


Debug RSet(Bin(#WS_SIZEBOX),32,"0") ; bit 18 is on
Debug RSet(Bin(#PB_Window_MaximizeGadget),32,"0") ; bit 18 is on, why ?
Debug RSet(Bin(#PB_Window_MinimizeGadget),32,"0") ; bit 18 is off, ok

Debug "minimize button, window not resizable"
OpenWindow(0,100,100,640,480,"", #PB_Window_MinimizeGadget)
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow

Debug "minimize button, window resizable as requested by specifying the #PB_Window_SizeGadget flag"
OpenWindow(0,100,100,640,480,"", #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow

Debug "maximize button, window is resizable, why ?"
OpenWindow(0,100,100,640,480,"", #PB_Window_MaximizeGadget)
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow

Debug "if I remove the #WS_SIZEBOX bit, the window is not resizeable anymore"
OpenWindow(0,100,100,640,480,"", #PB_Window_MaximizeGadget &~ #WS_SIZEBOX)
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow


Debug #PB_Window_MaximizeGadget ; current vale
Debug #PB_Window_MaximizeGadget & ~ #WS_SIZEBOX ; shouldn't have this value instead ?

Before reporting this as a bug, do you agree or am I missing something ?
"Have you tried turning it off and on again ?"
A little PureBasic review
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: #PB_Window_MaximizeGadget value wrong ?

Post by IdeasVacuum »

Just checked a few apps on my WinXP machine - it seems that they are all have resize if they have the maximize button enabled, so maybe it is simply 'standard' for Windows that way, just an MS quirk.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: #PB_Window_MaximizeGadget value wrong ?

Post by luis »

I think that's because a program which can be resized usually (99%) can also be maximized. So it's a coincidence because a lot of programs are made that way.

But there is no reason for not having a window not resizable AND maximizable.

You can make one using API or in PB by removing the #WS_SIZEBOX from the PB constant. The point is in PB that bit is always bundled with the maximize button, and that's not happening with the minimize bottom.
And that's is in contrast with your everyday experience using API, where the resizable flag doesn't follow the maximize button. Why ?

Code: Select all

Global hBrush = CreateSolidBrush_(GetSysColor_(#COLOR_WINDOW))

Procedure WinProc (hWnd, Msg, wParam, lParam) 
  Select Msg
    Case #WM_CLOSE
      DestroyWindow_(hWnd)
     
    Case #WM_NCDESTROY
      DeleteObject_(hBrush)
      PostQuitMessage_(0)
      ProcedureReturn 0     
  EndSelect
 
  ProcedureReturn DefWindowProc_(hWnd, Msg, wParam, lParam)
EndProcedure

#WinStyle = #WS_VISIBLE | #WS_SYSMENU | #WS_OVERLAPPED | #WS_MINIMIZEBOX  | #WS_MAXIMIZEBOX ; | #WS_SIZEBOX

Classname$ = "TestClass"

With wClass.WNDCLASSEX
  \cbsize  = SizeOf(WNDCLASSEX)
  \lpfnWndProc  = @WinProc()
  \hCursor  = LoadCursor_(0, #IDC_ARROW)
  \hbrBackground  = hBrush
  \lpszClassName  = @classname$
EndWith

RegisterClassEx_(@wClass)

hWnd = CreateWindowEx_(0, classname$, "#WS_SIZEBOX bit", #WinStyle, 100, 100, 640, 480, 0, 0, 0, 0)

ShowWindow_(hWnd,  #SW_SHOWDEFAULT)

While GetMessage_(msg.MSG, 0, 0, 0 )
  TranslateMessage_(msg)
  DispatchMessage_(msg)
Wend
Maybe Fred followed the same line of thought: if you can maximize a window you should shuffle/resize its content too, so that same window is with a high level of probability also resizable. So maybe this is on purpose. In that case semantically it cannot be called bug obviously but it's still wrong/incoherent IMHO.

I don't see why you can't simply do as you please. As in with the API flags. You should simply be able to use #PB_Window_SizeGadget at your discretion, not find it already forced inside #PB_Window_MaximizeGadget.

Moreover the help says:
help wrote: #PB_Window_MaximizeGadget: Adds the maximize gadget to the window title bar. #PB_Window_SystemMenu is automatically added.
Does not mention #PB_Window_SizeGadget. So I still see it as a bug....

Probably I'm spending too much energy on this :lol:
"Have you tried turning it off and on again ?"
A little PureBasic review
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: #PB_Window_MaximizeGadget value wrong ?

Post by IdeasVacuum »

You should simply be able to use #PB_Window_SizeGadget at your discretion, not find it already forced inside #PB_Window_MaximizeGadget.
Agreed. Not a bug, more like 'an artificial limitation'. So, enhancement request?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: #PB_Window_MaximizeGadget value wrong ?

Post by luis »

At the moment for me is still a bug (a wrong value for the constant, for the reasons I have explained).
The idea of this thread was to get a possible argument against the fact it is a bug, and I haven't.
So I'm going to post in the bug section. Probably 1 minute after posting it there I'll be sliced to pieces by someone. LOL. Well, I did what I needed to do.
Thank you for your feedback :wink:
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply