Solved

Problem with dropdown RxLib components and D6

Posted on 2002-05-27
5
712 Views
Last Modified: 2012-08-14
I'm using D6 with RxLib. I set up my forms to respond to Esc key with closing:

procedure TForm2.FormKeyPress(Sender: TObject; var Key: Char);
begin
    if(Key = #27) then
    begin
      Key := #0;
      Close;
    end;
end;

It works properly, but when RxLib dropdown component (for instance RxLookupEdit or DBDateEdit) is dropped down and the user presses Esc, he gets the error with the message: 'Cannot focus a disabled or invisible window'.
It does not happen with Delphi dropdown components.

0
Comment
Question by:shrldu
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7036899
maybe you should first closeup the dropped list and the close your form like


procedure TForm2.FormKeyPress(Sender: TObject; var Key: Char);
begin
   if(Key = #27) then
   begin
     Key := #0;
     if (activecontrol is trx...) then
       trx...(activecontrol).closeup;  //or similar method to close the list
     //maybe an application.processmessages is needed here
     Close;
   end;
end;

meikl ;-)
0
 

Author Comment

by:shrldu
ID: 7036929
So fast response, thanks!
I tried it but CloseUp is protected. Can I cope with it? Or what else can do that?
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 7036938
well, no delphi on hand yet,
so i can't look a bit deeper
to the ascendors

at least you can crack protected methods
with a little trick like

//add this into your formunit
//with meaningfull replacements, of course ;-)
type
  tcrackclass = class(ClassNameWhichShouldBeCracked);

now you can access protected methods by typconversion to the tcrackclass

like

procedure TForm2.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if(Key = #27) then
  begin
    Key := #0;
    if (activecontrol is ClassNameWhichShouldBeCracked) then
      tcrackclass(activecontrol).closeup;  //access protected method
    //maybe an application.processmessages is needed here
    Close;
  end;
end;

maybe i can this evening look a bit closer,
if not solved until then

meikl ;-)
0
 
LVL 4

Expert Comment

by:nestorua
ID: 7037480
HI,
Use PopupCloseUp method instead of CloseUp.
TRxLookupEdit is inherited from TCustomComboEdit which has that method in protected section.
You can try to send the message CBN_CLOSEUP.
Sincerely,
Nestorua.
0
 

Author Comment

by:shrldu
ID: 7037724
Nestorua,

You are right, but the same problem is also with TRxDBLookupCombo where I had to use CloseUp and the trick provided by kretzschmar.

There is also additional problem that Delphi dropdown components after the first Esc close up, and the second Esc closes the form, while with the method implemented with kretzschmar and your help the form is closed immediately...

Thanks

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now