Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Child Menu Goes off when other child gets focus

Status
Not open for further replies.

SidYuca

Technical User
Nov 13, 2008
79
MX
Imagine an MDI form with no menu (perhaps a design flaw). On MDI form sits form A with a menu. When a certain menu option is exercised Form A is resized And Form B (with several cmd buttons) is introduced to the left of Form A.
When any of the cmd buttons on B is clicked...then Menu on Form A goes off. I want it to stay on. To accomplish this I set the focus to form A. Problem is that I see the blink. Is there a way to keep Form A menu on when form A loses the focus (by virtue of the click on a cmd button on B?

Thanks for any suggestions.
 
One way, maybe not the best way, but the API LockWindowUpdate...(BTW this API is not suggested but...)
form1_deactivate
LockWindowUpdate me.hwnd

form1_activate
LockWindowUpdate 0&

I believe would be the only code you would need to add but if there is a better way I know someone will be along here shortly to point you in the correct direction.



Good Luck
 
Deja vu or what! I came on here today to ask a question about LockWindowUpdate.

I've steered clear using of this useful function because on some machines when I've turned off LockWindowUpdate it redraws all the desktop icons for some reason. Is this a known problem or is it just me using it incorrectly?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Okay, after further research, the general consensus on this forum is... it is okay to use the [tt]LockWindowUpdate[/tt] API just so long as it is for short operations. So SidYuca, I think in your case it will be fine to use since your operation is extremely short.



Good Luck
 
I would suggest creating the menu structure on MDI from instead of child form A.
This ensures the menu always stay there, no matter which child form is active.
 
I really appreciate everyones help and I thank you. I am afraid that I have gooten in too deep to find my way out. Hypeteria is probably correct but I didn't start out that way and starting all over is out of the question. Since form A is always visible and available to the user It has the menu options (right or wrong). I tried today to place a menu option on the MDi form in anticipation of making a change but when the program started form A covered the option. If I explain with a little more detail perhaps my error will shout out to someone. Program starts out with form A covering all of MDI form. User selects a particular option which introduces form B but first Form A's size is adjusted and moved towards the right. Form B, has 8 small square vertical labels (like an odometer)with a cmd button on either side of each label. The right hand cmd buttons have an up arrow on each and on the left side (you guessed it) a down arrow, The user may click any arrow (and he is nuts, any label or the form) What is supposed to happen is the user clicks an arrow, the 'odometer/label' is updated updated AND so are some labels/textboxes of form A. Problem: ANY click (up/down) toggles Menu A with all updates being made made. It is that little flash that is killing me. ALSO when user first elects to bring in Form B, the FrmA menu lightens.

I have introduced LockWindowUpdate in a module and for the life of me can not find the place to effectively lock form A.
 
Instead of Form B being a form, try placing a picturebox onto your MDI parent form, align it to the bottom, make it invisible and set its height to be the same as form B. Then instead of showing form B, make the picturebox visible and resize form A. You can then place your labels on the picturebox and dummy-up an 'X' in the top right corner so people can close it as if it was an actual form.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Thank you all for your suggestions. I have a 'fix' perhaps better called a 'work around'. I am not proud, but it works and as I do this as a hobby I have learned. Learned that I should have had a menu on the MDI form to start with.

This is what I did. I placed the same Menu items as I had on Form A on the MDI form (without code). Now when I pressed any of the three locations on Form B (form, label cmd) there was no blink (noticible at least). Now I had a new problem the menu on form A was locked! ... or was it? By changing the case on one of the menu items on the MDI form I found that the MDI form menu was being displayed (but not active..(no code). On the three points click events in questions I place "FormA.setfocus" and that did it.

Thank you all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top