Flickerfree my menu

Sometime I disable some menu items and after another some time I enable these.
When I do that ( enable or disable ) I get an ugly flickering. How to prevent that ?
LVL 9
ginsonicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Colin_DawsonCommented:
Try this.

Link each menu item to a TAction.  Use only the TAction's on update command to set the TAction.Enabled property.  This will be triggered everytime the menu is displayed, and is then updated BEFORE the menu it put on screen.
0
ginsonicAuthor Commented:
More details please. I don't use until now Actions.
0
nafeelmCommented:

How do u enable/disable the menu items - is it on a Button Click event or in the Menu's Click event!
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Colin_DawsonCommented:
Actions may seem daunting as first but they radically simply functions.  Here's a quick way to use them...

You'll find the actionlist component on the "Standard" Tool Pallette.

Drop the component onto your form and double click on it.
next Create an Action using popup editor screen.

At this point give the action a Name, and a Caption.  Next Goto the Events Tab, you'll see and OnUpdate, and an OnExecute event.  Use the OnUpdate to set the Enabled, checked and other properties.   The OnExecute method will be called Only if the Action is Enabled and The Action.Execute method is called.   Put the Code that was previously in your TMenuItem's OnClick Event into the Actions OnExecute.  Next remove the Menus onClick event completely.

Your TMenuItem has a property called Action.   Drop this list down and your new Action will be listed.  Select this, to make the MenuItem a slave of the action.   You do not need to set the Caption, Checked, Enabled, Visible or most of the other properties of the menuitem - The Action will take care of it for you.

Also you can place an action onto many other Delphi controls, Like a TSpeedButton and TButton.
0
ginsonicAuthor Commented:
When I click a button I show a second form. Then I disable some items until I will close the second form.

See the code for enable-disable here:

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20564097.html
0
Colin_DawsonCommented:
I've taken a look at the example code.   You don't need to do any of that, in fact I think it's that code that's causing the problem!

Using the general enable and disable will be OK, but using the method that I outlined about each of the menuitems will have it's own action.  Each of the Actions will have it's own OnUpdate (you could use a generic version and typecast if you like though)

The actions OnUpdate could look like this....


Procedure OnUpdate( Sender : TComponent );
Begin
  MyAction.Enabled := fMenuEnabled;
End;

As I said there is a generic version that could look like this...

Procedure OnUpdate( Sender : TComponent );
Begin
  If Sender <> nil Then
  Begin
    If Sender if TAction Then
      TAction( Sender ).Enabled := fMenuEnabled;
  End;
End;

You can then attach this method to all your action components.
0
ginsonicAuthor Commented:
Is the first time when I use actions. Can you give me more details how to add OnUpdate action?
Thanks!
0
Colin_DawsonCommented:
1. Drop a TActionList onto your form
2. Double Click the TActionList component.
3. Right click on the window that Pops up.
4. Select New Action
5. Click on that Action
6. Switch to the Property Inspector in delphi
7. Change to the Events Tab

The Lowest Event if the OnUpdate
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ginsonicAuthor Commented:
I done all this. After that I remove from menuClick event the code and add it to Action OnExecute event.

I added the Action to Menu item.

Is the right way ?

Making all this the flickering is still there :(
0
Colin_DawsonCommented:
You've done everything right, OK back to basics....

how exactly is the menu flickering?  Any chance that you can post your source/exe somewhere so that I can take a closer look?
0
ginsonicAuthor Commented:
I will put a sample project today.
0
CleanupPingCommented:
ginsonic:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.