Solved

Move from form to form with keystroke

Posted on 1998-11-25
3
166 Views
Last Modified: 2010-04-04
I want to have a key combination move me to the next form, within the Delphi IDE.  So if I have 10 forms, I want say ALT -> to display the next form and ALT <- to display the previous form. I know I can use the form 'pick list' dialog box and select a form to display - but I want to just cycle through my forms using a single keystroke.
0
Comment
Question by:abulka
[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
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1347890
Here is ane Xample...

First create a global variable that will keep the current form...

var
  CurrForm : Integer;
{...}
OnCreate()
var
  i : integer;
begin
  for i := 0 to System.FormCount - 1 do
    System.Forms[i].Tag := i;
  CurrForm := 1;
end;
{...}
OnKeyDown()
begin
  if (Shift = [ssAlt])and(Key = VK_RIGHT)  then begin
    Inc(CurrForm);
    SetCurrForm(CurrForm);
  end
  else if (Shift = [ssAlt])and(Key = VK_LEFT)  then begin
    Dec(CurrForm);
    SetCurrForm(CurrForm);
  end;
end;

procedure SetCurrForm(Count : Integer);
var
  i : Integer;
begin
  for i := 0 to System.FormCount - 1 do
    if Forms[i].Tag = Count then begin
      SetForegroundWindow(Forms[i].Handle);
      break;
    end;
end;

I have not tested this one, but I hope it works :)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347891
or you could use Forms[i].Show; Instead of SetForegroundWindow(Forms[i].Handle);

Try both and see which one works best for you..

Cheers,
Viktor
0
 

Author Comment

by:abulka
ID: 1347892
Thanks.  Looks good.  I actually wanted to be able to do this during DESIGN mode, but the answer is useful to me in runtime also.  Thanks.
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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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