Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Move from form to form with keystroke

Posted on 1998-11-25
3
Medium Priority
?
170 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
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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 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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

963 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