Click to See Complete Forum and Search --> : Dialog problem


Alert123456
September 22nd, 2005, 04:15 AM
On my dialog, i add a static text wtih a space large enough to hold up to 20 chars and 20 lines, a square (20x20)!


I will type down a long string in my windowclient area and I want this string to appear inthat dialog static text, (that square) when i call this dialog.


I am looking for a way to do thhat but haven't found it yet,

I hope I'll find you.


Thank you

Anaidni~

philkr
September 22nd, 2005, 09:22 AM
First of all you need to change the ID of the text control to something else. It can be anything, but not IDC_STATIC (for example IDC_TEXT).
When you create your dialog you can set the LPARAM parameter to the text you want to show.

char strText[] = "Here is your string"
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, &DialogProc, (LPARAM)strText);

In the DialogProc() on WM_INITDIALOG you set the control text using SetDlgItemText():

// ...
case WM_INITDIALOG:
SetDlgItemText(hDlg, IDC_TEXT, (LPSTR)lParam);
break;