joyrider
asked on
disable check/combo boxes losing focus in frames on key up / down
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.HorzScrollB ar.Increme nt;
vi:=ScrollBox1.VertScrollB ar.Increme nt;
hp:=ScrollBox1.HorzScrollB ar.Positio n;
vp:=ScrollBox1.VertScrollB ar.Positio n;
Handled:=True;
if Msg.wParam=VK_LEFT then begin
ScrollBox1.HorzScrollBar.P osition=hp -hi; end;
if Msg.wParam=VK_UP then begin
ScrollBox1.VertScrollBar.P osition=vp -vi; end;
if Msg.wParam=VK_RIGHT then begin
ScrollBox1.HorzScrollBar.P osition=hp +hi; end;
if Msg.wParam=VK_DOWN then begin
ScrollBox1.VertScrollBar.P osition=vp +vi;
end;
end
else begin
Handled:=False;
end;
end;
Took me about 3 hours :(
Good Luck!
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.HorzScrollB
vi:=ScrollBox1.VertScrollB
hp:=ScrollBox1.HorzScrollB
vp:=ScrollBox1.VertScrollB
Handled:=True;
if Msg.wParam=VK_LEFT then begin
ScrollBox1.HorzScrollBar.P
if Msg.wParam=VK_UP then begin
ScrollBox1.VertScrollBar.P
if Msg.wParam=VK_RIGHT then begin
ScrollBox1.HorzScrollBar.P
if Msg.wParam=VK_DOWN then begin
ScrollBox1.VertScrollBar.P
end;
end
else begin
Handled:=False;
end;
end;
Took me about 3 hours :(
Good Luck!
ASKER
i'm goana tried it out immeadiatly =)
ASKER
Works like a charm !
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.HorzScrollB
vi:=ScrollBox1.VertScrollB
hp:=ScrollBox1.HorzScrollB
vp:=ScrollBox1.VertScrollB
Handled:=True;
if Msg.wParam=VK_LEFT then begin
ScrollBox1.HorzScrollBar.P
if Msg.wParam=VK_UP then begin
ScrollBox1.VertScrollBar.P
if Msg.wParam=VK_RIGHT then begin
ScrollBox1.HorzScrollBar.P
if Msg.wParam=VK_DOWN then begin
ScrollBox1.VertScrollBar.P
end;
end
else begin
Handled:=False;
end;
end;
Took me about 3 hours :(
Good Luck!