那只有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;
}
可以写在初始化函数里