Solved

disable check/combo boxes losing focus in frames on key up / down

Posted on 2002-04-15
5
210 Views
Last Modified: 2010-04-04
Hi,

i got this form with a frame in it and i use it to let it scroll in 3 times so it seems like it's a new page everytime.
anyway if one uses the mouse only everything works fine
but if u select one checkbox and the press the up or down key the next / previous control gets focus and this is irritating since it messes with my scrolling
so i want to know how i can disable this.

I noticed there's no onkey down on frames, i tried onkeydown on each control in the frame and setting key to 0 didn't work
setted also the tabstops to false didn't work either

got any idea's ? thanks
0
Comment
Question by:joyrider
[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
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
freshman3k earned 50 total points
ID: 6943603
Hello!

I assumed that the name of your Scroll Box was ScrollBox1 so you could replace everywhere with your Scroll Box name

The Following should work:

private
    { Private declarations }
    procedure OnMessage(var Msg: tagMSG; var Handled: Boolean);
  public
    { Public declarations }
  end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMessage := OnMessage;
end;

procedure TForm1.OnMessage(var Msg: tagMSG; var Handled: Boolean);
var
  hi,vi,hp,vp: Integer;
begin
 if (Msg.message= WM_KEYDOWN) and
    (Msg.wParam=VK_LEFT or Msg.wParam=VK_UP or
    Msg.wParam=VK_RIGHT or Msg.wParam=VK_DOWN) then begin
 
   hi:=ScrollBox1.HorzScrollBar.Increment;
   vi:=ScrollBox1.VertScrollBar.Increment;
   hp:=ScrollBox1.HorzScrollBar.Position;
   vp:=ScrollBox1.VertScrollBar.Position;
   Handled:=True;
 
   if Msg.wParam=VK_LEFT then begin
   ScrollBox1.HorzScrollBar.Position=hp-hi;  end;
   if Msg.wParam=VK_UP then begin
   ScrollBox1.VertScrollBar.Position=vp-vi;  end;
   if Msg.wParam=VK_RIGHT then begin
   ScrollBox1.HorzScrollBar.Position=hp+hi;  end;
   if Msg.wParam=VK_DOWN then begin
   ScrollBox1.VertScrollBar.Position=vp+vi;
     end;  
  end
  else begin
  Handled:=False;
  end;
end;

Took me about 3 hours  :(

Good Luck!
0
 
LVL 2

Expert Comment

by:freshman3k
ID: 6943689
Hello!

I assumed that the name of your Scroll Box was ScrollBox1 so you could replace everywhere with your Scroll Box name

The Following should work:

private
    { Private declarations }
    procedure OnMessage(var Msg: tagMSG; var Handled: Boolean);
  public
    { Public declarations }
  end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMessage := OnMessage;
end;

procedure TForm1.OnMessage(var Msg: tagMSG; var Handled: Boolean);
var
  hi,vi,hp,vp: Integer;
begin
 if (Msg.message= WM_KEYDOWN) and
    (Msg.wParam=VK_LEFT or Msg.wParam=VK_UP or
    Msg.wParam=VK_RIGHT or Msg.wParam=VK_DOWN) then begin
 
   hi:=ScrollBox1.HorzScrollBar.Increment;
   vi:=ScrollBox1.VertScrollBar.Increment;
   hp:=ScrollBox1.HorzScrollBar.Position;
   vp:=ScrollBox1.VertScrollBar.Position;
   Handled:=True;
 
   if Msg.wParam=VK_LEFT then begin
   ScrollBox1.HorzScrollBar.Position=hp-hi;  end;
   if Msg.wParam=VK_UP then begin
   ScrollBox1.VertScrollBar.Position=vp-vi;  end;
   if Msg.wParam=VK_RIGHT then begin
   ScrollBox1.HorzScrollBar.Position=hp+hi;  end;
   if Msg.wParam=VK_DOWN then begin
   ScrollBox1.VertScrollBar.Position=vp+vi;
     end;  
  end
  else begin
  Handled:=False;
  end;
end;

Took me about 3 hours  :(

Good Luck!
0
 
LVL 2

Expert Comment

by:freshman3k
ID: 6943690
Hello!

I assumed that the name of your Scroll Box was ScrollBox1 so you could replace everywhere with your Scroll Box name

The Following should work:

private
    { Private declarations }
    procedure OnMessage(var Msg: tagMSG; var Handled: Boolean);
  public
    { Public declarations }
  end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMessage := OnMessage;
end;

procedure TForm1.OnMessage(var Msg: tagMSG; var Handled: Boolean);
var
  hi,vi,hp,vp: Integer;
begin
 if (Msg.message= WM_KEYDOWN) and
    (Msg.wParam=VK_LEFT or Msg.wParam=VK_UP or
    Msg.wParam=VK_RIGHT or Msg.wParam=VK_DOWN) then begin
 
   hi:=ScrollBox1.HorzScrollBar.Increment;
   vi:=ScrollBox1.VertScrollBar.Increment;
   hp:=ScrollBox1.HorzScrollBar.Position;
   vp:=ScrollBox1.VertScrollBar.Position;
   Handled:=True;
 
   if Msg.wParam=VK_LEFT then begin
   ScrollBox1.HorzScrollBar.Position=hp-hi;  end;
   if Msg.wParam=VK_UP then begin
   ScrollBox1.VertScrollBar.Position=vp-vi;  end;
   if Msg.wParam=VK_RIGHT then begin
   ScrollBox1.HorzScrollBar.Position=hp+hi;  end;
   if Msg.wParam=VK_DOWN then begin
   ScrollBox1.VertScrollBar.Position=vp+vi;
     end;  
  end
  else begin
  Handled:=False;
  end;
end;

Took me about 3 hours  :(

Good Luck!
0
 

Author Comment

by:joyrider
ID: 6945218
i'm goana tried it out immeadiatly =)
0
 

Author Comment

by:joyrider
ID: 6945251
Works like a charm !
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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 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