Hello!
I use Windows 98 and BCB.
I develop a password protected application which resides ion systray. I wish when windows shuts down to stop my application without showing password dialog. Here is my code:
...
void __fastcall TMainForm::WndProc( TMessage &Msg)
{
switch ( Msg.Msg )
{
case WM_ENDSESSION:
if ( Msg.WParam )
{
bForceClose = true;
Close();
Msg.Result = 0;
}
break;
case WM_QUERYENDSESSION:
bForceClose = true;
Msg.Result = true;
break;
default: break;
}
inherited::WndProc( Msg);
}
...
void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if ( bForceClose )
{
CanClose = true;
return;
}
...//showing password dialog, etc.
}
....
The result is: my program stops (without password dialog) but windows refuses to shudown. It shuts down at the second attempt when the program is not running. On the other hand if there is an unsaved document (for example in notepad), when windows shuts down the user will be asked to save the document and if he/she clicks
"Cancel" button the shut down process stops. I need my program to run all the
time windows is running.
Where am I wrong?
Sincerely,
Petyo Milotinov
I use Windows 98 and BCB.
I develop a password protected application which resides ion systray. I wish when windows shuts down to stop my application without showing password dialog. Here is my code:
...
void __fastcall TMainForm::WndProc( TMessage &Msg)
{
switch ( Msg.Msg )
{
case WM_ENDSESSION:
if ( Msg.WParam )
{
bForceClose = true;
Close();
Msg.Result = 0;
}
break;
case WM_QUERYENDSESSION:
bForceClose = true;
Msg.Result = true;
break;
default: break;
}
inherited::WndProc( Msg);
}
...
void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if ( bForceClose )
{
CanClose = true;
return;
}
...//showing password dialog, etc.
}
....
The result is: my program stops (without password dialog) but windows refuses to shudown. It shuts down at the second attempt when the program is not running. On the other hand if there is an unsaved document (for example in notepad), when windows shuts down the user will be asked to save the document and if he/she clicks
"Cancel" button the shut down process stops. I need my program to run all the
time windows is running.
Where am I wrong?
Sincerely,
Petyo Milotinov