Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hooks

Status
Not open for further replies.

gforrest

Programmer
Apr 26, 2000
39
CA
Hi,<br><br>&nbsp;&nbsp;&nbsp;Anyone have sample code, documentation or know of a good book that<br>describes how to program hooks from Delphi into other applications?<br><br>&nbsp;&nbsp;&nbsp;Thanks
 
Hi!<br><br>You send many questions on Win API to this forum.<br>Try to look at win32.hlp which must be in Delphi installation (I have seen it in Delphi1,2,3,4,5 ), You find many interesting and usefull API functions there.As for this question see&nbsp;&nbsp;SetWindowsHookEx in that help file.<br><br>Good luck.<br>Vladimir.
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Yes you're absolutely right.&nbsp;&nbsp;It seems that for even the most simple tasks I must use Windows API functions.&nbsp;&nbsp;For example, I'm running an application from Delphi which I&nbsp;&nbsp;Minimize on start up.&nbsp;&nbsp;I don't want to give my user the ability to Maximize the application however, I do want an icon left on the task bar at the bottom of the screen (task tray??) and I do want to see the app. in the task manager listing.&nbsp;&nbsp;Apparently, one of the few ways (although certainly not the simplest) is to use hooks, hence my initial quiry.&nbsp;&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If you happen to know of a more simplistic approach to this problem I would be grateful for your input.<br><br>Thanks.<br><br>Glenn.
 
Project1.exe contain only Form1( this is empty project), this code hides window but on task bar still have program ico:<br><br>WinExec('Project1.exe',SW_SHOWNORMAL);<br>ShowWindow(FindWindow(nil,'Form1'),SW_HIDE);<br><br>another way is to hide program from task bar( still have in task list)<br><br>WinExec('Project1.exe',SW_SHOWNORMAL);<br>ShowWindow(FindWindow(nil,'Project1'),SW_HIDE);<br><br>
 
This would work if I was trying to hide a Delphi application however, I'm attempting to hide an external application which I start from within my Delphi program.&nbsp;&nbsp;The program I start runs in a DOS Window.
 
No problem, we can move window:<br>I use fdisk.exe which run in dos window:<br><br>Wnd : HWND;<br>....................<br>WinExec('fdisk.exe',SW_SHOWNORMAL);<br>repeat<br>Wnd:=FindWindow('tty','fdisk');<br>Application.ProcessMessages;<br>until Wnd&lt;&gt;0;<br>SetWindowPos(Wnd,0,2000,2000,0,0,SWP_NOOWNERZORDER or SWP_NOSIZE);<br>..............................<br><br>Vladimir.<br><br><br>
 
Code above must contain string( at the end ):<br>EnableWindow(Wnd,false);<br>to disable keyboard and mouse input.<br><br>Or we can use next code:<br><br>WinExec('fdisk.exe',SW_SHOWMINNOACTIVE);<br>repeat<br>&nbsp;&nbsp;&nbsp;Wnd:=FindWindow('tty','fdisk');<br>&nbsp;&nbsp;&nbsp;Application.ProcessMessages;<br>until Wnd&lt;&gt;0;<br>EnableWindow(Wnd,false);<br>
 
Thanks.&nbsp;&nbsp;I'll give this a shot however, I was under the impression that WinExec was obsolete and that in 32 bit Windows (95,98,NT) you should use ShellExecute or CreateProcess??<br><br>
 
Yes! but WinExec calls CreateProcess and more simple in many cases.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top