Hi there,
I was just curious as to how this is done? I'm working in Visual Studio (with C++) and I'm trying to follow an author's work on how he made a dialog box and then added content to it.
Check out the following code he uses:
Code:
void AddItem(HWND hWnd, char *ch, void *pData)
{
WPARAM nI = (WPARAM)((int)(DWORD)SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)ch));
SendMessage(hWnd,CB_SETITEMDATA, nI, (LPARAM)pData);
}
And here's an example of it being called:
Code:
AddItem(m_hADAPTER, m_xAdapterInfo[a].
d3dAdapterIdentifier.Description,
&m_xAdapterInfo[a]);
Which takes place inside an iteration loop where a is the incremented iterator.
The function AddItem is a helper function which contains the native Win32 code that does the job. I was a bit confused though that it seems to use the function SendMessage twice? In the first part he uses SendMessage to make a WPARAM variable which is then passed into another call of SendMessage on the very next line.
That's where I'm struggling, why use SendMessage twice? Maybe the first call is just to add a string to the combo box and maybe the next is to add the relevant data to its entry?
I should add by the way that the HWND variable m_hADAPTER is a handle to the combo box control itself and not a HWND handle to the Dialog Box it's contained within.
I hope that's made some sense, I'd appreciate anyone who can shed any light on this at all is it's got my head well and truly cornered