1、main与wWinMain区别
main是win32控制台程序的程序入口
wWinMain是win32 GUI控制台程序的程序入口
一般来说,待有GUI的都会出现界面
看一个函数声明:
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow);
前面有一个宏APIENTRY,用来指定调用约定
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define WINAPIV __cdecl
#define APIENTRY WINAPI
#define APIPRIVATE __stdcall
#define PASCAL __stdcall
2、编译好CEF3的代码
从官网下载好代码之后,文件夹下有个CMakeLists.txt
重新建一个文件夹,按住shift后右键,打开命令行,输入cmake命令:
cmake CEFfilepath -G "Visual Studio 12 2013"
CEFfilepath是你下载的cef代码的绝对路径,Visual Studio 12 2013是你用的vs版本,我用的2013,完成后打开文件夹下的.sln文件就编译好可以运行啦,总共有这5个工程
3、创建一个win32application工程,系统自动生成代码:
#include "stdafx.h"
#include "MyBroswer.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_MYBROSWER, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MYBROSWER));
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
有个变量MSG msg;是操作系统的消息机制,定义是:
typedef struct tagMSG {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
#ifdef _MAC
DWORD lPrivate;
#endif
} MSG, *PMSG, NEAR *NPMSG, FAR *LPMSG;
hand表示一个窗口的句柄
message用一个无符号整形表示消息,通常用宏表示
wParam和lParam都是一个整数,右键时wParam表示消息的附加信息
lParam表示键盘按键后获取的键盘信息
pt定义为
typedef struct tagPOINT
{
LONG x;
LONG y;
} POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT;
可表示坐标,或者宽高
明天继续写,下班啦啦啦啦啦啦啦~