Click here to Skip to main content
15,891,204 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMy rc file got too fat !!! Pin
8-Oct-01 15:54
suss8-Oct-01 15:54 
GeneralRe: My rc file got too fat !!! Pin
8-Oct-01 21:43
suss8-Oct-01 21:43 
GeneralRe: My rc file got too fat !!! Pin
8-Oct-01 22:48
suss8-Oct-01 22:48 
Generaldirectory and DFileDialog Pin
8-Oct-01 14:51
suss8-Oct-01 14:51 
GeneralRe: directory and DFileDialog Pin
Michael Dunn8-Oct-01 16:12
sitebuilderMichael Dunn8-Oct-01 16:12 
GeneralRe: directory and DFileDialog Pin
Fredrik Sigbjörn8-Oct-01 21:24
Fredrik Sigbjörn8-Oct-01 21:24 
GeneralProper implementation of ComboBox Pin
Xian8-Oct-01 14:45
Xian8-Oct-01 14:45 
GeneralRe: Proper implementation of ComboBox Pin
Brendan Tregear8-Oct-01 18:03
Brendan Tregear8-Oct-01 18:03 
I haven't done much work with combo box controls, but I had a similar situation with a list control where i needed to store extra data besides what is displayed. I think you can use the CComboBoxEx object which use the COMBOEXITEM structure instead of LVITEM. You can store a pointer to a filter string (or a pointer to a structure if you need to store more)

<br />
typedef struct { TCHAR szFilter[256]; //eg "*.*<br />
} FILTERDATA, *PFILTERDATA;<br />


Then just add the structure when adding your items, for list control:

<br />
PFILTERDATA pData = new FILTERDATA;<br />
strcpy(pData->szFilter, szMyFilter);<br />
<br />
COMBOEXITEM item;<br />
memset(&item, 0, sizeof(item));<br />
item.mask = CBEIF_LPARAm | CBEIF_TEXT;<br />
item.lparam = (LPARAM) pData;<br />
item.iItem = -1;<br />
item.pszText = new TCHAR[sizeof(szMyDisplay)];<br />
item.cchText = sizeof(szMyDisplay);<br />
<br />
nItem = m_cFilters.InsertItem(0, &item);<br />


Then when your user selects something do:
<br />
		COMBOEXITEM cbi;<br />
		ZeroMemory(&cbi, sizeof(COMBOEXITEM));<br />
		cbi.iItem = hitTest.iItem;<br />
		cbi.mask = CBEIF_PARAM;<br />
		m_cFilters.GetItem(&cbi);<br />
		<br />
                PFILTERDATA pTemp = cbi.lParam;<br />
<br />
		CString strTemp;<br />
                strTemp.Format("Filter is %s", pTemp->szFilter);<br />


or maybe there's an easier way Smile | :)

btw don't forget to delete the lparam pointer. probably best to subclass the entire control so you can delete the memory in teh destructor
Question.NET to replace MFC???? Pin
Stormwind8-Oct-01 14:37
Stormwind8-Oct-01 14:37 
AnswerRe: .NET to replace MFC???? Pin
Fazlul Kabir8-Oct-01 14:55
Fazlul Kabir8-Oct-01 14:55 
AnswerRe: .NET to replace MFC???? Pin
Christian Graus8-Oct-01 15:52
protectorChristian Graus8-Oct-01 15:52 
GeneralRe: .NET to replace MFC???? Pin
Fazlul Kabir8-Oct-01 17:01
Fazlul Kabir8-Oct-01 17:01 
GeneralRe: .NET to replace MFC???? Pin
Christian Graus8-Oct-01 17:24
protectorChristian Graus8-Oct-01 17:24 
GeneralRe: .NET to replace MFC???? Pin
Fazlul Kabir8-Oct-01 18:54
Fazlul Kabir8-Oct-01 18:54 
GeneralRe: .NET to replace MFC???? Pin
Christian Graus8-Oct-01 19:02
protectorChristian Graus8-Oct-01 19:02 
GeneralRe: .NET to replace MFC???? Pin
Tomasz Sowinski8-Oct-01 23:48
Tomasz Sowinski8-Oct-01 23:48 
GeneralRe: .NET to replace MFC???? Pin
Christian Graus9-Oct-01 0:05
protectorChristian Graus9-Oct-01 0:05 
GeneralRe: .NET to replace MFC???? Pin
Mike Burston9-Oct-01 0:33
Mike Burston9-Oct-01 0:33 
GeneralRe: .NET to replace MFC???? Pin
Christian Graus9-Oct-01 0:40
protectorChristian Graus9-Oct-01 0:40 
GeneralRe: .NET to replace MFC???? Pin
Tomasz Sowinski9-Oct-01 1:01
Tomasz Sowinski9-Oct-01 1:01 
GeneralRe: .NET to replace MFC???? Pin
Mike Burston9-Oct-01 1:31
Mike Burston9-Oct-01 1:31 
GeneralRe: .NET to replace MFC???? Pin
Tomasz Sowinski9-Oct-01 1:40
Tomasz Sowinski9-Oct-01 1:40 
GeneralRe: .NET to replace MFC???? Pin
Mike Burston9-Oct-01 2:06
Mike Burston9-Oct-01 2:06 
GeneralRe: .NET to replace MFC???? Pin
Tomasz Sowinski9-Oct-01 2:17
Tomasz Sowinski9-Oct-01 2:17 
GeneralRe: .NET to replace MFC???? Pin
Derek Lakin9-Oct-01 0:35
Derek Lakin9-Oct-01 0:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.