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. a simple VC++ scrolling display

a simple VC++ scrolling display

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestionannouncement
5 Posts 4 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
    Alan Kurlansky
    wrote on last edited by
    #1

    I want to begin to learn how to do visual gui programs in VC++. I am good with c/c++. To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window. The window should automatically scroll down as new messages are added. But the user should have the ability to scroll back as well. Any suggestions on how to approach this? Also, as a follow on project I'll want to display data in row/column format and be able to update cells as changes are received over a tcp connection. Thanks

    M L M 3 Replies Last reply
    0
    • A Alan Kurlansky

      I want to begin to learn how to do visual gui programs in VC++. I am good with c/c++. To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window. The window should automatically scroll down as new messages are added. But the user should have the ability to scroll back as well. Any suggestions on how to approach this? Also, as a follow on project I'll want to display data in row/column format and be able to update cells as changes are received over a tcp connection. Thanks

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

      Do you know how to do the "receive tcp message" stuff (code and implementation) ? if you know how to do that, then the rest is quite simple. Create a worker thread that will receive the data; when the data is received, send a message to the main UI thread ( Create a simple UI thread (main UI, do not create and manage UI in the worker thread)that contains either a CListBox or a CListCtrl. implement handlers for the messages sent by the worker thread. good luck. M.

      Watched code never compiles.

      A 1 Reply Last reply
      0
      • M Maximilien

        Do you know how to do the "receive tcp message" stuff (code and implementation) ? if you know how to do that, then the rest is quite simple. Create a worker thread that will receive the data; when the data is received, send a message to the main UI thread ( Create a simple UI thread (main UI, do not create and manage UI in the worker thread)that contains either a CListBox or a CListCtrl. implement handlers for the messages sent by the worker thread. good luck. M.

        Watched code never compiles.

        A Offline
        A Offline
        Alan Kurlansky
        wrote on last edited by
        #3

        Thanks. Anything I need to be careful to select or not to select when I create the project in VC? When you say implement handlers, do you mean each message gets it own handle and is processed from that perspective?

        1 Reply Last reply
        0
        • A Alan Kurlansky

          I want to begin to learn how to do visual gui programs in VC++. I am good with c/c++. To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window. The window should automatically scroll down as new messages are added. But the user should have the ability to scroll back as well. Any suggestions on how to approach this? Also, as a follow on project I'll want to display data in row/column format and be able to update cells as changes are received over a tcp connection. Thanks

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

          I would suggest you forget about the TCP stuff until you have mastered the text viewer and scrolling. Whether you use simple Win32 or MFC this can be quite a challenge and TCP would only complicate matters. Start with a view window and add the scroll features then add a mechanism to send some lines of text, say up to 100 and see that your scrolling is working. Then when you have all those features under control you can start to add the more complex pieces of the TCP feed.

          It's time for a new signature.

          1 Reply Last reply
          0
          • A Alan Kurlansky

            I want to begin to learn how to do visual gui programs in VC++. I am good with c/c++. To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window. The window should automatically scroll down as new messages are added. But the user should have the ability to scroll back as well. Any suggestions on how to approach this? Also, as a follow on project I'll want to display data in row/column format and be able to update cells as changes are received over a tcp connection. Thanks

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

            Alan Kurlansky wrote:

            To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window.

            Hi Alan! I suggest an alternative approach without multi threading to get up and running quickly: 1) create a new MFC project and add a CListBox control: Using the CListBox control[^], this comes with a working example dialog project. 2) Add a TCP client socket such as CAsyncSocket to your dialog: Socket Programming with MFC (Part 1)[^], this will also explain which initialisation is needed in your application. 3) Add a button to your dialog so you can connect/disconnect to a server. The client will tell you in its OnReceive()[^] handler when more data is available, you can add this to the listbox with AddString()[^] and scroll listbox with SendMessage(WM_VSCROLL, SB_BOTTOM, NULL). There are many ways to communicate between socket and GUI, for starters you could give the socket object a pointer to your dialog. For example with a method OnReceiveText() that you call from your socket whenever a full text line is available:

            // Add text to end of listbox and remove old text
            void CMyDlg::OnReceiveText(const char* szText)
            {
            m_listbox.AddString(szText);
            m_output.SendMessage(WM_VSCROLL, SB_BOTTOM, NULL);
            while(m_output.GetCount() > 10000) m_output.DeleteString(0);
            }

            Hope this helps :) /Moak

            Webchat in Europe :java: Now with 26% more Twitter

            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