Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Unhandled exception when using acmFormatChoose.

Unhandled exception when using acmFormatChoose.

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redeemer
    wrote on last edited by
    #1

    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

    B D 2 Replies Last reply
    0
    • R redeemer

      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

      B Offline
      B Offline
      Bill Wilson
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • R redeemer

        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

        D Offline
        D Offline
        Daniel Lohmann
        wrote on last edited by
        #3
        1. 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 )
        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups