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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Many tabs using one serial port

Many tabs using one serial port

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutoriallearning
2 Posts 2 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.
  • C Offline
    C Offline
    chauteen
    wrote on last edited by
    #1

    Hi, I'm writing a dialog by MFC. I have several tabs, and every tab has some control items on it. I creat classes for every tab. I want to send out status thru RS-232, such as when the user click one spin, and the spin value will be sent out thru RS-232. My problem is I've got the tab class and a serial class ready. But how to confige a serial port that can be used by "all" tabs. If I create the port in one tab's cpp, other tabs will not be able to use the port, of course. However, it doesn't work if I configure a port in the project's main cpp, either. Forthermore, if I call the functions in the CSerailPort class, like: CSerialPort::Openport("com4"); The compiler says another error: illegal call of non-static member function. Thanx your help. Chauteen

    T 1 Reply Last reply
    0
    • C chauteen

      Hi, I'm writing a dialog by MFC. I have several tabs, and every tab has some control items on it. I creat classes for every tab. I want to send out status thru RS-232, such as when the user click one spin, and the spin value will be sent out thru RS-232. My problem is I've got the tab class and a serial class ready. But how to confige a serial port that can be used by "all" tabs. If I create the port in one tab's cpp, other tabs will not be able to use the port, of course. However, it doesn't work if I configure a port in the project's main cpp, either. Forthermore, if I call the functions in the CSerailPort class, like: CSerialPort::Openport("com4"); The compiler says another error: illegal call of non-static member function. Thanx your help. Chauteen

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

      Buddy, if you are comfortable with pointer,then declare the pointer in base of CSerialPort like this is you class. sorry i didn't work on tab control but i worked on property pages.i think you taleneted enough to understand this. here is little solution, you base class CSerialPort *BasePort; in your tabbed dialog classes as there can be many CSerialPort *DerPort; inbase class contructor or initdialog BasePort=new CSerialPort; // function regrading insilization of port /// now you are creating tab contral, just pass the pointer to every derived tab classes like this. Let One of tab class is Ctab1; now, Ctab1.DerPort=this->BasePort; andthis way you can access teh serial port in nay class. ps,don't forget to delete the pointer before closing the application ----------------------------- "I Think It will Work" Formerly Known As "Alok The Programmer" at CP ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

      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