Solved

Move from form to form with keystroke

Posted on 1998-11-25
3
159 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 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now