Re: Window's caption bar size problem
- From: "Mark Fenwick" <mark-at-redfox-dot-co-dot-uk>
- Date: Tue, 2 Aug 2005 13:52:01 +0100
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
>
>
.
- References:
- Window's caption bar size problem
- From: Mark Fenwick
- Re: Window's caption bar size problem
- From: MikeD
- Window's caption bar size problem
- Prev by Date: Re: Window's caption bar size problem
- Next by Date: Re: API for: CopyMemory, MoveMemory, ZeroMemory, FillMemory in API Viewer are incorrect!
- Previous by thread: Re: Window's caption bar size problem
- Next by thread: Re: API for: CopyMemory, MoveMemory, ZeroMemory, FillMemory in API Viewer are incorrect!
- Index(es):
Relevant Pages
|