Tabbing bewtween controls on a view (CView that is)
MHENRY.UMI.COM -- MHENRY@umi.com Monday, September 23, 1996 Environment: VC++ 4.0, Win 95 I have a CView-derived class that I place two CListBoxs and a CRichEditView on. I'd like to be able to tab between them. I've tried giving the view window the extended "WS_EX_CONTROLPARENT", which according to the (negligible) documentation allows you to tab between control windows on a view. But it doesn't work, i.e., you hit tab and nothing happens. Has anyone used this extended window style? I can't find decent documentation on it anywhere. I suppose I could create a dialog template and put my controls on that in a CFormView, but I'd rather not mess with another dialog resource if I can avoid it. Besides, This should work (I think). Here's my code... BOOL CMTIView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { // create the window if (!CWnd::CreateEx(WS_EX_CONTROLPARENT, lpszClassName, lpszWindowName, dwStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, pParentWnd->m_hWnd, (HMENU)nID, pContext)) return FALSE; // create CRichEditCtrl VERIFY(m_pRECFile->Create((WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_SUNKEN | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL | ES_READONLY), CRect(1,1,10,10), this, 0)); // create the list boxes VERIFY(m_pListIdentified->CreateEx(WS_EX_CLIENTEDGE,"LISTBOX","", WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | LBS_NOINTEGRALHEIGHT | LBS_STANDARD, 1,1,10,10,GetSafeHwnd(),(HMENU)IDC_LIST_TERM_IDENTIFY)); VERIFY(m_ListTerms.CreateEx(WS_EX_CLIENTEDGE,"LISTBOX","", WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_STANDARD, 1,1,10,10,GetSafeHwnd(),(HMENU)IDC_LIST_TERMS)); return TRUE; } I also tried setting the controls with the WS_TABSTOP style but to no avail. --matt /~~~~~~~~~~~~~~~~~~~~~~~~~~~ Matthew Henry -- UMI mhenry@umi.com (Work) mhenry1384@aol.com (Home) ~~~~~~~~~~~~~~~~~~~~~~~~~~/
ganeshs@nationwide.com Tuesday, September 24, 1996 [Mini-digest: 3 responses] Environment: VC++ 4.0, Win 95 > > I have a CView-derived class that I place two CListBoxs and a CRichEditView > on. I'd like to be able to tab between them. I've tried giving the view > window the extended "WS_EX_CONTROLPARENT", which according to the (negligible) > documentation allows you to tab between control windows on a view. But it > doesn't work, i.e., you hit tab and nothing happens. > > Has anyone used this extended window style? I can't find decent documentation > on it anywhere. I suppose I could create a dialog template and put my > controls on that in a CFormView, but I'd rather not mess with another dialog > resource if I can avoid it. Besides, This should work (I think). > > > Here's my code... > > BOOL CMTIView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD > dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* > pContext) > { > // create the window > > if (!CWnd::CreateEx(WS_EX_CONTROLPARENT, lpszClassName, lpszWindowName, > dwStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, > pParentWnd->m_hWnd, (HMENU)nID, pContext)) return FALSE; > > // create CRichEditCtrl| > VERIFY(m_pRECFile->Create((WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | > ES_SUNKEN | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL | ES_READONLY), > |||||CRect(1,1,10,10), this, 0)); > > // create the list boxes| > VERIFY(m_pListIdentified->CreateEx(WS_EX_CLIENTEDGE,"LISTBOX","", > WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | > LBS_NOINTEGRALHEIGHT | LBS_STANDARD, > 1,1,10,10,GetSafeHwnd(),(HMENU)IDC_LIST_TERM_IDENTIFY)); > > VERIFY(m_ListTerms.CreateEx(WS_EX_CLIENTEDGE,"LISTBOX","", > WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | > LBS_NOINTEGRALHEIGHT | LBS_STANDARD, > 1,1,10,10,GetSafeHwnd(),(HMENU)IDC_LIST_TERMS)); > > return TRUE; > } > > I also tried setting the controls with the WS_TABSTOP style but to no avail. > > --matt > /~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Matthew Henry -- UMI > mhenry@umi.com (Work) > mhenry1384@aol.com (Home) > ~~~~~~~~~~~~~~~~~~~~~~~~~~/ Try this: Override PreTranslateMessage(). Check the msg structure to see if the message is for this particular view (this is just so you don't cause any side-effects elsewhere). If so, run it through IsDialogMessage() (returning the appropriate value from PreTrans... depending on IsDialogMessage's return values, etc...) , and you should get the required functionality. / ___| / ___| __ _ _ __ ___ ___| | \___ \ | | _ / _` | '_ \ / _ \/ __| '_ \ ___) | | |_| | (_| | | | | __/\__ \ | | | |____(_) \____|\__,_|_| |_|\___||___/_| |_| -----From: ganeshs@nationwide.com Environment: VC++ 4.0, Win 95 Oops! Guess I was half asleep while writing the last response to this one!! It should have read: Try this: Override PreTranslateMessage() in your derived-view as so: if (IsDialogMessage()) return TRUE; else return CView::IsDialogMessage(); and you should get the required functionality. / ___| / ___| __ _ _ __ ___ ___| | \___ \ | | _ / _` | '_ \ / _ \/ __| '_ \ ___) | | |_| | (_| | | | | __/\__ \ | | | |____(_) \____|\__,_|_| |_|\___||___/_| |_| -----From: Niels Ull JacobsenIf you don't want to use a dialog, you'll have to write your own handlers for focus change and accelerator handling.=20 I'd go for a CFormView myself. What's so bad about an extra dialog templa= te? If you like, you can make it empty and Create all your controls yourself = in OnCreate. WS_EX_CONTROLPARENT is only useful for childs of dialogs - it is only inspected by the default dialog handlers for focus change and accelerator= s. The default windows procedure won't look at it. And it's meant for window= s which contain controls but aren't controls themselves - e.g. embedded dialogs or pages on "do-it-yourself" property sheets. So you shouldn't us= e it for a control. =20 Niels Ull Jacobsen [MVP], Kr=FCger A/S (nuj@kruger.dk) Everything stated herein is THE OFFICIAL POLICY of the entire Kruger=20 group and should be taken as legally binding in every respect.=20 Pigs will grow wings and fly.
T.K.Wessing -- tkw@xs4all.nl Thursday, November 28, 1996 Hi, Why don't you use a CFormView with two contols on it? /===================================== | T.K.Wessing | Senior Software Engineer | Caledon Systems International BV | The Netherlands | Private E-Mail: | tkw@xs4all.nl \===================================== The Nedherlands ? Yep, "The Nedherlands" It does exists indeed! ---------- > From: MHENRY.UMI.COM> To: mfc-l@netcom.com > Subject: Tabbing bewtween controls on a view (CView that is) > Date: Monday, September 23, 1996 7:26 PM > > > > Environment: VC++ 4.0, Win 95 > > > I have a CView-derived class that I place two CListBoxs and a CRichEditView > on. I'd like to be able to tab between them. I've tried giving the view > window the extended "WS_EX_CONTROLPARENT", which according to the (negligible) > documentation allows you to tab between control windows on a view. But it > doesn't work, i.e., you hit tab and nothing happens. > > Has anyone used this extended window style? I can't find decent documentation > on it anywhere. I suppose I could create a dialog template and put my > controls on that in a CFormView, but I'd rather not mess with another dialog > resource if I can avoid it. Besides, This should work (I think). > > > Here's my code... > > BOOL CMTIView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD > dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* > pContext) > { > // create the window > > if (!CWnd::CreateEx(WS_EX_CONTROLPARENT, lpszClassName, lpszWindowName, > dwStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, > pParentWnd->m_hWnd, (HMENU)nID, pContext)) return FALSE; > > // create CRichEditCtrl > VERIFY(m_pRECFile->Create((WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | > ES_SUNKEN | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL | ES_READONLY), > CRect(1,1,10,10), this, 0)); > > // create the list boxes > VERIFY(m_pListIdentified->CreateEx(WS_EX_CLIENTEDGE,"LISTBOX","", > WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | > LBS_NOINTEGRALHEIGHT | LBS_STANDARD, > 1,1,10,10,GetSafeHwnd(),(HMENU)IDC_LIST_TERM_IDENTIFY)); > > VERIFY(m_ListTerms.CreateEx(WS_EX_CLIENTEDGE,"LISTBOX","", > WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | > LBS_NOINTEGRALHEIGHT | LBS_STANDARD, > 1,1,10,10,GetSafeHwnd(),(HMENU)IDC_LIST_TERMS)); > > return TRUE; > } > > I also tried setting the controls with the WS_TABSTOP style but to no avail. > > --matt > /~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Matthew Henry -- UMI > mhenry@umi.com (Work) > mhenry1384@aol.com (Home) > ~~~~~~~~~~~~~~~~~~~~~~~~~~/ > >
Rommel Songco -- rsongco@spectrasoft.com Monday, December 02, 1996 Matt, Override PreTranslateMessage() in your CView-derived class. Here, call IsDialogMessage() to let this function process the tab key like a normal dialog box. Here's a sample code: BOOL CYourView::PreTranslateMessage(MSG *msg) { if (msg->wParam == VK_TAB) return ( ::IsDialogMessage( m_hWnd,msg ) ); return FALSE; } BTW, don't forget to set the WS_TABSTOP attribute of your controls. Regards, Rommel rsongco@spectrasoft.com
| Вернуться в корень Архива |