Win32: MoveWindow - Logical or Device?
Quick question: Does anyone know if the Win32 function MoveWindow() works in Device or Logical Coordinates? MSDN's MoveWindow reference is vague. I know I could do a test but I'll ask here first and see what happens.
Thanks in advance.
Not really. Device units are in pixels but Logical units (or coordinates) can be pixels or any other coordinate system. It all depends on the current mappping mode - which defaults to MM_TEXT (units of pixels). Anyway, I've found the answer; They're in Screen Coordinates [makes sense [rolleyes]] which are in device units, which are pixels. lol.
Thanks for the help anyways, ace_lovegrove.
Thanks for the help anyways, ace_lovegrove.
I'd bet that they're in logical coordinates of the parent window, which for a top-level window would be the desktop, which probably always has logical units set to pixels. Did you test it with moving a child window inside it's parent, or did you only test top-level windows?
Quote:Original post by Extrarius
I'd bet that they're in logical coordinates of the parent window, which for a top-level window would be the desktop, which probably always has logical units set to pixels. Did you test it with moving a child window inside it's parent, or did you only test top-level windows?
They're not, I did the latter test. The scaling by 10 pixels for every 1 logical unit didn't have any effect on MoveWindow:
case WM_KEYDOWN : // Get Screen DC hdc = GetDC(NULL); SetMapMode(hdc, MM_ISOTROPIC); SetWindowExtEx(hdc, 1, 1, NULL); SetViewportExtEx(hdc, 10, 10, NULL); if ( wParam >= VK_LEFT && wParam <= VK_DOWN ) { GetWindowRect(hwnd, &rect); ProcessKeys(hwnd, hdc, wParam, &rect); } ReleaseDC(hwnd, hdc); return 0;
code snippet of ProcessKeys function that does the test:
void ProcessKeys(HWND hwnd, HDC hdc, WPARAM wParam, RECT *rect){ POINT pt = {0}; switch ( wParam ) { case VK_LEFT : if ( rect->left != 0 ) { rect->left--; rect->right = (rect->right - rect->left) - 1; rect->bottom = rect->bottom - rect->top; pt.x = rect->left; pt.y = rect->top; MoveWindow(hwnd, pt.x, pt.y, rect->right, rect->bottom, TRUE); } break;
Are you allowed to change things like the logical coordinate system for the desktop? Did you test other functions to see if your attempted changes actually had any affect?
It seems to me that the logical coordinate system is a proprety of the DC and so can't affect MoveWindow (since a DC isn't involved for that). Also, you can have multiple DCs per window presumably with different coordinate systems, so how would MoveWindow know which one to use?
Quote:Original post by Extrarius
Are you allowed to change things like the logical coordinate system for the desktop? Did you test other functions to see if your attempted changes actually had any affect?
Yes. You can change the Screen, Whole Window and Client coordinates. This is done by mapping logical coordinates to device coordinates. These three device coordinate systems are in units pixels. Always. The Screen Coordinates are what you work with on the Desktop. You can map a metric (There's five windows predefined metric mapping modes) or a program defined coordinate system to device coordinates via SetWindowMode and freinds but if the function itself doesn't work in logical units; it's of no use.
The problem with MoveWindow is that it only accepts Screen Coordinates, which are in device units. My Mapping Mode won't have any effect. Problem would be solved it accepted logical coordinates so I could do my own scaling. So long as a functions description says it accepts logical coordinates, that's all one really needs to know to work with a diffrent coordinate system besides device coordinates. But this paticluar functions description doesn't mention its coordinate system at all.
Quote:Original post by ZQJ
It seems to me that the logical coordinate system is a proprety of the DC and so can't affect MoveWindow (since a DC isn't involved for that). Also, you can have multiple DCs per window presumably with different coordinate systems, so how would MoveWindow know which one to use?
Exactly, The Mapping Mode is an attribute of the current Device Context. This is how I now know, apart from my needless test, that MoveWindow only woks in device coordinates because Logical Coordinates can only be mapped and specified with GDI functions. MoveWindow is non-GDI. It's actually part of the WUI (Windows User Interface) system.
Thanks for all the help guys,
xeddiex
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement