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. Serial port question

Serial port question

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 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.
  • A Offline
    A Offline
    andyg 101
    wrote on last edited by
    #1

    Hi I have some code written for a serial port class. Now I want to access the same serial port object from a number of different dialogues etc within my program. So I guess the best way to do this is by making the object global at the start of the application? Or is there another way? Also where do I put the decleration for a global variable in an MDI app? Any suggestions much appreciated Andy

    A L 2 Replies Last reply
    0
    • A andyg 101

      Hi I have some code written for a serial port class. Now I want to access the same serial port object from a number of different dialogues etc within my program. So I guess the best way to do this is by making the object global at the start of the application? Or is there another way? Also where do I put the decleration for a global variable in an MDI app? Any suggestions much appreciated Andy

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      other way would be to modify the constructors. Add a pointer to of Object.

      A 1 Reply Last reply
      0
      • A Anonymous

        other way would be to modify the constructors. Add a pointer to of Object.

        A Offline
        A Offline
        andyg 101
        wrote on last edited by
        #3

        could you explain in more detail? Andy

        A 1 Reply Last reply
        0
        • A andyg 101

          could you explain in more detail? Andy

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          create an own class that handles your actions with the serial port. Start the Dialog, SDI or MDI. Create a Member of Your SerialPortClass in the Maindialog. If you start an other Window add an pointer to your dialog class into the window constructor. Now you have acces to the members of the dialog

          1 Reply Last reply
          0
          • A andyg 101

            Hi I have some code written for a serial port class. Now I want to access the same serial port object from a number of different dialogues etc within my program. So I guess the best way to do this is by making the object global at the start of the application? Or is there another way? Also where do I put the decleration for a global variable in an MDI app? Any suggestions much appreciated Andy

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Put it in the Application class, then refer to it via theApp->member _variable. Elaine :rose: The tigress is here :-D

            A 1 Reply Last reply
            0
            • L Lost User

              Put it in the Application class, then refer to it via theApp->member _variable. Elaine :rose: The tigress is here :-D

              A Offline
              A Offline
              andyg 101
              wrote on last edited by
              #6

              nice one cheers I get a bit stuck sometimes with the doc/view structure, coming from C/embedded stuff where I just have main! Andy

              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