win_api基础(3) - 创建窗口
(一) 环境
CLion + Cygwin
CLion
: 代码编辑,提供代码提示和代码补全等功能,方便api
学习,不一定要看win api 文档,Ctrl + p
快捷键提示参数,右键可以跳到函数/常量的定义。
Cygwin
: 简单地认为是可以把Linux软件包
移植到windows上。(Mingw类似)
安装完Cygwin
后需要安装编译相关的软件:gcc g++ make cmake gdb
,这边使用清华源
加快下载:https://mirrors.tuna.tsinghua.edu.cn/cygwin/
(二) 创建自己的窗口
#include <windows.h>
#include <tchar.h>
const TCHAR CLSNAME[] = TEXT("helloworldWClass");
LRESULT CALLBACK winproc(HWND hwnd, UINT wm, WPARAM wp, LPARAM lp);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PTSTR cmdline, int cmdshow)
{
WNDCLASSEX wc = {
}; // fill in the window class structure
MSG msg; //
HWND hwnd;
wc.cbSize = sizeof (wc); // size, in bytes
wc.style = 0; //The window class styles. This is 0 for now
wc.lpfnWndProc = winproc; // It stores the address of the window procedure. The window procedure is a function that handles events for all windows that are instances of this window class.
wc.cbClsExtra = 0; //extra bytes to allocate for the window class
wc.cbWndExtra = 0; // extra by