Control collections and design...
Reza Razavipour -- biles.com!reza_r@jabberwock.biles.com Friday, April 19, 1996 VC4.1 on NT3.5.1 I have three CPropertyPage derived classes. Each of these Pages have, somewhere in them, three static controls and three dropdown lists. The drop down lists, are identical with data and methods and behavior. In order not to duplicate the code that deals with these dropdown lists, I was thinking about a way to do the code once and have all three CPropertyPages use IT. The non GUI aspects of the above problem, I have no problem with, but the GUI aspects of it, I am not sure how to get around. Ideally, I like to layout the common controls, i.e. the three static controls and the three dropdown lists, ideally in the resource editor, create a class from it, and just "drop" this "composite control", onto any CView or CDialog derived class. Any ideas or hints are highly appreciated. Reza
Niels Ull Jacobsen -- nuj@kruger.dk Thursday, April 25, 1996 At 14:29 19-04-96 -0500, you wrote: >VC4.1 on NT3.5.1 > >I have three CPropertyPage derived classes. Each of these Pages have, somewhere=20 >in them, three static controls and three dropdown lists. The drop down l= ists,=20 >are identical with data and methods and behavior. In order not to duplic= ate the=20 >code that deals with these dropdown lists, I was thinking about a way to= do the=20 >code once and have all three CPropertyPages use IT.=20 > >The non GUI aspects of the above problem, I have no problem with, but th= e GUI=20 >aspects of it, I am not sure how to get around. Ideally, I like to layou= t the=20 >common controls, i.e. the three static controls and the three dropdown l= ists,=20 >ideally in the resource editor, create a class from it, and just "drop" = this=20 >"composite control", onto any CView or CDialog derived class.=20 Unless you make your "Control collection" an OLE control, I don't think y= ou can add it=20 with the resource editor.=20 But you can make it a dialog, which you embed on your pages. Something like this: class CMyControls : public CDialog { ... } class CPage1 : public CPropertyPage { ... CMyControls m_MyControls; ... } CPage1::OnInitialUpdate() { VERIFY(m_MyControls.Create(IDD_MYCONTROLS,this)); CRect Rect; GetDlgItem(IDC_PLACEHOLDER_FRAME)->GetWindowRect(Rect); // invisible place holder ScreenToClient(Rect); #ifdef _DEBUG // Check that it fits in the place holder CRect controlrect; VERIFY(m_MyControls.GetClientRect(controlrect)); ASSERT(controlrect.Width() <=3D Rect.Width() && controlrect.Heigh= t() <=3D rect.Height()); #endif CWnd* pPrev =3D GetDlgItem(IDC_SOMECONTROL); // Right before the contr= ol collection in tab order =20 =20 VERIFY(m_ControlCollection.SetWindowPos(pPrev,=20 Rect.left, Rect.top, 0, 0, SWP_NOSIZE |SWP_NOACTIVATE)); }; For this to work, your IDD_CONTROL_COLLECTION should be a WS_CHILD, have = no border and have the WS_EX_CONTROL style and (maybe) WS_CLIPSIBLINGS. > >Any ideas or hints are highly appreciated. > >Reza > > > Niels Ull Jacobsen, Kr=FCger A/S (nuj@kruger.dk) Everything stated herein is THE OFFICIAL POLICY of the entire Kruger grou= p and should be taken as legally binding in every respect. Pigs will grow wings and fly.
| Вернуться в корень Архива |