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. Problem with CDialog::InitModalIndirect()

Problem with CDialog::InitModalIndirect()

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 0 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.
  • E Offline
    E Offline
    Eugene Pustovoyt
    wrote on last edited by
    #1

    I'm wrote a simple code to creates a empty Dialog. But I've an exception with him. Why?

        DLGTEMPLATE dlg;
    dlg.x = 0;
    dlg.y = 0;
    dlg.cx = 200;
    dlg.cy = 200;
    dlg.style = WS\_BORDER|WS\_CHILD|WS\_VISIBLE;
    dlg.dwExtendedStyle = 0;
    dlg.cdit = 0;
    CDialog Dialog;
    Dialog.InitModalIndirect(&dlg);
    DoModal();
    

    Best regards, Eugene Pustovoyt


    ICQ UIN: 161325180

    J 1 Reply Last reply
    0
    • E Eugene Pustovoyt

      I'm wrote a simple code to creates a empty Dialog. But I've an exception with him. Why?

          DLGTEMPLATE dlg;
      dlg.x = 0;
      dlg.y = 0;
      dlg.cx = 200;
      dlg.cy = 200;
      dlg.style = WS\_BORDER|WS\_CHILD|WS\_VISIBLE;
      dlg.dwExtendedStyle = 0;
      dlg.cdit = 0;
      CDialog Dialog;
      Dialog.InitModalIndirect(&dlg);
      DoModal();
      

      Best regards, Eugene Pustovoyt


      ICQ UIN: 161325180

      J Offline
      J Offline
      John R Shaw
      wrote on last edited by
      #2

      From MSDN: "To create a modal dialog box indirectly, first allocate a global block of memory and fill it with the dialog box template. Then call the empty CDialog constructor to construct the dialog-box object. Next, call InitModalIndirect to store your handle to the in-memory dialog-box template." Here is the most IMPORTANT part: "first allocate a global block of memory" It does not matter which version of InitModalIndirect you call, the DLGTEMPLATE must be in a globaly allocated memory block. That means using GlobalAlloc(...). If this is not the cause of exception, then the MSDN remarks section may be wrong. The only question that remains is: who is responsible for freeing the memeory? Search the MSDN for the sample code: "DLGTEMPL: Creating Dialog Templates Dynamically" Good Luck! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen

      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