|
|
|
| Помогите новичку.
Не могу найти функцию для получения char *p (или просто текста) из диалог бокса, т.е. что-то вроде
GetDlgItemInt должно быть но только для строк. | |
|
|
|
|
|
|
|
для: trix
(01.09.2008 в 01:29)
| | GetDlgItemText Function
--------------------------------------------------------------------------------
The GetDlgItemText function retrieves the title or text associated with a control in a dialog box.
Syntax
UINT GetDlgItemText( HWND hDlg,
int nIDDlgItem,
LPTSTR lpString,
int nMaxCount
);
Parameters
hDlg
[in] Handle to the dialog box that contains the control.
nIDDlgItem
[in] Specifies the identifier of the control whose title or text is to be retrieved.
lpString
[out] Pointer to the buffer to receive the title or text.
nMaxCount
[in] Specifies the maximum length, in TCHARs, of the string to be copied to the buffer pointed to by
lpString. If the length of the string, including the NULL character, exceeds the limit, the string is
truncated.
Return Value
If the function succeeds, the return value specifies the number of TCHARs copied to the buffer, not including the terminating NULL character.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
| |
|
|
|
|
|
|
|
для: GeorgeIV
(01.09.2008 в 17:08)
| | А вы бы не могли написать коротенький пример использования данной функции. Я ее уже находил, но не могу разобраться как ее использовать: вот пример кода где ее хочу использовать
void My_OnDlgCommand(HWND hwndDlg ,int id, HWND hwndCtrl, UINT codeNotify)
{
HWND hOwner;
hOwner = GetParent(hwndDlg);
switch(id)
{
case IDC_BUTTON1: //Нажали кнопку
WCHAR *tmp;
GetDlgItemText(hwndDlg,IDC_EDIT1,tmp,10); //В tmp ничего нет !!! Как правильно этой функцией пользоваться ?
break;
}
}
|
| |
|
|
|
|
|
|
|
для: trix
(01.09.2008 в 22:59)
| | Это реальный код? MFC используете? У вас реально приходит на это код, в отладчике смотрели?
И кроме того, у вас должно было обругать за использование неинициализированного указателя tmp, пытаетесь писать в буфер, которого нет.
Хотя бы так
TCHAR tmp[10]; | |
|
|
|
|
|
|
|
для: GeorgeIV
(01.09.2008 в 23:17)
| | Спасибо вы мне очень помогли! Краеугольный камень был: TCHAR tmp[10]; :)) MFC пока не использую, хотя он вроде попроще. | |
|
|
|