Solved

Move from form to form with keystroke

Posted on 1998-11-25
3
164 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

735 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