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 prevent a TDBEdit from taking over its parent's popup 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
28-Aug-02
Category
Database-VCL
Language
Delphi 2.x
Views
106
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

I have several TDBEdits on a groupbox which is on a TabControl. The TabControl has 
its own PopupMenu and the DBEdits are assuming this menu, even though I only want 
the DBEdits to have the standard Windows Edit/ Cut/ Paste. How do I stop the 
DBEdit's from assuming the TabControls PopUp? Their PopUpMenu property is not set 
to anything.

Answer:

That turned out to be a pretty hairy problem. I was able to solve it but the 
solution ain't pretty. Attach a common handler to all the edits OnContextMenu 
event. Modify the form as follows:

1   { ... }
2   private
3   { Private declarations }
4   
5   procedure wmUser(var msg: TMessage); message wm_user;
6   public
7     { Public declarations }
8   end;
9   
10  var
11    Form1: TForm1;
12  
13  implementation
14  
15  {$R *.DFM}
16  
17  type
18    twc = class(twincontrol)
19    public
20      property DefWndProc;
21    end;
22  
23  procedure TForm1.wmUser(var msg: TMessage);
24  begin
25    with twc(msg.wparam) do
26      callwindowproc(defwndproc, handle, wm_contextmenu, handle, msg.lparam);
27  end;
28  
29  procedure TForm1.Edit1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: 
30  Boolean);
31  begin
32    handled := true;
33    postmessage(handle, wm_user, wparam(Sender),
34      lparam(PointToSmallpoint((Sender as Tedit).ClientToScreen(mousepos))));
35  end;


What this does is jumping through hoops to get the WM_CONTEXTMENU message that triggers the menu past the default message handling code in the VCL. Tested with normal TEdits, D5.01, on Win95B.

			
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