Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to disable a TTimer while browsing a menu Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
26-Oct-02
Category
VCL-General
Language
Delphi All Versions
Views
131
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

I have an application that auto-minimizes itself after 4 seconds, when maximized 
(using TTimer). The main form has a menu. I want the Timer to be disabled while the 
user browses the menu items. Is that possible?

Answer:

Solve 1:

Add this line to your form declaration:
1   
2   protected
3   
4   procedure WMMenuSelect(var msg: TWMMenuSelect); message WM_MenuSelect;
5   
6   and then add this procedure:
7   
8   procedure TForm1.WMMenuSelect(var msg: TWMMenuSelect);
9   begin
10    tmrAutoClose.Enabled := (msg.MenuFlag = $FFFF);
11  end;



Solve 2:
12  
13  Yes. The form will get one special message when the menu is first opened 
14  (WM_ENTERMENULOOP) and a second when the menu is finally closed (WM_EXITMENULOOP). 
15  Add handlers for these and disable/ enable the timer in them.
16  
17  { ... }
18  private
19  
20  procedure WMEnterMenuLoop(var msg: TMessage);
21    message WM_ENTERMENULOOP;
22  procedure WMExitMenuLoop(var msg: TMessage);
23    message WM_EXITMENULOOP;
24  { ... }
25  
26  procedure TForm1.WMEnterMenuLoop(var msg: TMessage);
27  begin
28    IdleTimer.Enabled := false;
29    inherited;
30  end;
31  
32  procedure TForm1.WMExitMenuLoop(var msg: TMessage);
33  begin
34    IdleTimer.Enabled := true;
35    inherited;
36  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC