Click here to Skip to main content
15,881,709 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow can I check if LPCTSTR is empty ? Pin
_Flaviu10-Apr-11 20:57
_Flaviu10-Apr-11 20:57 
AnswerRe: How can I check if LPCTSTR is empty ? Pin
Hans Dietrich10-Apr-11 21:10
mentorHans Dietrich10-Apr-11 21:10 
GeneralRe: How can I check if LPCTSTR is empty ? Pin
_Flaviu10-Apr-11 21:20
_Flaviu10-Apr-11 21:20 
AnswerRe: How can I check if LPCTSTR is empty ? Pin
Rajesh R Subramanian10-Apr-11 21:22
professionalRajesh R Subramanian10-Apr-11 21:22 
AnswerRe: How can I check if LPCTSTR is empty ? Pin
Rob Grainger10-Apr-11 23:44
Rob Grainger10-Apr-11 23:44 
GeneralRe: How can I check if LPCTSTR is empty ? Pin
_Flaviu11-Apr-11 5:45
_Flaviu11-Apr-11 5:45 
GeneralRe: How can I check if LPCTSTR is empty ? Pin
Rob Grainger11-Apr-11 12:55
Rob Grainger11-Apr-11 12:55 
QuestionProblem Showing Enumerated Sound Devices in ComboBox [modified] Pin
Paul Hasler10-Apr-11 16:49
Paul Hasler10-Apr-11 16:49 
Hi,

I'm trying to work through the example code in the MSDN DirectSound Programming Guide to enumerate sound devices.
When I run my app, the ComboBox which should list the available sound devices is for some reason empty.
Below is the Callback Procedure I've used for the Direct Sound device enumeration.
BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCSTR lpszDescription, LPCSTR lpszDriverName, LPVOID lpContext)
{
	HWND	hCombo = (HWND)lpContext;
	LPGUID	lpTemp = NULL;

	if(lpGUID != NULL)
	{
		if((lpTemp = (LPGUID)malloc(sizeof(GUID))) == NULL)
			return TRUE;
		memcpy(lpTemp, lpGUID, sizeof(GUID));
	}
	ComboBox_AddString(hCombo, lpszDescription);
	ComboBox_SetItemData(hCombo, ComboBox_FindString(hCombo, 0, lpszDescription), lpTemp);
	free(lpTemp);
	return TRUE;
}


FYI Inspecting lpGUID during debugging reveals that the first time the if(lpGUID != NULL) is reached, it's value is 0 so the statement evaluates to FALSE, and lpszDescription points to the 'P' of "Primary Sound Driver". The call to ComboBox_AddString processes ok without returning CB_ERR or CB_ERRSPACE. The process repeats for the other available devices, but once it's finished the ComboBox remains empty!?Confused | :confused:

Below is my Callback procedure for the dialog containing the ComboBox. I've added a static text to display the total number of entries as a check, but this shows "Num Entries: 0" when I run the app. What am I missing here?
BOOL CALLBACK DLG_AudioDeviceSelectionProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND	hCombo, hEntryCountText;
	int	iCount;
	TCHAR	szBuffer[32];

	switch(message)
	{
	case WM_INITDIALOG:
		hCombo = GetDlgItem(hDlg, IDC_COMBO);
		if(DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc,(VOID*)&hCombo) != DS_OK)
		{
			EndDialog(hDlg, TRUE);
			return TRUE;
		}
		iCount = ComboBox_GetCount(hCombo);
		hEntryCountText = GetDlgItem(hDlg, IDC_ENTRY_COUNT);
		wsprintf(szBuffer, TEXT("Num Entries: %i"), iCount);
		SetWindowText(hEntryCountText, szBuffer);
		
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDCANCEL:			
		case IDOK:
			EndDialog(hDlg, 0);
			return TRUE;
		}
		break;
	}
	return FALSE;
}


I'm using MS VC++ 2010.
I've worked through Petzold but I'm still essentially a Win API noob.
modified on Monday, April 11, 2011 12:57 AM

AnswerRe: Problem Showing Enumerated Sound Devices in ComboBox Pin
Hans Dietrich10-Apr-11 19:03
mentorHans Dietrich10-Apr-11 19:03 
GeneralRe: Problem Showing Enumerated Sound Devices in ComboBox Pin
Paul Hasler10-Apr-11 20:26
Paul Hasler10-Apr-11 20:26 
GeneralRe: Problem Showing Enumerated Sound Devices in ComboBox Pin
Hans Dietrich10-Apr-11 20:41
mentorHans Dietrich10-Apr-11 20:41 
GeneralRe: Problem Showing Enumerated Sound Devices in ComboBox Pin
Paul Hasler10-Apr-11 21:18
Paul Hasler10-Apr-11 21:18 
GeneralRe: Problem Showing Enumerated Sound Devices in ComboBox Pin
Hans Dietrich10-Apr-11 21:27
mentorHans Dietrich10-Apr-11 21:27 
GeneralRe: Problem Showing Enumerated Sound Devices in ComboBox Pin
Paul Hasler10-Apr-11 22:01
Paul Hasler10-Apr-11 22:01 
GeneralRe: Problem Showing Enumerated Sound Devices in ComboBox Pin
Hans Dietrich10-Apr-11 22:13
mentorHans Dietrich10-Apr-11 22:13 
Questionhow to set IE to open my file format? just like PDF files. Pin
refla10-Apr-11 16:08
refla10-Apr-11 16:08 
AnswerRe: how to set IE to open my file format? just like PDF files. Pin
Hans Dietrich10-Apr-11 19:06
mentorHans Dietrich10-Apr-11 19:06 
QuestionRedirecting output to DVI or HDMI. Pin
beastian10-Apr-11 4:34
beastian10-Apr-11 4:34 
AnswerRe: Redirecting output to DVI or HDMI. Pin
Code-o-mat10-Apr-11 11:37
Code-o-mat10-Apr-11 11:37 
GeneralRe: Redirecting output to DVI or HDMI. Pin
beastian13-May-11 4:28
beastian13-May-11 4:28 
GeneralRe: Redirecting output to DVI or HDMI. Pin
Code-o-mat13-May-11 4:30
Code-o-mat13-May-11 4:30 
Questionproblem to draw line in list control Pin
shashankacharya8-Apr-11 19:30
shashankacharya8-Apr-11 19:30 
AnswerRe: problem to draw line in list control Pin
Nitheesh George8-Apr-11 20:18
Nitheesh George8-Apr-11 20:18 
GeneralRe: problem to draw line in list control Pin
shashankacharya8-Apr-11 22:13
shashankacharya8-Apr-11 22:13 
GeneralRe: problem to draw line in list control Pin
Rotted Frog8-Apr-11 23:02
Rotted Frog8-Apr-11 23:02 

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.