VC MFC对话框有多个Edit控件,只更新其中一个Edit控件的显示(已设置对应的int变量),

2024-11-29 10:04:36
推荐回答(2个)
回答1:

那只有SetWindowText等类似的API,SetDlgItemText和SetDlgItemInt后面其实也是调用的SetWindowText

SetWindowText调用的是
SendMessage(hWnd,WM_SETTEXT,0,text);

SetWindowText的源码(from reactos)
BOOL WINAPI
SetWindowTextW(HWND hWnd,
LPCWSTR lpString)
{
PWND pwnd;

pwnd = ValidateHwnd(hWnd);
if (pwnd)
{
if (!TestWindowProcess(pwnd))
{
/* do not send WM_GETTEXT messages to other processes */
return (DefWindowProcW(hWnd, WM_SETTEXT, 0, (LPARAM)lpString) >= 0);
}
return (SendMessageW(hWnd, WM_SETTEXT, 0, (LPARAM)lpString) >= 0);
}
return FALSE;
}

回答2:

可以写在初始化函数里