tags:

views:

70

answers:

1

How do I get the window (wxDC or window id) on a certain point (like get window at point(10,20)) using wxWidgets or XCB? ~ Thanks

+1  A: 

Check these functions:

::wxFindWindowAtPoint    
::wxFindWindowAtPointer
Wacek
Those methods do not seem to work for windows besides the window the code is hosted on...like i have:[CODE]void MyFrame::OnGetWindowClick(wxCommandEvent wxPoint pt = wxGetMousePosition(); wxWindow* winpt = wxFindWindowAtPointer(pt); std::cout << "px=" << pt.x << std::endl; std::cout << "window=" << winpt->GetId() << std::endl;}[/CODE]And I get the window ID of the current hello world window (which gives me 2006) and then the label is returned blank. For all other windows it says Segmentation Failed, because the windows returned are NULL...
mail_321
You didn't say in your question that you want to get id or device context from _any_ window. WxWidgets application holds info only about objects created by itself.I don't think it can be done by wxWidgets and its documented functions and methods. Try to use native API functions. MS Windows API has a function called WindowFromPoint, which does what you want, but it returns HWND of the target window. You must use this handle to obtain other information about target window.
Wacek
What is the native API function in Linux?
mail_321
Sorry, I have no experience in Linux GUI programming. Maybe you should check the wxWidgets source code, especially the Linux version of wxWindowFromPoint function.
Wacek