CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Controls in MFC

  1. #1
    Join Date
    Feb 2011
    Posts
    7

    Controls in MFC

    Hi

    I have a question, I'm working on a MFC assigment and I encountered on a problem,and fixed it after spending houres searching the internet and thinking . Here is what the problem was, my project was working fine but when I would close it a run time check error ocures saying "stack around InitCtrls variable was corrupted", variable InitCtrls is defined

    1. INITCOMMONCONTROLSEX InitCtrls;
    2. InitCtrls.dwSize = sizeof(InitCtrls);

    3. InitCtrls.dwICC = ICC_STANDARD_CLASSES;
    4. InitCommonControlsEx(&InitCtrls);
    Now I know that when this error ocures that there isn't enough memory for some variable
    example:

    int a[4];
    a[5]=25; //stack over variable a corrupted

    In my problem the line 3. was defined like this
    InitCtrls.dwICC =ICC_WIN95_CLASSES;

    and when I changed it to

    InitCtrls.dwICC = ICC_STANDARD_CLASSES;

    the problem was fixed. Finnaly my question is how does changing the code in line 3. relate with the simple example showed above? what do ICC_WIN95_CLASSES,ICC_STANDARD_CLASSES mean?

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Controls in MFC

    No, I don't think it is not having enough stack space for some reason. You can increase your stack space in your project by changing the options.
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Controls in MFC

    I suspect that it probably has to do with another stack variable either before or after "INITCOMMONCONTROLSEX InitCtrls;" which is over/under-flowing. All the ICC_xxx defines are the same size (they're #defines in commctl.h).

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Controls in MFC

    [ removed duplicate thread ]
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Feb 2011
    Posts
    7

    Re: Controls in MFC

    You're right hoxsiew, I put the ICC_WIN95_CLASSES back and it works fine now, it was another variable. The problem would always occur when I would add a variable by an Add Variable Wizard in my Edit Control in the Dialog box, and when I would remove the variable, then there would be no run time errors.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured