?
Solved

Flickerfree my menu

Posted on 2003-04-01
12
Medium Priority
?
161 Views
Last Modified: 2012-05-04
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 ?
0
Comment
Question by:ginsonic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8249106
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
 
LVL 9

Author Comment

by:ginsonic
ID: 8251115
More details please. I don't use until now Actions.
0
 
LVL 1

Expert Comment

by:nafeelm
ID: 8252616

How do u enable/disable the menu items - is it on a Button Click event or in the Menu's Click event!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8256033
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
 
LVL 9

Author Comment

by:ginsonic
ID: 8258965
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
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8274957
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
 
LVL 9

Author Comment

by:ginsonic
ID: 8277788
Is the first time when I use actions. Can you give me more details how to add OnUpdate action?
Thanks!
0
 
LVL 4

Accepted Solution

by:
Colin_Dawson earned 150 total points
ID: 8278103
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
 
LVL 9

Author Comment

by:ginsonic
ID: 8278177
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
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8278217
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
 
LVL 9

Author Comment

by:ginsonic
ID: 8282426
I will put a sample project today.
0
 

Expert Comment

by:CleanupPing
ID: 9316513
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question