Solved

Modal Application ?

Posted on 2000-03-10
16
377 Views
Last Modified: 2010-04-04
Is it possible to create a modal application ?

I have a form which accepts input from a keyboard wedge laser scanner, and processes it using keypreview, keydown etc.

The only problem I come across is if someone has clicked off the form, and my application no longer has focus, then I lose scans.

So all I need it to keep my form activated whilst it is expecting scans.  A modal application kinda sounded right, but not sure if it is possible or how.

Thanks.

Dave.
0
Comment
Question by:dmcqueen
[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
  • 4
  • 3
  • 3
  • +5
16 Comments
 
LVL 5

Expert Comment

by:TheNeil
ID: 2604290
Could you try adding a timer and get it to check if your app is active or not? If it ISN'T active when the timer fires then it makes your app active.

i.e.

IF NOT(Active)
THEN
  BringToFront;

An alternative would be to catch when the form becomes deactivated and then just use BringToFront again.

WIndows will probably stop you from modally running your app but I'm not an expert on that so 24000 people will now tell me I'm wrong.

The Neil
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2604316
Try this:

procedure TForm1.Deactivated(Sender: TObject);
begin
  SetForegroundWindow(Handle);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnDeactivate := Deactivated;
end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2604351
maybe also try this


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
  private
    Procedure WMKillFocus(var Msg : TMessage); message WM_KILLFOCUS;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

Procedure TForm1.WMKillFocus(var Msg : TMessage);
begin
  inherited;
  SetForeGroundWindow(self.Handle);
end;

end.

meikl
0
Industry Leaders: 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!

 
LVL 17

Expert Comment

by:inthe
ID: 2605597
Hi
you could use form1 as a splash screen form and on  a timer call

form1.hide;{hide splash form}
form2.showmodal; {show modal app}
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2606354
Listening
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2607254
I think you should handle the message WM_ACTIVATE or WM_ACTIVATEAPP. Don't know, perhaps Epsylon's suggestion does that already.
0
 
LVL 4

Expert Comment

by:Radler
ID: 2620596
A dumb solution;

1 - Make a full screem form, with stay on top
2 - copy the background image, grats to some E-E
use this at onCreate
SetWindowPos(Handle,hwnd_TopMost,Left,Top,Width,Height,swp_NoRedraw+swp_ShowWindow);
3 - Make the desired form and put over the last ( stay on top too )
4 - Avoid ALT-TAB, etc with
SystemParametersInfo(SPI_SCREENSAVERRUNNING, LongWord(True), @LongNum, 0);

I accept opinions.

T++, Radler.
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 100 total points
ID: 2625269
>Sigh<

Try this:

procedure TForm1.Deactivated(Sender: TObject);
begin
  SetForegroundWindow(Handle);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnDeactivate := Deactivated;
end;


0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2625534
clever, eps ;-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2625735
I have more than 10 questions open, waiting for a response. I'm not going to wait forever.....
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2625851
As an aside Epsylon, how do you tell how many open Q's you have (apart from counting them manually...)?
Cheers,

Raymond.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2625996
I have 19 notification emails here from 19 different questions. I have marked them and throw them away when the question's answer is accepted. 4 of them are from this week. Another 3 or 4 I did not answer. I'm there are more question but they slipped between my  fingers because I never got a notification from them. And a few weeks ago I missed a dozen notifications because of a stupid mistake of my provider.

Btw: did you receive your gift? I have not seen anything yet. And you, Meikl?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2626621
hi eps,

have ordered the gift some weeks ago,
but it didn't received me until yet :-(

meikl
0
 
LVL 17

Expert Comment

by:inthe
ID: 2626948
no gift yet for me neither :-( boo hoo
the march e.e letter says they will start shipping this month ..
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2630347
I haven't received mine either yet.

Cheers,

Raymond.
0
 
LVL 1

Expert Comment

by:chengjian
ID: 2648019
set mainform.formstyle to fsStayOnTop?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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