Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now