list box
-
I have created a list box using my own class derived from CListBox. I want to disapear it from the dialog if anyone is clicking outside that listbox. very similar to combobox. Please help me to do that.. It will be fine if provide some sample code. Thanks
-
I have created a list box using my own class derived from CListBox. I want to disapear it from the dialog if anyone is clicking outside that listbox. very similar to combobox. Please help me to do that.. It will be fine if provide some sample code. Thanks
Create a handler for
WM_KILLFOCUS
inside you're class and callShowWindow(SW_HIDE)
on the listbox handle.«_Superman_»
I love work. It gives me something to do between weekends. -
Create a handler for
WM_KILLFOCUS
inside you're class and callShowWindow(SW_HIDE)
on the listbox handle.«_Superman_»
I love work. It gives me something to do between weekends.That I hv done but its not closing. Actually I am trying to create a dropdown Control. For that I created a button control derived from CButton and on click of that button control I am creating a listbox derived from CListBox. I am able to show and hide on the button click, even I am able to show and hide on listbox onselchange(), but I am not able to hide when I am clicking anywhere on the dialogbox. is there any child and parent window problem ? Thanks.
-
That I hv done but its not closing. Actually I am trying to create a dropdown Control. For that I created a button control derived from CButton and on click of that button control I am creating a listbox derived from CListBox. I am able to show and hide on the button click, even I am able to show and hide on listbox onselchange(), but I am not able to hide when I am clicking anywhere on the dialogbox. is there any child and parent window problem ? Thanks.
I'm guessing you're not getting the kill focus event. That's probably because you're not setting focus to the list when shown.
«_Superman_»
I love work. It gives me something to do between weekends. -
I'm guessing you're not getting the kill focus event. That's probably because you're not setting focus to the list when shown.
«_Superman_»
I love work. It gives me something to do between weekends. -
Could you please tell me how and where to set the focus for the list box. Bcoz I m creatin List box on the click of button control.
You could try to call
SetFocus
after creating and showing the list box.«_Superman_»
I love work. It gives me something to do between weekends. -
I have created a list box using my own class derived from CListBox. I want to disapear it from the dialog if anyone is clicking outside that listbox. very similar to combobox. Please help me to do that.. It will be fine if provide some sample code. Thanks
Have a look at my article: Generic Picker Dropdown Control[^] or the article I borrowed the original popup / killfocus idea from: Office 97 style Colour Picker control[^] Hopefully they will help you! Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
-
You could try to call
SetFocus
after creating and showing the list box.«_Superman_»
I love work. It gives me something to do between weekends.Hi I hv tried but its not working.. Here by I m sending my code , plz look into that.. // Here I am creating the button as well as ListBox. CTxDropDown is derived from CButton. void CTxDropDown::CreateDropDown(CRect rect, CWnd *pWnd, UINT nID) { this->Create(L"", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,rect, pWnd, nID); CRect m_rtBtn(rect); m_rtLst.left = m_rtBtn.left + 2 ; m_rtLst.top = m_rtBtn.top + 38 ; m_rtLst.right = m_rtBtn.right - 2 ; m_rtLst.bottom = m_rtBtn.bottom + 120 ; m_lstCtrl.CreateListBox(m_rtLst , pWnd , this , nID); m_lstCtrl.SetItemHeight(0, 25); m_lstCtrl.AddString(L" ENGLISH"); m_lstCtrl.AddString(L" JAPANIES"); m_lstCtrl.AddString(L" FRENCH"); m_lstCtrl.AddString(L" GERMAN"); m_lstCtrl.ShowWindow(SW_HIDE); } // On button click I m showing the and hiding the ListBox. m_lstCtrl is the object of my listbox class void CTxDropDown::OnBnClicked() { // TODO: Add your control notification handler code here. m_lstCtrl.SetFocus(); m_bShowListCtrl = !m_bShowListCtrl; m_lstCtrl.ShowWindow(m_bShowListCtrl ); Invalidate(); } // Here I am creating the ListBox.CTxListControl is derived froom CListBox. void CTxListControl::CreateListBox(CRect rect,CWnd *pWnd,CWnd *pDropDownWnd ,UINT nID) { this->Create(WS_VISIBLE |WS_CHILD|WS_VSCROLL|LBS_NOTIFY| LBS_HASSTRINGS | WS_TABSTOP ,rect , pWnd , nID); this->SetFocus(); m_pDropDownWnd = pDropDownWnd; m_rtLst = rect ; } // Calling the KillFocus on ClistBox void CTxListControl::OnLbnKillfocus() { // TODO: Add your control notification handler code here CListBox::ShowWindow(SW_HIDE); } Plz look the code.. and Gv some idea where I m worng..
-
Have a look at my article: Generic Picker Dropdown Control[^] or the article I borrowed the original popup / killfocus idea from: Office 97 style Colour Picker control[^] Hopefully they will help you! Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
-
Did the KillFocus path have any advantages over SetCapture/ReleaseCature? (And 10 extra points for why.) The capture way seems to be how comboboxes are implemented, since mouse clicks outside the dropped down list has no effect on other controls.
I might have to miss the extra points, I'm afraid - I mostly just took Chris' idea and went with it. In the end, pretty much all the code was mine, I just took the idea. But SetCapture does have a disadvantage or two once you go from Win 3 to NT - it doesn't work across processes now - for good reason. KillFocus will work better if you click on another application. Your point about not doing anything when you're just clicking away from the dropdown bit of a combox box is a good one, I have to say. I hadn't really noticed it before. I press escape, or click on the already selected item if I want to get rid of it. In the app I used the Generic Dropdown's in had a decent about of safe clickable space, so it wasn't an issue. Did I get the cookie? Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
-
I might have to miss the extra points, I'm afraid - I mostly just took Chris' idea and went with it. In the end, pretty much all the code was mine, I just took the idea. But SetCapture does have a disadvantage or two once you go from Win 3 to NT - it doesn't work across processes now - for good reason. KillFocus will work better if you click on another application. Your point about not doing anything when you're just clicking away from the dropdown bit of a combox box is a good one, I have to say. I hadn't really noticed it before. I press escape, or click on the already selected item if I want to get rid of it. In the app I used the Generic Dropdown's in had a decent about of safe clickable space, so it wasn't an issue. Did I get the cookie? Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
-
I might have to miss the extra points, I'm afraid - I mostly just took Chris' idea and went with it. In the end, pretty much all the code was mine, I just took the idea. But SetCapture does have a disadvantage or two once you go from Win 3 to NT - it doesn't work across processes now - for good reason. KillFocus will work better if you click on another application. Your point about not doing anything when you're just clicking away from the dropdown bit of a combox box is a good one, I have to say. I hadn't really noticed it before. I press escape, or click on the already selected item if I want to get rid of it. In the app I used the Generic Dropdown's in had a decent about of safe clickable space, so it wasn't an issue. Did I get the cookie? Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
-
Have a look at my original reply: http://www.codeproject.com/Messages/3528108/Re-list-box.aspx[^] I gave you links to two good articles that should help you. It will take you a little while to read them, look at the code, try moving some of the code to your own program... Good luck, Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!