Windows Develop Bookmark and Share   
 index > Windows Forms General > getting window client area coordinates in large windows
 

getting window client area coordinates in large windows

Hi!

I need to acquire the client-area mouse coordinates in a window of a third party application. I have used GetCursorPos and ScreenToClient to get the mouse coordinates when the scrollbars are positioned at the top-left position. Unfortuanately the client area of the window who’s coordinates I need are usually much larger then the window itself. If you use ScreenToClient in the window when the scrollbars are positioned a few 1000 pixels to the right and down from the upper left corner you will get the position of the mouse pointer relative to the upper left corner of the visible part of the client area.

Is there a way to get the difference between the upper left corner of the windows client area and the upper left corner of the visible part of the client area?

Thanks in advance,
Martin

Martin559  Friday, November 17, 2006 3:53 PM
No, this is an implementation detail for the 3rd party app. It also would get mouse coordinates relative to the upper left corner of the client rectangle. It would know enough about the scroll state to be able to translate that into a logical client position. If it would have to. The best you can do is try to read the scrollbar positions and translate that an upper-left corner offset. That would only work if the scrolled client area is always the same size...
nobugz  Friday, November 17, 2006 9:13 PM
What do you mean by client area? If you're looking for the client area of your Form for the size of another process's window that doesn't make sense. Can you explain what you want to do (not what you're trying to do) you're dealing, essentially, with three different coordinate systems.
Peter Ritchie  Friday, November 17, 2006 4:57 PM
No, this is an implementation detail for the 3rd party app. It also would get mouse coordinates relative to the upper left corner of the client rectangle. It would know enough about the scroll state to be able to translate that into a logical client position. If it would have to. The best you can do is try to read the scrollbar positions and translate that an upper-left corner offset. That would only work if the scrolled client area is always the same size...
nobugz  Friday, November 17, 2006 9:13 PM

What I want to do is a bit complicated, I want to drag-and-drop something on an application that doesn’t have drag-and-drop support implemented. This means I have to do it all on my side in the CompleteDrag-event, this isn’t a hard as it sounds since the target apps has an OLE Automation server and a feature rich scripting language through which you can complete the drop. I have been able to drop the object in the correct window but as I wrote in my last message the object is always positioned in the client apps window with the assumption that the scrollbars always are positioned at the upper left corner.

Martin559  Monday, November 20, 2006 9:09 AM

Unfortunately it isn’t, the size of the client area can grow and shrink dynamically. Isn’t information about the size and what part of the client area is visible available if you look below the Windows Forms layer into gdi?

Martin559  Monday, November 20, 2006 9:32 AM

You can use google to search for other answers

Custom Search

More Threads

• make a form fullscreen?
• Format space and row
• SendInput Win32 API is making me feel retarded!
• help how to display
• message box dose not display.
• Accessing data from another form
• infinite recursion iniatializing user control
• Deactivate form
• How to search Text in ListView's Column with Less Complexity Algorithm?
• Editing ToolStrip screws up auto generated code