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 control focus in a MDI application 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
21-Oct-02
Category
Others
Language
Delphi 2.x
Views
107
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

Status: MDI-application. MDI window and one child window. MDI window owns a TPanel 
component, which owns any component which can get focus (TEdit for example). Child 
window owns a TDBGrid component.

Problem: After running this simple test application, the focus is set on child 
window's first focusable component - TDBGrid. After switching focus to TEdit 
component owned by MDI window, there is no more possibility to switch focus back to 
TDBGrid component owned by child window. TDBGrid component is immune to any mouse 
events. Why? It looks like a child window is thinking about still having focus.

Answer:

This is one of the many shortcomings of the Windows MDI framework, it has never 
been designed to cope with controls outside the MDI children that can take the 
focus. You can trick it by sending a WM_MDIACTIVATE message to the active MDI 
child, here demonstrated by an OnClick handler for a combobox on the toolbar:

1   procedure TMainForm.ComboBox1Click(Sender: TObject);
2   begin
3     { ... other actions }
4     if Assigned(ActiveMDIChild) then
5       with ActiveMDIChild do
6         sendmessage(handle, WM_MDIACTIVATE, 0, handle);
7   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