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. Error Heap in allocate modeless .

Error Heap in allocate modeless .

Scheduled Pinned Locked Moved C / C++ / MFC
help
8 Posts 3 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.
  • H Offline
    H Offline
    HTT90
    wrote on last edited by
    #1

    I have the code about create many modeless dialog .

    for(int i=0;i < 5;++i)
    {
    pRegionDlg[i] = new CRegionDlg ( this );
    pRegionDlg[i]->Create( IDD_DIALOG , this );
    pRegionDlg[i]->ShowWindow( SW_SHOW ) ;
    }

    this code is error heap . but I don't understand why it's error . while this code can run good on other program . Thanks for reading and helping .

    D CPalliniC 2 Replies Last reply
    0
    • H HTT90

      I have the code about create many modeless dialog .

      for(int i=0;i < 5;++i)
      {
      pRegionDlg[i] = new CRegionDlg ( this );
      pRegionDlg[i]->Create( IDD_DIALOG , this );
      pRegionDlg[i]->ShowWindow( SW_SHOW ) ;
      }

      this code is error heap . but I don't understand why it's error . while this code can run good on other program . Thanks for reading and helping .

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      HTT90 wrote:

      this code is error heap . but I don't understand why it's error . while this code can run good on other program .

      What is this supposed to mean? What error? Where? How was pRegionDlg declared? Please clarify.

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Man who follows car will be exhausted." - Confucius

      1 Reply Last reply
      0
      • H HTT90

        I have the code about create many modeless dialog .

        for(int i=0;i < 5;++i)
        {
        pRegionDlg[i] = new CRegionDlg ( this );
        pRegionDlg[i]->Create( IDD_DIALOG , this );
        pRegionDlg[i]->ShowWindow( SW_SHOW ) ;
        }

        this code is error heap . but I don't understand why it's error . while this code can run good on other program . Thanks for reading and helping .

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        Maybe 'the other program' properly allocates the pRegionDlg array. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        H 1 Reply Last reply
        0
        • CPalliniC CPallini

          Maybe 'the other program' properly allocates the pRegionDlg array. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          H Offline
          H Offline
          HTT90
          wrote on last edited by
          #4

          I did : in header file :

          CRegionDlg *pRegionDlg[8] ;

          and when I debug , I receive a message , it's inform me no loaded from dll . and heap is error .

          CPalliniC 1 Reply Last reply
          0
          • H HTT90

            I did : in header file :

            CRegionDlg *pRegionDlg[8] ;

            and when I debug , I receive a message , it's inform me no loaded from dll . and heap is error .

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            Please don't define arrays in header files. Please report full error message. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            In testa che avete, signor di Ceprano?

            H 1 Reply Last reply
            0
            • CPalliniC CPallini

              Please don't define arrays in header files. Please report full error message. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              H Offline
              H Offline
              HTT90
              wrote on last edited by
              #6

              I don't know why now it's run good and no error . :( . Can You say why don't define arrays in header files ? I'm chicken . :)

              CPalliniC 1 Reply Last reply
              0
              • H HTT90

                I don't know why now it's run good and no error . :( . Can You say why don't define arrays in header files ? I'm chicken . :)

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #7

                You should never define variables inside header files (headers are for declarations), because you may get multiple definitions of the same symbol (if, as usual, the header is included by many sources). If you need to access a variable from multiple sources then you have to:

                • Declare it as extern inside an header file.
                • Define it inside just one source file.
                • Include the header file into every source that needs to access the variable itself.

                :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                In testa che avete, signor di Ceprano?

                H 1 Reply Last reply
                0
                • CPalliniC CPallini

                  You should never define variables inside header files (headers are for declarations), because you may get multiple definitions of the same symbol (if, as usual, the header is included by many sources). If you need to access a variable from multiple sources then you have to:

                  • Declare it as extern inside an header file.
                  • Define it inside just one source file.
                  • Include the header file into every source that needs to access the variable itself.

                  :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  H Offline
                  H Offline
                  HTT90
                  wrote on last edited by
                  #8

                  Thanks . :) .

                  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