How to send update text message with only standard windows library
-
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. -
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.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."
-
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.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 APISendDlgItemMessage
. Your code will be reduce like this,SendDlgItemMessage(hwndProgressDialog,IDC_PROGRESS_EM,PBM_SETPOS, (WPARAM)ProgressCount, 0);
Prasad MS MVP - VC++
-
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."
Thank you, Mark. SetWindowText works. Can you tell me, if I used the WM_SETTEXT in a SendMessage, how would I specify the text?
-
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."
Never mind. Figured it out.
-
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 APISendDlgItemMessage
. Your code will be reduce like this,SendDlgItemMessage(hwndProgressDialog,IDC_PROGRESS_EM,PBM_SETPOS, (WPARAM)ProgressCount, 0);
Prasad MS MVP - VC++
Thank you, Prasad. Your method looks more intuitive.