dmcqueen
asked on
Modal Application ?
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.
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.
Try this:
procedure TForm1.Deactivated(Sender: TObject);
begin
SetForegroundWindow(Handle );
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnDeactivate := Deactivated;
end;
procedure TForm1.Deactivated(Sender:
begin
SetForegroundWindow(Handle
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnDeactivate := Deactivated;
end;
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.H andle);
end;
end.
meikl
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.H
end;
end.
meikl
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}
you could use form1 as a splash screen form and on a timer call
form1.hide;{hide splash form}
form2.showmodal; {show modal app}
Listening
I think you should handle the message WM_ACTIVATE or WM_ACTIVATEAPP. Don't know, perhaps Epsylon's suggestion does that already.
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_T opMost,Lef t,Top,Widt h,Height,s wp_NoRedra w+swp_Show Window);
3 - Make the desired form and put over the last ( stay on top too )
4 - Avoid ALT-TAB, etc with
SystemParametersInfo(SPI_S CREENSAVER RUNNING, LongWord(True), @LongNum, 0);
I accept opinions.
T++, Radler.
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_T
3 - Make the desired form and put over the last ( stay on top too )
4 - Avoid ALT-TAB, etc with
SystemParametersInfo(SPI_S
I accept opinions.
T++, Radler.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
clever, eps ;-)
I have more than 10 questions open, waiting for a response. I'm not going to wait forever.....
As an aside Epsylon, how do you tell how many open Q's you have (apart from counting them manually...)?
Cheers,
Raymond.
Cheers,
Raymond.
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?
Btw: did you receive your gift? I have not seen anything yet. And you, Meikl?
hi eps,
have ordered the gift some weeks ago,
but it didn't received me until yet :-(
meikl
have ordered the gift some weeks ago,
but it didn't received me until yet :-(
meikl
no gift yet for me neither :-( boo hoo
the march e.e letter says they will start shipping this month ..
the march e.e letter says they will start shipping this month ..
I haven't received mine either yet.
Cheers,
Raymond.
Cheers,
Raymond.
set mainform.formstyle to fsStayOnTop?
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