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 send update text message with only standard windows library

How to send update text message with only standard windows library

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelptutorialannouncement
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.
  • T Offline
    T Offline
    theFrenchHornet
    wrote on last edited by
    #1

    I need to add a dialog to a project that only has available the Standard Windows Library. I am at the point where the dialog displays and the progress bar updates. I need to add changing the text in a Label. I don't know what command to send, and how to specify the text. The dialog is created with: HWND hwndProgressDialog = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DIALOG_EM), GetDesktopWindow(), EMProgressRoutine); Here is the code that updates the progress bar: hwndProgressBar = GetDlgItem(hwndProgressDialog, IDC_PROGRESS_EM); SendMessage(hwndProgressBar, PBM_SETPOS, (WPARAM)ProgressCount, 0); To update the lable text, I assume I get a handle to the Label ID in similar fashion and do another SendMessage. But, what is the comparable command to PBM_SETPOS for setting text and how to specify the text itself? Thanks for any help.

    M P 2 Replies Last reply
    0
    • T theFrenchHornet

      I need to add a dialog to a project that only has available the Standard Windows Library. I am at the point where the dialog displays and the progress bar updates. I need to add changing the text in a Label. I don't know what command to send, and how to specify the text. The dialog is created with: HWND hwndProgressDialog = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DIALOG_EM), GetDesktopWindow(), EMProgressRoutine); Here is the code that updates the progress bar: hwndProgressBar = GetDlgItem(hwndProgressDialog, IDC_PROGRESS_EM); SendMessage(hwndProgressBar, PBM_SETPOS, (WPARAM)ProgressCount, 0); To update the lable text, I assume I get a handle to the Label ID in similar fashion and do another SendMessage. But, what is the comparable command to PBM_SETPOS for setting text and how to specify the text itself? Thanks for any help.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You can use the SetWindowText() API (or use a WM_SETTEXT message directly) to set a control's text. Mark

      "If you can dodge a wrench, you can dodge a ball."

      T 2 Replies Last reply
      0
      • T theFrenchHornet

        I need to add a dialog to a project that only has available the Standard Windows Library. I am at the point where the dialog displays and the progress bar updates. I need to add changing the text in a Label. I don't know what command to send, and how to specify the text. The dialog is created with: HWND hwndProgressDialog = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DIALOG_EM), GetDesktopWindow(), EMProgressRoutine); Here is the code that updates the progress bar: hwndProgressBar = GetDlgItem(hwndProgressDialog, IDC_PROGRESS_EM); SendMessage(hwndProgressBar, PBM_SETPOS, (WPARAM)ProgressCount, 0); To update the lable text, I assume I get a handle to the Label ID in similar fashion and do another SendMessage. But, what is the comparable command to PBM_SETPOS for setting text and how to specify the text itself? Thanks for any help.

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

        theFrenchHornet wrote:

        hwndProgressBar = GetDlgItem(hwndProgressDialog, IDC_PROGRESS_EM); SendMessage(hwndProgressBar, PBM_SETPOS, (WPARAM)ProgressCount, 0);

        Mark Salsbery has already suggested you the right answer. I just wanted to suggest that, in case sending message to dialog items, you can use API SendDlgItemMessage. Your code will be reduce like this,

        SendDlgItemMessage(hwndProgressDialog,IDC_PROGRESS_EM,PBM_SETPOS, (WPARAM)ProgressCount, 0);

        Prasad MS MVP - VC++

        T 1 Reply Last reply
        0
        • M Mark Salsbery

          You can use the SetWindowText() API (or use a WM_SETTEXT message directly) to set a control's text. Mark

          "If you can dodge a wrench, you can dodge a ball."

          T Offline
          T Offline
          theFrenchHornet
          wrote on last edited by
          #4

          Thank you, Mark. SetWindowText works. Can you tell me, if I used the WM_SETTEXT in a SendMessage, how would I specify the text?

          1 Reply Last reply
          0
          • M Mark Salsbery

            You can use the SetWindowText() API (or use a WM_SETTEXT message directly) to set a control's text. Mark

            "If you can dodge a wrench, you can dodge a ball."

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

            Never mind. Figured it out.

            1 Reply Last reply
            0
            • P prasad_som

              theFrenchHornet wrote:

              hwndProgressBar = GetDlgItem(hwndProgressDialog, IDC_PROGRESS_EM); SendMessage(hwndProgressBar, PBM_SETPOS, (WPARAM)ProgressCount, 0);

              Mark Salsbery has already suggested you the right answer. I just wanted to suggest that, in case sending message to dialog items, you can use API SendDlgItemMessage. Your code will be reduce like this,

              SendDlgItemMessage(hwndProgressDialog,IDC_PROGRESS_EM,PBM_SETPOS, (WPARAM)ProgressCount, 0);

              Prasad MS MVP - VC++

              T Offline
              T Offline
              theFrenchHornet
              wrote on last edited by
              #6

              Thank you, Prasad. Your method looks more intuitive.

              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