#include<windows.h>
int main()
{
HWND wnd;
wnd=FindWindow(NULL,"无标题.txt-记事本");
MoveWindow(wnd,0,0,220,120,NULL);
return 0;
}
为什么不能修改记事本的位置和大小?
#001 //
#002 // 响应命令.
#003 //
#004 //
#005 LRESULT CCaiWinMsg::OnCommand(int nID,int nEvent)
#006 {
#007 // 菜单选项命令响应:
#008 switch (nID)
#009 {
#010 case IDC_CREATEBTN:
#011 //显示一个按钮。
#012 if (!m_hBtn)
#013 {
#014 m_hBtn = CreateWindow(_T("BUTTON"),_T("按钮"),
#015 WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
#016 50,50,100,32,
#017 m_hWnd,(HMENU)IDC_BTN,m_hInstance,NULL);
#018 }
#019 break;
#020 case IDC_BTN:
#021 OutputDebugS www.hnnedu.com tring(_T("按钮按下\r\n"));
#022 {
#023 static bool bChangeText = true;
#024 if (bChangeText)
#025 {
#026 //设置按钮的文字。
#027 SetWindowText(m_hBtn,_T("改变它"));
#028
#029 //改变按钮窗口的位置和大小。
#030 MoveWindow(m_hBtn,10,10,100,32,TRUE);
#031 }
#032 else
#033 {
#034 //设置按钮的文字。
#035 SetWindowText(m_hBtn,_T("按钮"));
#036
#037 //改变按钮窗口的位置和大小。
#038 MoveWindow(m_hBtn,50,50,100,32,TRUE);
#039 }
#040
#041 //每一次都改变。
#042 bChangeText = !bChangeText;
#043 }
#044 break;
#045 default:
#046 return CCaiWin::OnCommand(nID,nEvent);
#047 }
#048
#049 return 1;
#050 }
#002 // 响应命令.
#003 //
#004 //
#005 LRESULT CCaiWinMsg::OnCommand(int nID,int nEvent)
#006 {
#007 // 菜单选项命令响应:
#008 switch (nID)
#009 {
#010 case IDC_CREATEBTN:
#011 //显示一个按钮。
#012 if (!m_hBtn)
#013 {
#014 m_hBtn = CreateWindow(_T("BUTTON"),_T("按钮"),
#015 WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
#016 50,50,100,32,
#017 m_hWnd,(HMENU)IDC_BTN,m_hInstance,NULL);
#018 }
#019 break;
#020 case IDC_BTN:
#021 OutputDebugS www.hnnedu.com tring(_T("按钮按下\r\n"));
#022 {
#023 static bool bChangeText = true;
#024 if (bChangeText)
#025 {
#026 //设置按钮的文字。
#027 SetWindowText(m_hBtn,_T("改变它"));
#028
#029 //改变按钮窗口的位置和大小。
#030 MoveWindow(m_hBtn,10,10,100,32,TRUE);
#031 }
#032 else
#033 {
#034 //设置按钮的文字。
#035 SetWindowText(m_hBtn,_T("按钮"));
#036
#037 //改变按钮窗口的位置和大小。
#038 MoveWindow(m_hBtn,50,50,100,32,TRUE);
#039 }
#040
#041 //每一次都改变。
#042 bChangeText = !bChangeText;
#043 }
#044 break;
#045 default:
#046 return CCaiWin::OnCommand(nID,nEvent);
#047 }
#048
#049 return 1;
#050 }
温馨提示:答案为网友推荐,仅供参考