Jump to content
  • Advertisement


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


VC++ DialogBox()

This topic is 5527 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...


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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!