Link to home
Start Free TrialLog in
Avatar of chrislock
chrislock

asked on

Delphi 7 How can I programatically suppress Windows advisory messages?

D7 XP
Hi,
I need to run an application so that only the main form of the application  is always displayed. I wish to temporarily suppress all Windows messages (I hope all exceptions are handled within the app!!) whilst the app. is running. Can I do this programatically?
e.g.
'hiding your inactive icons'
'your hardware is ready;' (USB)
'Windows has altered time to BST'
etc.
etc.
Chris
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

I think if you created another desktop, and specifically did not run explorer, then you would be ok.
all system messages should go to the main desktop.
just make sure you close your created desktop when your app ends or you will be stuck in a limbo desktop :-)

something like ...

var Desk: HDESK;

  Desk := Windows.CreateDesktop(PChar(DesktopName), nil, nil, 0, MAXIMUM_ALLOWED, nil);
...

  Desk:=OpenDesktop(PChar(DesktopName), DF_ALLOWOTHERACCOUNTHOOK, False, MAXIMUM_ALLOWED);
  Sleep(100);
  SwitchDesktop(Desk);
...
  CloseDesktop(Desk);
...
might pay to read up on them first so you know what you're getting into, but not too bad
You can try the 3rd party component MadExcept.
Check http://www.madshi.net/madExceptDescription.htm
This component is very easy to use and can handle any kind of exception, inside your application or from the OS.
Very useful for this cases.
Avatar of chrislock
chrislock

ASKER

big_one01

I dont really understand what MadExcept has to do with the question!!!!!????

Chris
TheRealLok

Your code certainly works in part. How do I return to the original desktop?
I save the existing desktop
create the new desktop.
get a handle by calling opendesktop
switch desktop to desk
delay
then switch back
then ....

If the software closes the desktop (CloseDesktop(Desk);)  then nothing seems to happen and I'm still stuck with the blank desktop and its a hard reboot. Am I missing something?

 olddesk:=windows.getdesktopwindow();
  Desk := Windows.CreateDesktop(PChar('DesktopName'), nil, nil, 0, MAXIMUM_ALLOWED, nil);
  Desk :=OpenDesktop(PChar('DesktopName'), DF_ALLOWOTHERACCOUNTHOOK, False, MAXIMUM_ALLOWED);
  Sleep(100);
  SwitchDesktop(Desk);// activate the new desktop
  sleep(2000);
  SwitchDesktop(oldDesk);// activate the old desktop
  CloseDesktop(Desk);

Chris
I've just found this:

https://www.experts-exchange.com/questions/10688741/createdesktop-switchdesktop.html

I think theres a bit more to it than this!!!

There must be another way to suppress windows messages !

Chris
ASKER CERTIFIED SOLUTION
Avatar of chrislock
chrislock

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you do decide to go the desktop way, and get stuck in a limbo desktop, just do a ctrl-shift-escape, then "new task" explorer.exe
I think the main desktop is called "default" try switching to that,
I can't look it up right now, away from dev pc sorry
Sorry - forgot to say thanks for all the help anyway.