Re: SetMapMode



On Mar 23, 6:45 am, "Mike Williams" <m...@xxxxxxxxxxxxxxxxx> wrote:
"Steve" <sredm...@xxxxxxxxxx> wrote in message

news:1174605512.159786.7910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I need to find out the current mapping mode being
used by a window given only that windows hWnd.

As Michael C has already said, you can use the GetMapMode API. You can't use
it on the hWnd though, so you'll need to obtain the DC of the window and use
it on that:

z = GetMapMode(GetDC(Me.hwnd))

However, and this is a major point if you're using it on a VB window such as
a Form or PictureBox or any other VB window, which I think you may be doing,
you need to be aware that VB itself always uses a mapping mode of MM_TEXT
(device pixels), so you will get the same result (1) regardless of the VB
ScaleMode of the window, unless your code has temporarily altered the mode
of the window itself using the SetMapMode API (which is something you need
to take great care with if you don't want to badly upset VB and which I
think is unlikely in your case because if you had done so then you would
already know what the mapping mode was).

Mike

So given only the hWnd (which ofcoarse I know means I can also get the
hDc) how can I tell what the current ScaleMode setting of a VB window
is?

Thanks,
Steve

.



Relevant Pages

  • Re: How add buton onto title bar of any external active window?
    ... I want to add buttons ontoany active window. ... int sm_CXSIZE; ... static int WindowsFeaturesWidth(HWND hwnd, DWORD style) ... LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM ...
    (microsoft.public.win32.programmer.gdi)
  • Re: MFC and Worker Thread issue
    ... situations such as the thread has terminated before the window was created but has no way ... CWnd* which is the message sink and it is created before the thread (with its HWND value) ... which does never see PostMessage or HWND. ... Callbacks add their own problems; I try to avoid them if at all possible. ...
    (microsoft.public.vc.mfc)
  • Re: Are VBA userforms always child of Windows desktop?
    ... I only need this Hwnd of the parent, ... GetAncestor API (with GA_PARENT) to get Parent. ... I suppose which window you need will depend on the overall objective. ... Private Declare Function GetDesktopWindow Lib "user32" As Long ...
    (microsoft.public.excel.programming)
  • Re: Why doesnt this recursive function return the right value?
    ... sClassName Like ClassName & "*" Then FindWindowHwndLike_B = hwnd lHolder = hwnd ... Couldn't find anything for the ClassName comparison. ... Dim s1 As String, s2 As String ... 'finds the first window where the class name start with ClassName ...
    (microsoft.public.excel.programming)
  • Re: Creating new appointment & setting its properties
    ... The window and process subclassing I've seen with WordMail is horrendous, it's miles of code just to get a true hWnd for a WordMail window usually. ... Private Declare Function GetForegroundWindow Lib "User32.dll" As Long ... Private Declare Function FindWindowEx Lib "User32.dll" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long ...
    (microsoft.public.outlook.program_vba)