VC++状态栏创建问题!会的进来下!

2025-02-26 02:30:05
推荐回答(2个)
回答1:

要我说呀,没什么区别的,我们一般创建的状态栏不会太花里胡哨的,都是差不多的形状差不多额功能。在MSDN中搜索了一下,又在VC安装盘中搜索了,胡乱得出了以下结论

CStatusBarCtrl的Create函数定义,通过调用CWnd的Create方法。位置:C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\WINCTRL2.CPP

BOOL CStatusBarCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID)
{
// initialize common controls
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_BAR_REG));

CWnd* pWnd = this;
return pWnd->Create(STATUSCLASSNAME, NULL, dwStyle, rect, pParentWnd, nID);
}

而CWnd::Create调用的是sdk函数 ::CreateWindowEx(cs.dwExStyle, cs.lpszClass,
cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);
位置在C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\WINCORE.CPP

而CreateStatusWindow这个函数:The CreateStatusWindow function calls the"CreateWindow" function to create the window. 而这个CreateWindow是sdk的一个api函数

有上分析可见,二者都是调用了sdk函数,前者为CreateWindowEx,后者为CreateWindow。
The CreateWindowEx function creates an overlapped, pop-up, or child window with an extended style; otherwise, this function is identical to the CreateWindow function. 意思是说,CreateWindowEx除了可创建扩展风格的窗口之外,和CreateWindow是等价的。
下面是两个函数的原型
HWND CreateWindowEx(
DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu, or child-window identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);
比CreateWindow多了一个参数DWORD dwExStyle
HWND CreateWindow(
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu or child-window identifier
HANDLE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);

回答2:

模态对话框和非模态对话框学了没?创建非模态对话框是就要用到Create()函数,我想原理应该一样,用Create()函数创建的状态栏,在关闭窗口时要用delete删掉,而你说的::CreateStatusWindow(); 把这一过程包括在里面一起完成了,具体的,你可以去MSDN里查查,这个好久没用到了不好意思,自己斟酌吧~