Link to home
Start Free TrialLog in
Avatar of norifumi
norifumiFlag for Spain

asked on

trapping events (window messages)

Hi all,

My question is about how trap a window message.
I have an MDI application, in VB6, and I want to prevent all the MDI child forms to be maximized.
So, I think I have to trap the windows event ( window message ), in order to avoid that. I can't take the maximize button out of the child form.

I read on the MSDN that the event is WM_MDIMAXIMIZE, but I don't know how to trap it.

Any idea??

Nori.
Avatar of AzraSound
AzraSound
Flag of United States of America image

>>I can't take the maximize button out of the child form

Why not set BorderStyle to Fixed Single and MinButton to True?  Max button will be visible but disabled.
Avatar of Shauli
Shauli

Put the line below in the Form_Resize event of the child form:

MDIForm.Arrange vbCascade

Not a very nice solution, but works :)

S
ps. Change MDIForm to your MDI form name

S
Avatar of norifumi

ASKER

I want the maximize button to be visible and enable, but when the user will press it, I need to avoid the window to be maximized, so I need to catch the event -WM_MDIMAXIMIZE-
The user must to be able to move, resize and minimize the window normally.

My problem is that I don't know how handle window events. I know that I have to use the API to do that, and I tried some code but it doesn't work.

About the shauli comment, I don't understand what do you want to say with arrenging the windows. besides, when a window is maximized, the resize event is not launch..

"besides, when a window is maximized, the resize event is not launch....."

Is that so?????????????????????????????


S
Sorry about the above comments, I couldn't resist :)
The Resize event does launch when you maximize a form. Do a simple test: Put a msgbox in Form_Resize and see for yourself. As for my suggestion, what it does, it cascades the form while it is resized. So it keeps it in normal mode instead of maximize all the time. However it is an "ugly" solution, as when the user tries to maximize, it does flicker once, trying to maximize and then back to normal. As I said above, it is not a nice solution, rather it is a kind of walkaround.

S
You're right, the resize event is launched..

but it is launched after the maximize. I mean, the window is maximized, then the resize event is raised.

On my concrete application, the window never can be on a maximize state, so I can't use this solution..
That's fair enough, I'll keep looking :)

S
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great answer!!
thanks, Azrasound, that was exactly what I was looking for. I tried on my project and it works perfectly.

Sorry cos I've spent three days on giving you the points, but this weekend I was on holidays :D

Thanks and greetings

Norifumi.
Glad I could help  :-)h