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
Solved

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

Posted on 2002-04-15
5
197 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
  • 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

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

Suggested Solutions

Title # Comments Views Activity
indy Tmemory stream non latin charcter issue 2 121
CheckListBox usage 3 71
Slow Restore if incremental backups using RDiff.exe 4 28
MS Access from Delphi 31 59
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

792 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