Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 179
When I am typing into a TEdit last word repeats 7 158
delphi parse string to params 3 151
how to update exe applicatio from internet ? 6 91
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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