Notsosuperhero
December 21st, 2004, 08:32 PM
How would I get the text in a textbox in a dialog box to a TCHAR or LPSTR to be able to add to a list box on the Parent Window?
|
Click to See Complete Forum and Search --> : TextBox Notsosuperhero December 21st, 2004, 08:32 PM How would I get the text in a textbox in a dialog box to a TCHAR or LPSTR to be able to add to a list box on the Parent Window? NoHero December 22nd, 2004, 01:58 AM By using the GetDlgItemText() function: TCHAR szBuff[256] = ""; // Size it here, if you expect longer strings than that GetDlgItemText(hDlg, IDC_YOUR_EDIT_BOX, szBuff, sizeof(szBuff)); Where hDlg is the HWND of your dialog and IDC_* the ID of your edit control. After this call you will find the text of the edit box in szBuff. Boris K K December 22nd, 2004, 04:37 AM Actually if TCHAR happens to be WCHAR the calculation of buffer length should be sizeof szBuff / sizeof szBuff[0] NoHero December 22nd, 2004, 07:23 AM Of course thank you for correcting me. In addition you can also define the size as a macro: #define BUFFER_SIZE 256 TCHAR szBuff[BUFFER_SIZE] = ""; GetDlgItemText(hDlg, IDC_MY_EDIT_BOX, szBuff, BUFFER_SIZE); So additional resizing of the buffer size will be easy by just modifing the macro. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |