- 8
- 0
- 约2.02千字
- 约 3页
- 2017-06-07 发布于重庆
- 举报
9如何修改MFCAppWizard向导生成的框架程序的外观和大小
窗口的外观可以在BOOL CMainFrame::PreCreateWindow CREATESTRUCT cs 中进行修改,是子类的继承方式。
cs.style ~FWS_ADDTOTITLE;对标题等进行修改必须要用到这些东西。 cs.style WS_OVERLAPPEDWINDOW;
在窗口创建之后修改窗口的外观:setwindowlong和Setwindowlong
AfxGetInstanceHandle? 返回应用程序当前句柄
DefWindowProc 此函数有在sdk和mfc不同的平台下的不同的形式,注意区别。
修改图标在框架窗口中修改,修改背景和鼠标在view窗口中修改。
AfxRegisterWndClass 注册窗口类注意其中的缺省项,用来简易改变窗口。如果在函数的参数取值时用的不是0而是缺省值,那么窗口的设置不是原来设置,具体参照msdn。
改变的另外方法,在之后改变,窗口创建之后,用SetClassLong 。
MAKEINTRESOURCE 转换资源的宏,具体说明查看msdn
获得实例句柄的方式:(3种)
1. AfxGetInstanceHandle? 返回应用程序当前句柄
2. CWinApp Class Members 中的一个成员函数,CWinApp::m_hInstance是当前句柄。在mfc中的app文件中含有次变量,在framework中引用的时候要声明外部变量.
Extern 声明是引用另外一个源文件的变量,而不是重新定义新的变量。
3. AfxGetApp?
了解框架窗口时怎样创建工具栏的:
视频位置:5-9200到 7-1974
方法一:
Create a toolbar resource.
Construct the CToolBar object.
Call the Create or CreateEx function to create the Windows toolbar and attach it to the CToolBar object.
Call LoadToolBar to load the toolbar resource.
方法2:
Construct the CToolBar object.
Call the Create or CreateEx function to create the Windows toolbar and attach it to the CToolBar object.
Call LoadBitmap to load the bitmap that contains the toolbar button images.
Call SetButtons to set the button style and associate each button with an image in the bitmap.
CControlBar::EnableDocking 用来让工具栏可以停靠
CFrameWnd::EnableDocking 用来允许框架窗口可以被停靠
CFrameWnd::DockControlBar 停靠控制按钮
CFrameWnd::RecalcLayout? 工具栏窗口显示或隐藏后,用来调整工具栏的状态
CFrameWnd::ShowControlBar
状态栏:
CStatusBar 类的内容
Ctime 时间的类。
CStatusBar::SetPaneText 设置状态栏的字符
CStatusBar::CommandToIndex Gets index for a given indicator ID.
CStatusBar::SetPaneInfo Sets indicator ID, style, and width for a given index.
进度栏:
CProgressCtrl 进度控制类。
这个类中的create成员函数
CProgressCtrl::SetPos Sets the current position for a progress bar control and redraws the bar to reflect the new position.
在状态栏的某个矩形区域创建进度栏。
具体的实现方法是:获得状态栏某个状态信息所在的位置的矩形区域。以及大小。在次区域创建这个进度栏。
CStatusBar 类中有一个成员函数:CStatusBar::GetItemRect 获得项目的矩形区域。
WM_USER宏,
CFrameWnd::SetMessageText 直接在状态栏上放置文本
CWnd::Get
原创力文档

文档评论(0)