Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting the text of an Edit Box control on a dialog 1

Status
Not open for further replies.

Dreadson

Instructor
Jun 11, 2003
63
US
I would like to have the text of an Edit Box on a dialog that pops up to be set at that time. However, my code seems to be useless. It compiles with no errors or warnings but doesn't do anything. Here is my code:

// Mesage handler for New File box.
LRESULT CALLBACK NewFileDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{

char word[6]={'h','e','l','l','o','\0'}; //The string to be set into the edit box control


switch (message)
{
case WM_INITDIALOG:

SendMessage(
(HWND) IDC_MEASURES, //The edit box control
(UINT) WM_SETTEXT,
(WPARAM) wParam,
(LPARAM) lParam = *word
);

return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;

}
return FALSE;
}

I'm a beginning programmer so please tell me if I'm doing all of this wrong.
 
You can't just cast your ID to a HWND, that won't work at all. You need to call GetDlgItem to get the HWND for that ID. Also, your lParam = *word line is confusing. There is no need to reassign lParam, and what exactly is word? Just do this:

char* text = "asdf";
SetWindowText(GetDlgItem(hDlg, IDC_MEASURES), text);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top