《把脉VC++》
Chap 2
Q:VC6对template/STL等支持非常差?
#include <cstdio> vs. #include <stdio.h>
C函数会置于全局名字空间std中。
Chap 3.
TCHAR = char/wchar_t
Chap 3. 常见对象的表达
引用只是一个别名。
_intN(_int8, _int16)VC++专有整数数据类型
《Windows Programming》V2
Chap 6. Windows
1. WinMain()
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
ASSERT(hPrevInstance == NULL);
int nReturnCode = -1;
CWinThread* pThread = AfxGetThread();
CWinApp* pApp = AfxGetApp();
// 类库框架内部的初始化
if(!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
goto InitFailure;
// 应用程序的全局初始化
if(pApp != NULL && !pApp->InitApplication())
goto InitFailure;
// 主线程的初始化
if(!pThread->InitInstance())
{
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
// 开始与用户交互
nReturnCode = pThread->Run();
InitFailure:
return nReturnCode;
}
Q:pThread与pApp是不是同样一个object?(因为pApp也是一种CWinThread)
2. CMyApp::InitInstance()
///
// CMyApp成员函数的实现代码
BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyWnd;
::ShowWindow(*m_pMainWnd, this->m_nCmdShow);
::UpdateWindow(*m_pMainWnd);
return TRUE; // 返回TRUE进入消息循环
}
注:在这里,CWinApp与CWnd发生关系
Q::;ShowMainWnd()是哪一个函数?似乎不太对?
3. CMyWnd::CMyWnd()
///
// CMyWnd成员函数的实现代码
CMyWnd::CMyWnd()
{
LPCTSTR lpszClassName = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,
::LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_3DFACE+1));
CreateEx(WS_EX_CLIENTEDGE, lpszClassName,
"框架程序创建的窗口", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL);
}
注:窗口类注册与窗口生成