• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 762
  • Last Modified:

borland builder MDI modal window key down event

In Borland Builder an MDI application has a Modal window which is not a Child window.  For non-child modal windows, how does one get the OnKeyDown event?


0
lirtua
Asked:
lirtua
1 Solution
 
DrDelphiCommented:
You could send a user defined message back to the mainform:

MODAL form's OnKeyDown event handler:

{
  SendMessage(FindWindow('TMyMainForm',null),WM_USER+100,0,0);
}  



MainForm:

class TMyMainForm : public TForm
{
__published:     // IDE-managed Components
private:     // User declarations
public:          // User declarations
       __fastcall TMyMainForm(TComponent* Owner);
       void __fastcall ProcessMyMessage(TMessage &msg);
       BEGIN_MESSAGE_MAP
       MESSAGE_HANDLER(WM_USER+100, TMessage, ProcessMyMessage)
       END_MESSAGE_MAP(TForm)
};


//MyMainform cpp


void __fastcall TMyMainForm::ProcessMyMessage(TMessage &msg)
{
 if (msg.Msg=WM_USER+100) ShowMessage("Modal form keydown event fired");
}




Good luck!!



0
 
lirtuaAuthor Commented:
ok - this looks cool - i'll give it a try sometime this week - have a couple other issues that need fixing first - i'll let you know how it goes in a few days
0
 
lirtuaAuthor Commented:
Ok DrDelphi - heres the deal - it works almost all the time - it doesnt work the first time, ie if you start the app, open a modal non-child window, and then hit the MODAL form's OnKeyDown event - once you close the modal window, and reopen it, the code you gave works great - so im stumped

the solution looks pretty good - just needs small fix
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
DrDelphiCommented:
Hmmm.. sounds like a timing issue. I'd check the return of FindWindow to make sure that the "Main" form is being hit.

Good luck!!
0
 
griesshCommented:
Dear lirtua

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "DrDelphi"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
MindphaserCommented:
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now