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. Variables and functions in user defined functions

Variables and functions in user defined functions

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpquestion
5 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.
  • S Offline
    S Offline
    SeanSheehan
    wrote on last edited by
    #1

    When creating a dialog based MFC application in VC++.net how does one utilize control variables and other function like UpdateData() inside a user defined function?

    M T 2 Replies Last reply
    0
    • S SeanSheehan

      When creating a dialog based MFC application in VC++.net how does one utilize control variables and other function like UpdateData() inside a user defined function?

      M Offline
      M Offline
      mirex
      wrote on last edited by
      #2

      please rephrase your question, i dont understand

      S 1 Reply Last reply
      0
      • S SeanSheehan

        When creating a dialog based MFC application in VC++.net how does one utilize control variables and other function like UpdateData() inside a user defined function?

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        i don't understand either, but why should it be different to call a these functions in a user defined function from a non one ??? of course, you cannot call everything (UpdateData() is MFC specific), but you call it the same way...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        1 Reply Last reply
        0
        • M mirex

          please rephrase your question, i dont understand

          S Offline
          S Offline
          SeanSheehan
          wrote on last edited by
          #4

          So I wrote my own function which is called when I click a button. I defined and declared it in the main source file. I also associated some variables with some edit boxes through the setup wizard. When I try to use these edit box variables within the body of my function I get a linker error. The same happens when I try to use UpdateData() in my function. The only way I've found to use the variables in my function is to declare them at the top of the file - but then there are other errors because they are not defined where the rest of the code expects to find them - in the public section of the header file. I'm sure this is something really simple to fix but in my limited experience I just haven't yet come across a solution.

          M 1 Reply Last reply
          0
          • S SeanSheehan

            So I wrote my own function which is called when I click a button. I defined and declared it in the main source file. I also associated some variables with some edit boxes through the setup wizard. When I try to use these edit box variables within the body of my function I get a linker error. The same happens when I try to use UpdateData() in my function. The only way I've found to use the variables in my function is to declare them at the top of the file - but then there are other errors because they are not defined where the rest of the code expects to find them - in the public section of the header file. I'm sure this is something really simple to fix but in my limited experience I just haven't yet come across a solution.

            M Offline
            M Offline
            mirex
            wrote on last edited by
            #5

            Well definately you should not declare those variables, they should be declared (and inserted into sourcecode) when you create them by wizard. I dont use VC.NET, just a classical VC 6, but it works this way: I have main dialog, it is a class, it has two sourcefiles, header classfile.h and code classfile.cpp. When I insert a button and add a function to it it creates a function (OnButton1 for example) which is member of the dialog class (it is defined in header and function code outline is inserted into cpp file). If i create a edit box and associate a variable to it its definition is added to header file. (are you sure you added it ? because if you add it and then click 'cancel' button, then changes are lost, you have to click 'Ok' button in the wizard). So now we have a function which is member of dialog class and a variables which are members of the dialog class. So they should see each other and they should be able to access each other... if this does not help then please post a build log or project files, where we can see what is the error.

            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