Archived

This topic is now archived and is closed to further replies.

VC++ DialogBox()

This topic is 5239 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I created the proper resource.rc file with an about box which contains: one edit box called IDC_EDIT1, one OK and one CANCEL button. I''d like to get the value entered in the edit box after pressing on ''OK''. I open the edit box with the following instruction: nret=DialogBox(hInstance, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);

Share this post


Link to post
Share on other sites
in your About callback function - intercept the WM_COMMAND message and put this...



case WM_COMMAND :

if ( LOWORD( wParam ) == IDOK )
{
char text[ 1024 ];

GetDlgItemText ( hwnd, IDC_EDIT1, text, sizeof(text) );
}

return FALSE;




with that code, the text entered will be in the variable "text". If you need to get the number of characters so you can dynamically allocate the array - do this..



int bytes = SendDlgItemMessage ( hwnd, IDC_EDIT1, WM_GETTEXTLENGTH, 0, 0 );

char * text = new char [ bytes + 1 ];



hope that helped!



White space is free - so use it!!!

[edited by - TrapZZ on August 9, 2003 11:28:36 AM]

Share this post


Link to post
Share on other sites