ok, i have seen all kinds of code on how 2 get progs hwnds. but.. what can u do with it?? i mean what all can u do with knowing the hwnd number of a prog?
any help is great.. thanx!
Printable View
ok, i have seen all kinds of code on how 2 get progs hwnds. but.. what can u do with it?? i mean what all can u do with knowing the hwnd number of a prog?
any help is great.. thanx!
Usually you're not even intrested in the hWnd, but you can for instance make a program invisible, close it, move it, to name a few things.
Many API functions are declared to get your hwnd for some odd reason, I don't know why. Ie ShellExecute
Those API's want the hWnd as kind of a parentwindow for message's that might be displayed. Usually not intresting... :-)
It is important to know if you are trying to create an application that is dependent on another application. Example: If this application is open then do this otherwise do this. You can determine if the ap[plication is open by searching for the application by the handle(hwnd). You may never use it but when you do, it will be very valuable.
I've developed a program that deals with nothing but hwnd's, I'll let you look at it if you really want, but it's not done yet. It's beta, because I haven't added everything I want. Email me if you want to see it.
Or, simply, because some functionality in VB was never meant to be done. For example there's no VB way to get how many lines in the textbox, or get a particular line from the textbox. And that's where API come in. But you need a window handle (hWnd) of the control you want to get the text from. hWnd is a representation of window (or control which is also a window) for the Windows OS. Every object on the screen potentially has an hWnd (well, almost every object). Check out MSDN library to get the idea on how hWnd works and how to work with it.
P.S If you really think about VB's functionality, then you'll realize that it is just a basic wrapper around API calls. For example, when you're getting text from the TextBox:
strMyVariable = Text1.Text
Simply what it does, just calls SendMessage API with the WM_GETTEXT message.
Or if you get the Count from the ComboBox:
intCount = Combo1.ListCount
It just calls SendMessage API again:
intCount = SendMessage(Combo1.hWnd, WM_GETCOUNT, 0, 0)
I hope this will clear a lot of things for you.