help with global variables in MFC dialog Application
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: help with global variables in MFC dialog Application

  1. #1
    Join Date
    Jan 2009
    Posts
    20

    help with global variables in MFC dialog Application

    Dear all,

    I am using MFC dialog application to get an text input from the user and make processing on it and then reply with response but I need to declare some variables to be working throughout the whole system cycle(I think its called global variables) to be accessible whereever from my system coding files. Because I need to deal with the variable changes during the system cycle.

    I tired many things Like: static ,extern. But till now I'm beginner in this language so I didn't know how to deal with them in .cpp files.

    Please any help will be appreciated.


    Best regards.

  2. #2
    Join Date
    Jun 2009
    Location
    oklahoma
    Posts
    199

    Re: help with global variables in MFC dialog Application

    In your main application's .cpp file, you can declare your global variable at the top of the file
    Code:
    int g_nValue;
    Then in each other .cpp file you need access to it, at the top of the file
    Code:
    extern int g_nValue;
    By the way, this belongs in the Visual C++ forum

  3. #3
    Join Date
    Jan 2009
    Posts
    20

    Re: help with global variables in MFC dialog Application

    Thank you for your help. its work fine

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center