Solved

Problem with dropdown RxLib components and D6

Posted on 2002-05-27
5
716 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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