Solved

Problem with dropdown RxLib components and D6

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

690 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