Solved

Move from form to form with keystroke

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
Controlled Assessment GCSE - desperate help needed 4 119
CheckListBox usage 3 96
Wincontrol not (correctly) drawn 15 54
Tvertscrollbox like a whatsapp layout 5 65
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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