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. How to access a function in another class file

How to access a function in another class file

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++databasetutoriallearning
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.
  • V Offline
    V Offline
    vc _fragrance
    wrote on last edited by
    #1

    Hi, By using MFC Appwizard I have created a project. Say FirstApp as an SDI application and chosen the Header files only as databasesupport. I wrote a function in FirstAppView class to get the database connection. After that I have inserted another Dialog resource and added a few controls for it and then added a new class for it. Now I want to invoke the function which I wrote in FirstAppView class. Can you plz say How can I do that? Thanks in advance.

    P T V 3 Replies Last reply
    0
    • V vc _fragrance

      Hi, By using MFC Appwizard I have created a project. Say FirstApp as an SDI application and chosen the Header files only as databasesupport. I wrote a function in FirstAppView class to get the database connection. After that I have inserted another Dialog resource and added a few controls for it and then added a new class for it. Now I want to invoke the function which I wrote in FirstAppView class. Can you plz say How can I do that? Thanks in advance.

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      Does this help;

      AfxGetMainWnd()->GetActiveView()->YourFunction();

      Prasad Notifier using ATL | Operator new[],delete[][^]

      V 1 Reply Last reply
      0
      • V vc _fragrance

        Hi, By using MFC Appwizard I have created a project. Say FirstApp as an SDI application and chosen the Header files only as databasesupport. I wrote a function in FirstAppView class to get the database connection. After that I have inserted another Dialog resource and added a few controls for it and then added a new class for it. Now I want to invoke the function which I wrote in FirstAppView class. Can you plz say How can I do that? Thanks in advance.

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

        tejaswini.g wrote:

        Now I want to invoke the function which I wrote in FirstAppView class.

        create extern object of that Class and call the required function using taht object!

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

        1 Reply Last reply
        0
        • V vc _fragrance

          Hi, By using MFC Appwizard I have created a project. Say FirstApp as an SDI application and chosen the Header files only as databasesupport. I wrote a function in FirstAppView class to get the database connection. After that I have inserted another Dialog resource and added a few controls for it and then added a new class for it. Now I want to invoke the function which I wrote in FirstAppView class. Can you plz say How can I do that? Thanks in advance.

          V Offline
          V Offline
          vc _fragrance
          wrote on last edited by
          #4

          Thank you very much for both of you. I have another doubt shall i ask you? I wrote code like this. while() { ..... ..... //a query to insert data into database. .... } I want to stop the execution for sometime say 2milli seconds after insert query. How can I do that? Can I use sleep() method here?

          T 1 Reply Last reply
          0
          • V vc _fragrance

            Thank you very much for both of you. I have another doubt shall i ask you? I wrote code like this. while() { ..... ..... //a query to insert data into database. .... } I want to stop the execution for sometime say 2milli seconds after insert query. How can I do that? Can I use sleep() method here?

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            tejaswini.g wrote:

            I want to stop the execution for sometime say 2milli seconds after insert query. How can I do that? Can I use sleep() method here?

            any particular reason to use While Loop!...

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

            V 1 Reply Last reply
            0
            • T ThatsAlok

              tejaswini.g wrote:

              I want to stop the execution for sometime say 2milli seconds after insert query. How can I do that? Can I use sleep() method here?

              any particular reason to use While Loop!...

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

              V Offline
              V Offline
              vc _fragrance
              wrote on last edited by
              #6

              Yes I am reading data from a .txt file and inserting it into the database.

              1 Reply Last reply
              0
              • P prasad_som

                Does this help;

                AfxGetMainWnd()->GetActiveView()->YourFunction();

                Prasad Notifier using ATL | Operator new[],delete[][^]

                V Offline
                V Offline
                vc _fragrance
                wrote on last edited by
                #7

                Hi Prasad, Actually I tried this way but I got an error saying that my application class is not derived from CWnd. Can u say how to overcome it. Thanks in advacne.

                P 1 Reply Last reply
                0
                • V vc _fragrance

                  Hi Prasad, Actually I tried this way but I got an error saying that my application class is not derived from CWnd. Can u say how to overcome it. Thanks in advacne.

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #8

                  Can you show some code? I assume your application is SDI with Doc/view support. and you have a dilaog class from which you want to access a function in view class, isn't it?

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  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