Keeping track of control width
-
Hi, I have a control from which I regular need the current width, so I created a member variable. I did override OnSize() to get the new width. Where do I get the initial width?
-
Hi, I have a control from which I regular need the current width, so I created a member variable. I did override OnSize() to get the new width. Where do I get the initial width?
Try reading here: CWnd::OnGetMinMaxInfo**
--BlackSmith--
**/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
-
Try reading here: CWnd::OnGetMinMaxInfo**
--BlackSmith--
**/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
sorry, I dont get the relation to my question about current control size, which is a client window (a listbox) of a dialog. Meanwhile I tried with
OnSize()
, but OnSize() gets called to late. I need to catch the width somewhere earlier, right after the control is created.... -
sorry, I dont get the relation to my question about current control size, which is a client window (a listbox) of a dialog. Meanwhile I tried with
OnSize()
, but OnSize() gets called to late. I need to catch the width somewhere earlier, right after the control is created.... -
Well, I remember from my poor Win32 experience that you get a WM_SIZE after the control is created... so overriding OnSize() might be enough? Propably someone can confirm this? Or is there any other message handler to override and call GetClientRect()?
Initially you will recieve a WM_SIZE before the control is created, and one after the control is created. You could do the following:
static bool first = true ;
if (GetDlgItem(IDC_OF_CONTROL) != NULL && first)
{
// this code will only be executed once.
CRect size ;
GetDlgItem(IDC_OF_CONTROL)->GetWindowRect(&size) ;
first = false ;
// do something with the initial size of the control
}Roger Allen Sonork 100.10016 I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.