I'm in the process of making use of these to do multiple things. I started out looking at some old C++ code on Microsoft's website for a neat utility that gets the handle of a listview in another window, allocates a structure in that process' memory, and uses it to transfer the data to the clipboard...I had to modify it for more memory in the clipboard and made it extract two columns to a csv delimited text....but I knew it could be even better in PB of course.
I had to modify how it was getting the handles a lot since I soon found out that the way it was using lParam of the mousemove message didn't work since when the mouse went above or to the left of the window they suddenly jumped up in the 65535 range...I had got them to go correct with mod 65536, then said the heck with it and just used GetCursorPos. I even got it to where it draws a red rectangle around the control with the mouse over it like WinSpector does. I'm running into some other issues now though with getting it to "see" all controls.
Most example code I've found seems to assume WindowFromPoint only gets the Top Level Window/Frame/Form and is incorrect. When I call it I get pretty much any control or Window. WindowFromPoint also doesn't show hidden/disable controls, etc...so ChildWindowFromPoint is needed. Most example code also make another mistake in using this since they use the hWnd from the previous WindowFromPoint call that is often actually a control and not a Window...then call ScreenToClient it then maps the Point structure passed in to the Client of the child control and not the Window that is needed for the call. I can run through a loop with GetParent until I have the parent Window, but then I lose the ability to select Header Controls in a Listview, and child forms/dialogs then can't have any controls selected, etc. I can just getParent once which usually gets me the same results as just using WindowFromPoint by itself.
On top of all those issues, I also have problems where Windows with Frame Controls cause certain controls not to be seen by any of these ways of calling. I'm aware of other languages like Delphi and such hiding the controls pretty well or seeming to dynamically draw them, etc...but these are programs I made with PB and know they aren't child controls of the frame or anything special, so they should show??? I can get every other control, child of a control, window, hidden/disabled control, etc...but these still won't show. Is it a WinXP thing or are these just messed up? Anyone got any code they know works and shows all controls when frames are used?
(What is really weird is I have two frames in one window...both have Labels, Combos, a checkbox, and text boxes...in one frame I can get to all labels, in the other I can't...but can see the Checkbox while the combos and edit boxes neither one will work. Plus WinSpector will see all of them and highlight them.)
I had to modify how it was getting the handles a lot since I soon found out that the way it was using lParam of the mousemove message didn't work since when the mouse went above or to the left of the window they suddenly jumped up in the 65535 range...I had got them to go correct with mod 65536, then said the heck with it and just used GetCursorPos. I even got it to where it draws a red rectangle around the control with the mouse over it like WinSpector does. I'm running into some other issues now though with getting it to "see" all controls.
Most example code I've found seems to assume WindowFromPoint only gets the Top Level Window/Frame/Form and is incorrect. When I call it I get pretty much any control or Window. WindowFromPoint also doesn't show hidden/disable controls, etc...so ChildWindowFromPoint is needed. Most example code also make another mistake in using this since they use the hWnd from the previous WindowFromPoint call that is often actually a control and not a Window...then call ScreenToClient it then maps the Point structure passed in to the Client of the child control and not the Window that is needed for the call. I can run through a loop with GetParent until I have the parent Window, but then I lose the ability to select Header Controls in a Listview, and child forms/dialogs then can't have any controls selected, etc. I can just getParent once which usually gets me the same results as just using WindowFromPoint by itself.
On top of all those issues, I also have problems where Windows with Frame Controls cause certain controls not to be seen by any of these ways of calling. I'm aware of other languages like Delphi and such hiding the controls pretty well or seeming to dynamically draw them, etc...but these are programs I made with PB and know they aren't child controls of the frame or anything special, so they should show??? I can get every other control, child of a control, window, hidden/disabled control, etc...but these still won't show. Is it a WinXP thing or are these just messed up? Anyone got any code they know works and shows all controls when frames are used?
(What is really weird is I have two frames in one window...both have Labels, Combos, a checkbox, and text boxes...in one frame I can get to all labels, in the other I can't...but can see the Checkbox while the combos and edit boxes neither one will work. Plus WinSpector will see all of them and highlight them.)
Comment