窗口创建之前:
BOOLCMainFrame::PreCreateWindow(CREATESTRUCT& cs)
cs.cx=300; cs.cy=500; //窗口大小
cs.lpszName=”定制应用程序外观”;
cs.style=WS_OVERLAPPEDWINDOW; 或 cs.style &=~FWS_ADDTOTITLE;
窗口创建之后:
SetWindowLong(m_hWnd,GWL_STYLE,WS_OVERLAPPEDWINDOW);//改变窗口类型
在已有类型上进行修改:
SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)&~WS_MAXIMIZEBOX); //去掉窗口的最大化功能
窗口创建修改视类窗口:
cs.lpszClass=AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,LoadCursor(NULL,IDC_CROSS),(HBRUSH)GetStockObject(BLACK_BRUSH),0);
窗口创建后修改光标、图标:
SetClassLong():重置指定窗口所属类中指定数据成员的属性;
(1)插入图标资源;
(2)定义HICON类型的图标句柄数组成员变量,m_hIcons[3];
(3)加载图标;
m_hIcons[0]=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON1));
m_hIcons[1]=LoadIcon(theApp.m_hInstance,MAKEINTRESOURCE(IDI_ICON2));
m_hIcons[2]=LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON3));
SetClassLong(m_hWnd,GCL_HICON,(LONG)m_hIcons[0]);
SetTimer(1,1000,NULL);
(1) 定时器函数实现;
voidCMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code hereand/or call default
static int index=0;
SetClassLong(m_hWnd,GCL_HICON,(LONG)m_hIcons[index]);
index=++index%3;
CFrameWnd::OnTimer(nIDEvent);
}
(6)消息响应COMMAND 和 UPDATE_COMMAND_UI的区别
ON_COMMAND是点了按钮或菜单项后的响应消息,
ON_UPDATE_COMMAND_UI是用来表示对应的按钮和菜单项的状态的响应消息.