PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD19] - MDI Child Window and Maximize
[WD19] - MDI Child Window and Maximize
Débuté par JP, 21 juil. 2014 10:05 - 9 réponses
Posté le 21 juillet 2014 - 10:05
Hi All,

I am using MDI child windows for a partcular application. Is there a way to either (1) hide the Maximize button, or (2) to trap the maximize button click and do something different with the window instead? I do not want the user to be able to maximize the window as it interferes with other interface design elements we have developed.

Thank you.
Posté le 21 juillet 2014 - 13:47
MDI is windows standard. I think you can not control it from Windev or any other tools.
Make and Open() Free/SDI window instead you create MDI window for this you want to control.
Posté le 21 juillet 2014 - 16:23
Hi JP,

I remember that there are ordinary API-calls to make those little buttons hide. Just use google
https://www.google.at/…
there should be something for you ...
Posté le 21 juillet 2014 - 18:27
Hi Guenter!

Thanks for the pointer. I have found a Microsoft article which seems to be exactly what you are referring to.

http://support.microsoft.com/kb/137033

However, I am not sure how to convert the VB code to WinDev. I have this so far:

FunctionReturn is int // C type:LONG hWnd is system int // C type:HWND nIndex is int // C type:int dwNewLong is int // C type:LONG hWnd = Handle() // Handle of current window nIndex = -16 // Taken from MS article: Const GWL_STYLE = (-16) dwNewLong = API( "USER32" , "GetWindowLongA" , hWnd , nIndex )
At this point the VB code declares some constants which I dont know how to convert to WinDev because I am not sure what the &H.... values are in the constants declaration of the article?

Const WS_MINIMIZEBOX = &H20000 Const WS_MAXIMIZEBOX = &H10000
And then the article shows this:

L = GetWindowLong(Me.hWnd, GWL_STYLE) // GWL_STYLE will be our Index variable L = L And Not (WS_MINIMIZEBOX) L = L And Not (WS_MAXIMIZEBOX) L = SetWindowLong(Me.hWnd, GWL_STYLE, L)
So I am not sure what values to use for the 2 constants WS_MINIMIZEBOX and WS_MAXIMIZEBOX and these constants do not appear in the WINCONST.WL file.

Once I know the constants then I can call:

=API( "USER32" , "SetWindowLongA" , hWnd , nIndex , dwNewLong)
to switch off the minimize and maximize buttons.

Any help appreciated :)
Posté le 21 juillet 2014 - 19:45
Hi JP,

You will have mixed results. I tried to do that in the past and did not succeded. But maybe you will.

Here is a code example to desable the "close" button on a MDI window (code needs to be in the MDI child window). (French code, but convert it to english).

cpFlags est un entier = 0x400 lpHandleMenu est un entier = AppelDLL32("user32","GetSystemMenu",Handle(FEN_YourWindow),0) // Delete the close menu option from the system menu of the window AppelDLL32("user32","DeleteMenu", lpHandleMenu, 6, cpFlags) // Delete the separator bar AppelDLL32("user32","DeleteMenu", lpHandleMenu, 5, cpFlags)
If you find something better, share your findings!

The problem is that when you maximize the window the buttons are shown again! And I fear there is no standard way to fix that asside of using skinning and managing the buttons yourself manually (which we did not want to do).

Best regards,
Alexandre Leclerc

Edit 1 & 2: Forgot to explain the problem we had.
Posté le 21 juillet 2014 - 19:50
Hi Alexandre,

I will definitely post any success but I need to know what values to pass/set for the WM_MINIMIZE and WM_MAXIMIZE parameters. I dont know what values to pass into the =API( "USER32" , "SetWindowLongA" , hWnd , nIndex , dwNewLong) function.

I am sure, however, that if I find the right parameters/values that this will work because the article comes from the Microsoft website itself :)
Posté le 21 juillet 2014 - 19:52
Hi JP,

This is hexadecimal. Just type it the same way WinDev expresses hexadecimal. Something like this:

CONSTANT
WS_MINIMIZEBOX = 0x20000
WS_MAXIMIZEBOX = 0x10000
END

Best regards,
Alexandre Leclerc
Posté le 22 juillet 2014 - 13:29
[SOLUTION]

It IS possible to hide the min and max buttons on a MDI window. You can either disable one or the other or hide them both.

You can add this code to the Initialization event of the window to hide the buttons before the window even appears or you can call it anytime you wish to make the buttons hidden.

// // Code comes from Microsoft article http://support.microsoft.com/kb/137033 // // The below comes from help given by developers Mike Gagnon and Gregory Adams // who converted the MS article to VFP for me and then I converted to WinDev. // // Microsoft constants // WS_MINIMIZEBOX = 0x20000 // WS_MAXIMIZEBOX = 0x10000 // WM_NCACTIVATE = 0x0086 // GWL_STYLE = -16 // Decalre the variables required hWindow_Handle is system int nGWL_Style is int nCurrentStyle is int // Setup the variables hWindow_Handle = Handle() // Handle of current window nGWL_Style = -16 // MS constant // Get the current style of the window title bar nCurrentStyle = API( "USER32" , "GetWindowLongA" , hWindow_Handle , nGWL_Style ) // Switch off the min and max buttons // Both min and max must be removed before they actually disappear // otherwise buttons are just disabled individually but still shown nCurrentStyle = BinaryAND( nCurrentStyle , BinaryNOT( 0x20000 ) ) // WS_MINIMIZEBOX = 0x20000 nCurrentStyle = BinaryAND( nCurrentStyle , BinaryNOT( 0x10000 ) ) // WS_MAXIMIZEBOX = 0x10000 nCurrentStyle = API( "USER32" , "SetWindowLongA" , hWindow_Handle , nGWL_Style , nCurrentStyle ) // Send a message to the window to redraw the borders and title bar which hides the min and max buttons. // This is not required if this code runs in the Initialization event of the windoww i.e. before it is drawn. API( "USER32" , "PostMessageA" , hWindow_Handle , 0x0086 , 0 , 0 ) // WM_NCACTIVATE = 0x0086
Posté le 22 juillet 2014 - 17:05
Hi JP,

Thank you for sharing this code. But on my tests, when the window is maximized (by programming, using Maximize()) the buttons are still visible in the "menu" part.

This is what I was saying about the "mixed" results. But I assume that you do not want the window to be maximized. In my case I was trying to have it exclusively maximized as a "backgroud" window in the main MDI window.

Best regards,
Alexandre Leclerc
Posté le 22 juillet 2014 - 17:12
Oh I see what you mean. Well, I was trying to prevent the window from being able to be maximized (or minimized) but still be able to use MDI functionality and in this it succeeds. If you override that and manually maximize the window I guess Windows then takes over and adds an un-maximize button to the menu bar. I guess that is required because Windows wants to give the user a way to un-maximize the window. But I would not be surprised if there was another API call to remove even that button perhaps?

By the way, the code above also disable the minimize and maximize menu options from the window's control menu. Which for me is also desired.