how to disable minimize and maximize buttons on main window

how to disable minimize and maximize buttons on main window

Postby Tevlac » Wed Aug 01, 2007 1:08 pm

Hello all,
Can you send me a sample showing how to disable minimize and maximize buttons on main window MDI
Thank you
Tevlac
 
Posts: 5
Joined: Wed Aug 01, 2007 6:55 am
Location: Noumea

Postby Antonio Linares » Wed Aug 01, 2007 4:48 pm

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd STYLE nOr( WS_CAPTION, WS_VISIBLE, WS_SYSMENU ) MDI

   ACTIVATE WINDOW oWnd

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Tevlac » Wed Aug 01, 2007 7:47 pm

Thank you Antonio
Tevlac
 
Posts: 5
Joined: Wed Aug 01, 2007 6:55 am
Location: Noumea

Re: how to disable minimize and maximize buttons on main window

Postby anserkk » Mon Feb 01, 2010 6:34 am

Hi,

What would be the command to remove only the Maximize/Restore button from a MDI child window. ie I need the minimize and close buttons to be there on the windows.

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: how to disable minimize and maximize buttons on main window

Postby RAMESHBABU » Mon Feb 01, 2010 7:26 am

Hi Anser

Here it is

Code: Select all  Expand view

#include "FiveWin.ch"

#define MF_BYPOSITION 1024 // 0x0400
#define MF_DISABLED   2

function Main()

   local oWnd

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 70  STYLE nOR(WS_POPUP, WS_VISIBLE, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME,WS_MINIMIZEBOX) MDI

   ACTIVATE WINDOW oWnd ON INIT RemoveMItems(oWnd, .T.)

return nil

***********

FUNCTION RemoveMItems(oWin, lDisable)

LOCAL hMenu  := 0
LOCAL nCount := 0

IF lDisable
   hMenu  = GetSystemMenu(oWin:hWnd, .F.)
   nCount = GetMItemCount(hMenu)
   IF oWin:ClassName() = "TDIALOG"
      RemoveMenu(hMenu, 1, nOR( MF_BYPOSITION, MF_DISABLED) )
   ELSE
      RemoveMenu(hMenu, nCount - 3, nOR( MF_BYPOSITION, MF_DISABLED) )
      RemoveMenu(hMenu, nCount - 7, nOR( MF_BYPOSITION, MF_DISABLED) )
   ENDIF
   DrawMenuBar( oWin:hWnd )
ELSE
   GetSystemMenu( oWin:hWnd, .T. )
   DrawMenuBar( oWin:hWnd )
ENDIF

RETURN nil

 


Regards,

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: how to disable minimize and maximize buttons on main window

Postby anserkk » Mon Feb 01, 2010 8:08 am

Dear Ramesh,

Thank you for the code. Your sample code is working fine on the MDI window, unfortunately when I try it on the MDI CHILD window of my real app, only the Close button is getting disabled
Image

1. If I create the MDI child window without applying any style (Default one) only the Close button is disabled and the other controls ie Minimize & Maximaize are active

Code: Select all  Expand view
DEFINE WINDOW oWnd MDICHILD OF WndMain() FROM 0.5,2 to 27.5,47 TITLE "Quick Search" ;
                      ICON  oAppIcon COLOR oApp:nTextClr, oApp:nBkgClr


2. If I create the MDI child window with the style specified on your code ie STYLE nOR(WS_POPUP, WS_VISIBLE, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME,WS_MINIMIZEBOX), then I am getting the following error.

Code: Select all  Expand view
DEFINE WINDOW oWnd MDICHILD OF WndMain() FROM 0.5,2 to 27.5,47 TITLE "Quick Search" ;
                      ICON  oAppIcon COLOR oApp:nTextClr, oApp:nBkgClr ;
                      STYLE nOR(WS_POPUP, WS_VISIBLE, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME,WS_MINIMIZEBOX)
 

Code: Select all  Expand view
  Called from: source\rtl\tobject.prg => TMDICHILD:ERROR(172)
   Called from: source\rtl\tobject.prg => TMDICHILD:MSGNOTFOUND(205)
   Called from: source\rtl\tobject.prg => TMDICHILD:DEFCONTROL(0)
   Called from: .\source\classes\SAY.PRG => TSAY:NEW(145)
   Called from: .\CStock.PRG => QUICKSEARCH(509)


The error seems to be from the Class SAY.
Am I missing something ?

My requirement is to either remove OR disable the Maximize/Restore control on the MDI CHILD window. My first preference is to remove the Maximize/Restore control

Thanks in advance.

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: how to disable minimize and maximize buttons on main window

Postby James Bott » Mon Feb 01, 2010 5:52 pm

Anser,

>My requirement is to either remove OR disable the Maximize/Restore control on the MDI CHILD window. My first preference is to remove the Maximize/Restore control

This sounds like a non-modal dialog. Have you consider that?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: how to disable minimize and maximize buttons on main window

Postby anserkk » Tue Feb 02, 2010 7:29 am

Hi Mr.James,

The following code solved my problem. Applying the following style, disabled the Maximize/Restore button on a MDICHILD Window.
If this also failed then I would have opted a Non Modal Dialog.

Code: Select all  Expand view
DEFINE WINDOW oWnd MDICHILD of WndMain() ;
                    STYLE  nOr( WS_CAPTION, WS_VISIBLE, WS_SYSMENU, WS_MINIMIZEBOX )

ACTIVATE WINDOW oWnd


Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: how to disable minimize and maximize buttons on main window

Postby nageswaragunupudi » Tue Feb 02, 2010 1:45 pm

Where is the need to adopt such complex approach? Cant we simply disable these buttons while creating the window ( normal, MDI, MDICHILD ) by using the syntax already provided by FWH?

CREATE WINDOW ....... NOMINIMIZE NOMAXIMIZE

This does the job. Or am I missing something?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: how to disable minimize and maximize buttons on main window

Postby anserkk » Wed Feb 03, 2010 5:12 am

Dear Mr.Rao,

Your Quote
It is true that we can disable maximize or minimize buttons by simply using clauses NOMAXIMIZE, NOMINIMIZE, etc. while creating the window. But still the user can resize the window by dragging the right bottom corner of the window.

aMinMaxInfo gives us the full control on resizing. ( We can also control with ON RESIZE clause, but that is not elegant )

I found that, using the single line code using the STYLE is serving the expected behavior.
Code: Select all  Expand view
STYLE  nOr( WS_CAPTION, WS_VISIBLE, WS_SYSMENU, WS_MINIMIZEBOX )


According to me the disadvantage of using aMinMaxInfo is that it requires me to calculate the height and width in pixels. In future every time I need to alter the window size, I will have to recalculate the height and width again. Whereas using the STYLE, I need not bother about it. I don't use resource editors.

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests