Re: Where should I place the function GetClientRect(...) in ?
Li Hang wrote:
I derive a new control named CTrackPanel from CStaic, and place it in a
dialog. I need to get the width and height of the control as early as
best. Using GetClientRect(...) I could get the width and height( I
think for a CStatic, the client is as big as the CStatic window).
Because I don't change the size of the CTrackPanel in the running, I
just want to invoke the GetClientRect(...) just once and store the
width and height in the member vairiables of CTrackPanel. Where shoud
I place GetClientRect(...) in? First I place it in
CTrackPanel::OnPaint(), it works, but OnPaint() will be invoked many
times. Then I want to place it in CTrackPanel::OnCreate(), but the
running seems not going into it, I check the MSDN and it says that
OnCreate(...) will be called by the framework when using Create() or
CreateEx(), but I need not to invoke CTrackPanel.Create() myself,
because the dialog( the CTrackPanel is placed in it) do it for me. So
where or when should I invoke the GetClientRect(...) in the life cycle
of the CTrackPanel? Which windows message handler is the right one?
Li:
Have you looked at PreSubclassWindow() ?
David Wilkinson