|
希望,老师能根据win10系统做一下课程上的教学的补充
毕竟现在已经是2020年了。
- BOOL Win_SetPosSize(HWND hwd, int left=NULL, int top=NULL, int newWidth = NULL, int newHight = NULL)
- {
- RECT rect;
- GetWindowRect(hwd, &rect);
-
- if (left==NULL)
- {
- left = rect.left;
- }
- if (top== NULL)
- {
- top = rect.top;
- }
- if (newWidth == NULL)
- {
- newWidth =rect.right - rect.left;
- }
- if (newHight == NULL)
- {
- newHight = rect.bottom - rect.top;
- }
- return MoveWindow(hwd, left, top, newWidth, newHight, TRUE);
- }
- void CDlgTestDlg::OnBnClickedButton7()
- {
-
- //HWND hdl=::FindWindow(_T("QWidget"),_T("金山词霸2016"));
- //Windows.UI.Core.CoreWindow
-
- //HWND hdl = ::FindWindow(_T("ApplicationFrameWindow"), _T("计算器"));
- HWND hdl = ::FindWindowExA(NULL,NULL,"ApplicationFrameWindow", "计算器");
- //HWND hdl = ::FindWindowExA(NULL, NULL, "Windows.UI.Core.CoreWindow", "计算器");
- //HWND hdl = ::FindWindowEx(NULL,NULL,_T("ApplicationFrameWindow"), _T("计算器")); //获取不到
- //疑问:为什么用 FindWindowEx 获取不到 正确的窗口句柄?
-
- //RECT ret;
- //int newWide, newHight;
- if (hdl)
- {
- //::SetWindowText(hdl, _T("VC驿站 专用计算器!"));
- /*HWND hEdit = ::FindWindowEx(hdl, NULL, _T("Edit"), NULL);
- ::SetWindowText(hEdit, _T("1234567890"));*/
- //::SendMessage(hdl, WM_SETTEXT, 0, (LPARAM)_T("VC驿站 专用计算器!"));
- Win_SetPosSize(hdl, 5, 5);
- DWORD dwPID=0;
- GetWindowThreadProcessId(hdl,&dwPID);
- CString strPID;
- strPID.Format(_T("PID=%d"), dwPID);
- MessageBox(strPID);
- /*::GetWindowRect(hdl, &ret);
- newWide = ret.right - ret.left;
- newHight = ret.bottom- ret.top ;
- ::MoveWindow(hdl,0,0,newWide,newHight,TRUE);*/
- //::SetWindowText(hdl, _T("筋斗云是孙悟空的"));
- }
- }
复制代码
|
上一篇: win32 c++ socket怎么发送utf8的中文下一篇: 23课求助
|