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. comms config

comms config

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorialquestionworkspace
11 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.
  • A andyg 101

    Hi I'm trying to write a class for serial comms. One of the things I want to do is to be able to set the config of the serial port using the CommConfigDialog API call, but I keep getting an exception in serialui.dll. I think I need to call GetCommConfig first to get the pointer to the structure, but I can't work out how to get the size of the buffer (3rd parameter). Does anyone know how to do this? And also which buffer does it mean?

    BOOL GetCommConfig(
    HANDLE hCommDev, // handle to communications service
    LPCOMMCONFIG lpCC, // pointer to comm configuration structure
    LPDWORD lpdwSize // pointer to size of buffer
    );

    Thanks Andy

    D Offline
    D Offline
    David Crow
    wrote on last edited by
    #2

    HANDLE hDev; HWND hWnd; COMMCONFIG cfg; DWORD dwSize = sizeof(cfg); GetCommConfig(hDev, &cfg, &dwSize); CommConfigDialog("name of device", hWnd, &cfg);

    A 1 Reply Last reply
    0
    • D David Crow

      HANDLE hDev; HWND hWnd; COMMCONFIG cfg; DWORD dwSize = sizeof(cfg); GetCommConfig(hDev, &cfg, &dwSize); CommConfigDialog("name of device", hWnd, &cfg);

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

      Brilliant cheers :-) my next question is about the pointer to the window hWnd. How can I get a pointer to whichever dialogue creates an instance of my serial port class? e.g. I have a communications dialogue and I want to get a handle to this but using my serial port class, but make it flexible so that it is not restricted to one dialogue? Thanks Andrew

      D 1 Reply Last reply
      0
      • A andyg 101

        Brilliant cheers :-) my next question is about the pointer to the window hWnd. How can I get a pointer to whichever dialogue creates an instance of my serial port class? e.g. I have a communications dialogue and I want to get a handle to this but using my serial port class, but make it flexible so that it is not restricted to one dialogue? Thanks Andrew

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #4

        It would be up to the class that creates an instance of your serial port class to provide a pointer to its window. Your serial port class cannot "reach out" and get this.

        A 1 Reply Last reply
        0
        • D David Crow

          It would be up to the class that creates an instance of your serial port class to provide a pointer to its window. Your serial port class cannot "reach out" and get this.

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

          Ok, so the Dialogue class could pass it's own pointer if I defined the interface to the config dialogue as something like

          CComPort port;
          port.config(hWndDialogue)

          but how do I get the handle to the dialogue window? THis is what I meant really in the first place, I thought about using GetParent on the Config dialogue , but I can't because I need to create it first! Sorry if this is a stupid question. Hope you can help Andy

          D 1 Reply Last reply
          0
          • A andyg 101

            Ok, so the Dialogue class could pass it's own pointer if I defined the interface to the config dialogue as something like

            CComPort port;
            port.config(hWndDialogue)

            but how do I get the handle to the dialogue window? THis is what I meant really in the first place, I thought about using GetParent on the Config dialogue , but I can't because I need to create it first! Sorry if this is a stupid question. Hope you can help Andy

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #6

            andyg.101 wrote: CComPort port;port.config(hWndDialogue) but how do I get the handle to the dialogue window? hWndDialogue IS the handle to the dialog window. I'm assuming this only because you are using a variable-naming convention where 'h' most likely means handle.

            A 1 Reply Last reply
            0
            • D David Crow

              andyg.101 wrote: CComPort port;port.config(hWndDialogue) but how do I get the handle to the dialogue window? hWndDialogue IS the handle to the dialog window. I'm assuming this only because you are using a variable-naming convention where 'h' most likely means handle.

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

              ok, I have worked out that I needed to use the m_hWnd member of my dialogue doh! i.e. pass port.config(m_hWnd); How can i find out what member variables are in a class heirarchy? The base classes viewer seems to only show functions? Andy

              D 1 Reply Last reply
              0
              • A andyg 101

                ok, I have worked out that I needed to use the m_hWnd member of my dialogue doh! i.e. pass port.config(m_hWnd); How can i find out what member variables are in a class heirarchy? The base classes viewer seems to only show functions? Andy

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #8

                Not sure. Are you talking about the ClassView tab in the Workspace window? I've never known it to NOT show all members of a class.

                A 1 Reply Last reply
                0
                • D David Crow

                  Not sure. Are you talking about the ClassView tab in the Workspace window? I've never known it to NOT show all members of a class.

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

                  Yes the class view shows the members you declare in your derived class, but I don't think it shows the member variables in the base classes i.e. CWnd member variables. Andy

                  D 1 Reply Last reply
                  0
                  • A andyg 101

                    Yes the class view shows the members you declare in your derived class, but I don't think it shows the member variables in the base classes i.e. CWnd member variables. Andy

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #10

                    Nor would you want it to. The Workspace window would be way too crowded then. Intellisense, however, will show you the complete list of whatever object you happen to be working on.

                    A 1 Reply Last reply
                    0
                    • D David Crow

                      Nor would you want it to. The Workspace window would be way too crowded then. Intellisense, however, will show you the complete list of whatever object you happen to be working on.

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

                      :-) Thanks for all the help

                      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