Re: Window's caption bar size problem



Thanks Mike, that worked a treat.

I needed to use ClientToScreen to get the top and left position and then
GetClientRect to get the window size because top left were always zero, but
using the infomation from them both it works fine.



"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:%237h$mu1lFHA.3256@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Mark Fenwick" <mark-at-redfox-dot-co-dot-uk> wrote in message
> news:%23ItC9S1lFHA.3316@xxxxxxxxxxxxxxxxxxxxxxx
>> Is there a way to determine the absolute position of a control on the
>> screen? Rather than just adding its position on the form to the form's
>> position, which is what I have done before which is unreliable, as it can
>> vary due to font size and desktop theme settings.
>>
>> Is there a way of either:
>>
>> 1) Determining the correct height of the window's caption bar.
>>
>> or
>>
>> 2) Obtaining the controls position reletive to the screen rather htan the
>> form.
>
>
> #2 would be the easiest way, I think. There should be a number of
> Win32API functions you could use. You could use the ClientToScreen API
> function to convert the control's Left, Top, Width, and Height (you'd have
> to convert them to pixels first unless they are already expressed in
> pixels) to coordinates that are relative to the screen. There's also the
> GetWindowRect API function. Either of these would only work if the control
> has an hWnd. IOW, Label and Image controls (for example) are a no-go.
>
> If you went with #1, you could use the SystemParametersInfo API function.
> You would have to take into account menu bars, toolbars, borders, etc.
> IOW, anything part of the non-client area of the window. For
> SystemParametersInfo, specify SPI_GETNONCLIENTMETRICS to get these
> (although I don't think this provides info on toolbars so that could still
> be an issue).
>
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>


.



Relevant Pages

  • Re: CFrameWnd client area rect
    ... There are simple ways to add toolbars and status bars to a dialog-based app; ... I'm displaying it now is by place the window in a formview with the ... "Insert ActiveX control" menu, and then sizing it to the size of the ... Is it possible to know the client area size of a CFrameWnd? ...
    (microsoft.public.vc.mfc)
  • Re: Windows caption bar size problem
    ... You could use the ClientToScreen API function to ... Either of these would only work if the control has an hWnd. ... you could use the SystemParametersInfo API function. ... You would have to take into account menu bars, toolbars, borders, etc. IOW, ...
    (microsoft.public.vb.winapi)
  • Re: Window.close and Explorer 7 problem!
    ... It allows a web author to control what toolbars/etc are on the window instead of it being the users choice. ... In IE you can close a window by pressing Alt+F4, the x button on the title bar, clicking the icon on the title bar and selecting close. ... window.open without any toolbars, close the original window. ...
    (comp.lang.javascript)
  • Re: Control Name
    ... > Is there any API function that will return the name of a control on a ... > a specific control, I have to perform extensive semantics like finding the ... > change each time the window is opened, ... Rick - MVP ...
    (microsoft.public.vb.winapi)
  • Re: Windowless ActiveX Control
    ... carefully, there is no window i.e. m_hwnd == NULL, it is ... windowless control, then how can you use Win32 API function ... "EnumChildWindows" API function and select ...
    (microsoft.public.vc.mfc)