visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
294 experts, 1172 registered users, 1625 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


The DDRK link is back online.
We got a one week service interruption, sorry.
(23-30/01/2010)

Languages :: Delphi :: Disabling Alt+Tab


By: dax991 Finland  Date: 18/12/2005 14:32:40  English  Points: 20 Status: Answered
Quality : Poor
How I can disable Alt + Tab combination (this brings up the nice box that shows you the open or minimized windows) in Delphi.
By: VGR Date: 18/12/2005 17:07:37 English  Type : Answer
Hello ;-)

I first thought "it can't be done unless you use a global system hook, 'cause this is Windows behaviour", but in fact it seems to be easily feasible.

I found the answer at this greatis page


Disable Alt-Tab, Ctrl-Esc keys
Use SystemParametersInfo function with SPI_SCREENSAVERRUNNING parameter.



var MyW: Word = 0; ... procedure TForm1.Button1Click(Sender: TObject); begin SystemParametersInfo(SPI_SCREENSAVERRUNNING,1,@MyW,0); Label1.Caption:='mode - disable'; end; procedure TForm1.Button2Click(Sender: TObject); begin SystemParametersInfo(SPI_SCREENSAVERRUNNING,0,@MyW,0); Label1.Caption:='mode - enable'; end;



So in fact you fool Windows in believing you're a screensaver running, which is in fact a case when Alt-F4 won't work in standard Windows.

Hope this helps 8-)
By: dax991 Date: 18/12/2005 19:39:53 English  Type : Comment
I couldn't get that code to work (I manged to assemble the exe file but after that no results) with WinXp Home SP2 and Delphi 7 Enterprise. But I found a wroking bit of code for disabling Alt+F4 combination.

//Disable Alt+F4 combination procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); if (Key = VK_F4) and (ssAlt in Shift) then Key := 0; end;


I got it somewhere but just now I don't remember where so credits for the original developer of this bit of code.
By: VGR Date: 18/12/2005 19:47:00 English  Type : Comment
nice classical solution to intercept form events. I think this doesn't work in a formless application... (like a console one)

don't forget to accept an answer. If you just got clues and not "the" solution, I think the quality to choose is '++' or '+'

regards and see you soon

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 62.241080 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page