Unhandled exception when using acmFormatChoose.
-
I have some code where i try to display a dialog box where a user can choose a specific format. I've filled all the parts of the struct that needs to be filled accoring to the MSDN, but still i get an unhandled exception when running the function. Here's my code:
ACMFORMATCHOOSE acmChoose;
WAVEFORMATEX fmtChoose = { 0 };acmChoose.pwfx = &fmtChoose;
acmChoose.cbwfx = sizeof(fmtChoose);
acmChoose.cbStruct = sizeof(acmChoose);
acmChoose.hwndOwner = ghWnd;acmFormatChoose(&acmChoose);
Where ghWnd is a valid handle to my main window. Anyone know what could be wrong? Thankyou all, all input is appreciated. -Rune Svendsen
-
I have some code where i try to display a dialog box where a user can choose a specific format. I've filled all the parts of the struct that needs to be filled accoring to the MSDN, but still i get an unhandled exception when running the function. Here's my code:
ACMFORMATCHOOSE acmChoose;
WAVEFORMATEX fmtChoose = { 0 };acmChoose.pwfx = &fmtChoose;
acmChoose.cbwfx = sizeof(fmtChoose);
acmChoose.cbStruct = sizeof(acmChoose);
acmChoose.hwndOwner = ghWnd;acmFormatChoose(&acmChoose);
Where ghWnd is a valid handle to my main window. Anyone know what could be wrong? Thankyou all, all input is appreciated. -Rune Svendsen
I have know idea what is wrong with your code. If you handle the exception, you will find out what the problem is. Add try/catch to your code to catch the exception. Something like this:
try {
ACMFORMATCHOOSE acmChoose;
WAVEFORMATEX fmtChoose = { 0 };
acmChoose.pwfx = &fmtChoose;
acmChoose.cbwfx = sizeof(fmtChoose);
acmChoose.cbStruct = sizeof(acmChoose);
acmChoose.hwndOwner = ghWnd;acmFormatChoose(&acmChoose);
}
catch (CExcpetion *e) {
handle the excption here ...This is a general exception. You can catch specific derivitives with things like catch (CFileException ... catch (CMemoryException... These are classes derived from CExcpetion. Your code can have multiple catch clauses for a try clause. The first catch that qualifies will get the exception. try { ... } catch (CMemoryException *e) { ... } catch (CExceptin *e) { ... } catch (CFileException *e) { ... This will neverget executed, even if a file exceptionis thrown.The more general CException handler above will get it instead. Be careful of the order. Exceptin handling is a fairly deep topic and a fundamental of windows programming. I'd suggest you research windows exception handling in MSDN or other sources.
-
I have some code where i try to display a dialog box where a user can choose a specific format. I've filled all the parts of the struct that needs to be filled accoring to the MSDN, but still i get an unhandled exception when running the function. Here's my code:
ACMFORMATCHOOSE acmChoose;
WAVEFORMATEX fmtChoose = { 0 };acmChoose.pwfx = &fmtChoose;
acmChoose.cbwfx = sizeof(fmtChoose);
acmChoose.cbStruct = sizeof(acmChoose);
acmChoose.hwndOwner = ghWnd;acmFormatChoose(&acmChoose);
Where ghWnd is a valid handle to my main window. Anyone know what could be wrong? Thankyou all, all input is appreciated. -Rune Svendsen
- What is the debugger telling you in detail about the execption? (Exception type like "Microsoft C++ exception" or "Access violation" or something like that.) 2) If you choose Cancel to debug your app, where exactly the program is halted? This is the point in code which throws the exception. 3) If the above does not give you any helpful information, it might also be a worthwhile option to single-step your code in the debugger to see where exactly the exception occurs. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )