My CListBox won't accept the keyboard focus
Paul Martinsen -- p.martinsen@auckland.ac.nz Friday, March 07, 1997 Environment: VC4.0, Win 95 Hello All, I am working on implementing a Multiple undo dropdown on my tool bar --- like developer studios. To do this I create a window that contains a static text box, and a class derived from CListBox. This window is a child of the desktop so that it overlaps everything. (If I use a popup, the app gets the inactive look when the window pops up). The problem I am having is that I can't set the keyboard focus to the list box. m_list.SetFocus() returns null, even though GetFocus() does not. According to the documentation this means that the m_list window handle is invalid, but I don't know why. I am making this call from within DoModal, just before I call RunModalLoop. Any suggestions as to why I can't give the keyboard focus to my dropdown? Thanks for any help, Paul Martinsen. BTW: I am pretty sure it is correct to make the desktop the owner. MSVC seems to do that.
Davanum Srinivas -- srinidm@itd.ssb.com Monday, March 10, 1997 Hi, Try to Set the focus in the parent windows WM_CREATE (or) Post a WM_USER+?? message to itself in the parent window and set the focus in the Handler for the user - defined message. PS: to be really sure that your Listbox is created, alive and well. use GetSafeHwnd() to check.... HTH. -- dims ////////////////////////////////////////////////// // Davanum M. Srinivas // dims@usa.net // // State Street Bank. // dims@ix.netcom.com // // (617)-985-0685 // srinidm@itd.ssb.com // ////////////////////////////////////////////////// ---------- > From: Paul Martinsen> To: mfc-l@netcom.com > Subject: My CListBox won't accept the keyboard focus > Date: Thursday, March 06, 1997 5:19 PM > > Environment: VC4.0, Win 95 > > Hello All, > > I am working on implementing a Multiple undo dropdown on my tool bar --- > like developer studios. To do this I create a window that contains a static > text box, and a class derived from CListBox. This window is a child of the > desktop so that it overlaps everything. (If I use a popup, the app gets the > inactive look when the window pops up). > > The problem I am having is that I can't set the keyboard focus to the list > box. m_list.SetFocus() returns null, even though GetFocus() does not. > According to the documentation this means that the m_list window handle is > invalid, but I don't know why. I am making this call from within DoModal, > just before I call RunModalLoop. > > Any suggestions as to why I can't give the keyboard focus to my dropdown? > > Thanks for any help, > Paul Martinsen. > BTW: I am pretty sure it is correct to make the desktop the owner. MSVC > seems to do that. >
Become an MFC-L member | Вернуться в корень Архива |