Is it possible to get the position of a ltk (Common Lisp basic GUI library) window (one of its corners), in pixels from the top left screen corner?
I'm trying to use mouse movement to control an applet I'm making (details here), but I can only find the mouse's position relative to the window, and I can only set it relative to the screen itself. I want to hide the cursor and return it to a fixed point after every move, noting how it has moved. I need to know the window position to correct for the different measurements.
The manual gives several options for manipulating the toplevel, such as moving the window around or finding its position and dimensions. The particular expression needed here is (geometry *tk*), which returns a list of the window's x and y position and size.
Related
The question can be reworded as "How to get a cursor click point?", if "click point" is the correct name.
After obtained a bitmap from a cursor global resource, by using a combination of LoadCursorW and a combination of GDI32 functions. And finally having a bitmap that can be draw on top of another, I realized that I don't know how to "shift" the cursor depending on where the click point is for a given cursor.
For example: while the most typical ARROW cursor bitmap has its click point at [0, 0] (left, top). The HAND cursor, the one that appears over links, is a bit translated to the left.
For the most typical cursors, because they are simple 2D concepts, you can solve it by iterating on all the bitmap pixels, and take the top most non transparent pixel as the clicking point, or if there are more than a single pixel sharing the same Y coordinate, then return a value with an X that is at the center of all those pixels.
And I'm hoping there aren't any cursor themes with cursors pointing downwards.
The CURSORINFO structure doesn't contain this information. It only gives you the current mouse x and y coordinates. And they are the same coordinates that you get by other means like GetCursorPos.
The Windows API already provides this information in the ICONINFO structure, that can be filled by calling GetIconInfo.
The function accepts handles to icon or cursors.
The xHotspot and yHotspot fields contain the cursor's "hotspot". By aligning these coordinates with the current/desired cursor position you can draw the cursor in the correct place.
I want to get the top most window that is at position x and y. In Winapi I do this with WindowFromPoint seen here: https://msdn.microsoft.com/en-us/library/ms633558%28v=vs.85%29.aspx
Is there any equivalent in x11? I have covered the entire screen with a window and i want to know all the windows that are at the point in z order.
XQueryTree gives list of window in the stacking order. You would need to query dimensions for every window in the list and stop when your point is within rectangle
In SSRS, it is a good practice to put your report elements inside rectangles.
This makes it possible to move several items at once by moving the rectangle around. When moving the rectangle around with a mouse, this works like a charm: the Tablix position inside the Rectangle remains the same, so the Rectangle moves with all contents in-place to another position:
However, when you manually (via the Top / Left properties in the properties pane) alter the position of these rectangles in Design Mode, the rectangle moves, but the contents remain on the same place. So whenever I do the same movement via the properties pane (which is more precise IMHO), the contents are not moved along with the rectangle, and oftentimes even become invisible:
Whenever you alter the position of the Rectangle directly inside the XML of the report (in 'Code Mode'), the contents are moved along correctly - but this is a rather time-consuming way.
Is there a way to make SSRS move the contents of rectangles along in Design Mode, even when the position of the rectangles is altered via the properties pane?
Is there a way (API) of getting the size (vertical and horizontal) in pixels of the resize corners?
I am referring to the area at each of the corners of a window where you can resize the window in both directions (Left-to-Right and Top-to-Bottom) at the same time using your mouse. You will know you are there with your mouse cursor when you hover over the corners of the window and the mouse cursor is a Diagonal Resizing cursor.
Thank you
Edit:
An example: Hover your mouse over the right edge of a sizable window. Start in the middle (vertically) of the window and move the mouse up along the edge until the horizontal sizing cursor changes to a diagonal sizing cursor. How do I determine by asking the OS how far that position when the cursor changes, is from the top of the window.
I would suggest to use the size of the scrollbars. Call GetSystemMetrics with SM_CYHSCROLL and SM_CXVSCROLL. May be also SM_CYSIZEFRAME and SM_CXSIZEFRAME sizes can be combined.
But I think a better value is to use the height of the status bar. However even Microsoft Windows seems to use some fixed value as can seen on the screenshot.
Comparing the results of GetClientRect and GetWindowRect will tell you how wide the non-client (border) area is along each edge of the window.
If you're concerned that it might not all be active for sizing (true especially along the top), or you want to distinguish the diagonal sizing areas from edge sizing areas, you can take the coordinates discovered in step 1 and pass them to SendMessage(WM_NCHITTEST) See its documentation for the various return codes. There's no problem sending this message repeatedly -- it's designed to be called for each mouse move event and therefore is very fast.
I would like to determine if a rect inside a window is completly visible.
I have found RectVisible, but that function determines if any part of the rect is visible, I want to know if the entire rect is visible.
Is there any function for this?
First get the system clipping region (the visible region of a window) into a region by using GetRandomRgn. Read more about the 'system region' here. Then, offset that region since it is in screen coordinates (the article I linked has an example). After that, create a region from your rectangle with CreateRectRgn and combine the parts of your 'rectangle region' with those that are not part of the 'system region': that is calling CombineRgn passing the rectangle region as the first region, and the system region as the second region, and RGN_DIFF as the fnCombineMode. If the result is NULLREGION then your rectangle is fully visible - it is not fully or partially covered by any window (top level or not), or it is not fully or partially off-screen.
All in all, there's a probability that you're approaching your problem the wrong way around. If you've told what you've been trying to achieve someone could probably suggest a simpler approach.
Use PtVisible on each corner of the rectangle.
The PtVisible function determines
whether the specified point is within
the clipping region of a device
context.
Can you do a simple comparison using the coordinates of the window and the rectangle.
Check the rectangle's left ordinate is to the right of the Window's left border; the right ordinate is to the left of the Window's right border; and similar for top and bottom?
The only wrinkle might be if you are using both logical and physical coordinates, in which case you will need to perform a transformation.
All the functions that dealt with clip rectangles and point visibility broke with Windows Vista's new desktop composition feature. The functions will work fine on Windows XP and earlier, and on Windows 7 with Aero/Desktop Composition turned off, but otherwise, they will always claim that the entire window is visible.