WNDCLASS属性style取值: CS_GLOBALCLASS--应用程序全局窗口类 CS_BYTEALIGNCLIENT--窗口客户区的水平位置8倍数对齐 CS_BYTEALIGNWINDOW--窗口的水平位置8倍数对齐 CS_HREDRAW--当窗口水平变化时,窗口重新绘制 CS_VREDRAW--当窗口垂直变化时,窗口重新绘制 CS_CLASSDC--该类型的窗口,都是有同一个绘图(DC)设备 CS_PARENTDC--该类型的窗口,使用他的父窗口的绘图(DC)设备 CS_OWNDC--该类型的窗口,每个窗口都使用自己的绘图(DC)设备 CS_SAVEBITS--允许窗口保存成图(位图),提高窗口的绘图效率,但是耗费内存资源 CS_DBLCLKS--允许窗口接收鼠标左键双击 CS_NOCLOSE--窗口没有关闭按钮
CreateWindow实现原理 1.系统根据传入的窗口类名称,在应用程序局部窗口类中查找,如果找到执行步骤2,如果未找到,执行步骤3; 2.比较局部窗口类与创建窗口时传入的HINSTANCE变量,如果发现相等,创建和注册窗口类在同一模块,创建窗口返回,如果不相等,继续执行步骤3; 3.在应用程序全局窗口类,如果找到,执行步骤4,如果未找到执行步骤5 4.使用找到的窗口类的信息,创建窗口返回。 5.在系统窗口类中查找,如果找到创建窗口返回,否则创建窗口失败。
HWND CreateWindowEx( DWORD dwExStyle,//窗口的扩展风格 LPCTSTR lpClassName,//已经注册的窗口类名称 LPCTSTR lpWindowName,//窗口标题栏名字 DWORD dwStyle,//窗口的基本风格 int x,//窗口左上角水平坐标位置 int y,//窗口左上角垂直坐标位置 int nWidth,//窗口的宽度 int nHeight,//窗口的高度 HWND hWndParent,//窗口的父窗口句柄 HMENU hMenu,//窗口菜单句柄 HINSTANCE hInstance,//应用程序实例句柄 LPVOID lpParam//窗口创建时附加参数 );创建成功返回窗口句柄
WS_BORDER--The window has a thin-line border.(主体与边框间存在黑色边界线) WS_CAPTION--The window has a title bar (includes the WS_BORDER style).(标题栏风格) WS_CHILD--The window is a child window. A window with this style cannot have a menu bar.
This style cannot be used with the WS_POPUP style.(子窗口风格-子窗口必须使用该风格,并且父窗口句柄必须有值) WS_CHILDWINDOW--Same as the WS_CHILD style. WS_CLIPCHILDREN--Excludes the area occupied by child windows when drawing occurs within the parent window.
This style is used when creating the parent window.(切割窗口) WS_CLIPSIBLINGS--Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message,
the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated.
If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window,
to draw within the client area of a neighboring child window.(切割窗口) WS_DISABLED--The window is initially disabled. A disabled window cannot receive input from the user.
To change this after a window has been created, use the EnableWindow function.(窗口不可用) WS_DLGFRAME--The window has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar.(对话框) WS_GROUP--The window is the first control of a group of controls. The group consists of this first control and all controls defined after it,
up to the next control with the WS_GROUP style.
The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group.
The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. You can turn this style on and off to change dialog box navigation.
To change this style after a window has been created, use the SetWindowLong function.(分组风格,两窗口互斥,类似于单选框) WS_HSCROLL--The window has a horizontal scroll bar.(水平滚动条) WS_ICONIC--The window is initially minimized. Same as the WS_MINIMIZE style.(窗口创建出来,处于最小化状态) WS_MAXIMIZE--The window is initially maximized.(窗口创建出来,处于最大化状态) WS_MAXIMIZEBOX--The window has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style.
The WS_SYSMENU style must also be specified.(窗口有最大化按钮) WS_MINIMIZE--The window is initially minimized. Same as the WS_ICONIC style. WS_MINIMIZEBOX--The window has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style.
The WS_SYSMENU style must also be specified.(窗口有最小化按钮) WS_OVERLAPPED--The window is an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style.(交叠窗口) WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) The window is an overlapped window. Same as the WS_TILEDWINDOW style. WS_POPUP--The windows is a pop-up window. This style cannot be used with the WS_CHILD style.(弹出对话框风格) WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU) The window is a pop-up window. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible.(弹出对话框风格) WS_SIZEBOX--The window has a sizing border. Same as the WS_THICKFRAME style.(可改变窗口大小的边框) WS_SYSMENU--The window has a window menu on its title bar. The WS_CAPTION style must also be specified.(系统菜单) WS_TABSTOP The window is a control that can receive the keyboard focus when the user presses the TAB key.
Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. You can turn this style on and off to change dialog box navigation.
To change this style after a window has been created, use the SetWindowLong function.
For user-created windows and modeless dialogs to work with tab stops, alter the message loop to call the IsDialogMessage function.(可以用tab键切换) WS_THICKFRAME--The window has a sizing border. Same as the WS_SIZEBOX style. WS_TILED--The window is an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPED style. WS_TILEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) The window is an overlapped window. Same as the WS_OVERLAPPEDWINDOW style. WS_VISIBLE The window is initially visible. This style can be turned on and off by using the ShowWindow or SetWindowPos function.(显示窗口,一般应用于子窗口) WS_VSCROLL--The window has a vertical scroll bar.(垂直滚动条窗口)