Solved

Problem with dropdown RxLib components and D6

Posted on 2002-05-27
5
714 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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