Board index » delphi » Questions about "Handle"

Questions about "Handle"

Hello,
Many API functions require the handle of the window or the handle of the
application.
Can anyone tell me what's a handle?
How can I get the handle of an application(eg.Notepad) or a window with known
caption(eg.A window which caption is "Sample Window")?
If you can, pls provide me detail examples, since I'm a beginner only.

Thank in advance!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

 

Re:Questions about "Handle"


A handle is like a pointer (maybe it +ACo-is+ACo- a pointer). It just tells
Windows where, in memory, an application resides. Here is a little
loop that checks all running windows:

Var DesktopWnd : hWnd+ADs-
    i: longint+ADs-
    aBuffer: array+AFs-1..100+AF0- of char+ADs-
    aString: String+ADs-

          DesktopWnd :+AD0- Application.Handle+ADs-
          while (DesktopWnd +ADwAPg- 0) do
          begin
               DesktopWnd :+AD0- GetNextWindow(DesktopWnd,GW+AF8-HWNDNEXT)+ADs-
               if DesktopWnd +AD0- 0 then
                  break+ADs-
               GetWindowText(DesktopWnd,+AEA-aBuffer,99)+ADs-
               aString :+AD0- aBuffer+ADs-
               if aString +AD0- 'Some Window Caption' then
                   SetForegroundWindow(DesktopWnd)+ADs-
          end+ADs-

Quote
yeeting+AEA-iname.com wrote in message

+ADw-7ak00t+ACQ-nqs+ACQ-1+AEA-nnrp1.dejanews.com+AD4-...
+AD4-Hello,
+AD4-Many API functions require the handle of the window or the handle of
the
+AD4-application.
+AD4-Can anyone tell me what's a handle?
+AD4-How can I get the handle of an application(eg.Notepad) or a window
with known
+AD4-caption(eg.A window which caption is +ACI-Sample Window+ACI-)?
+AD4-If you can, pls provide me detail examples, since I'm a beginner
only.
+AD4-
+AD4-Thank in advance+ACE-
+AD4-
+AD4------------+AD0APQ- Posted via Deja News, The Discussion Network
+AD0APQ-----------
+AD4-http://www.dejanews.com/       Search, Read, Discuss, or Start Your
Own

Other Threads