先说: CStatic这个类没有Createx这个成员函数然后virtual BOOL Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff ); Parameters lpszText Specifies the text to place in the control. If NULL, no text will be visible. dwStyle Specifies the static control's window style. Apply any combination of static control styles to the control. rect Specifies the position and size of the static control. It can be either a RECT structure or a CRect object. pParentWnd Specifies the CStatic parent window, usually a CDialog object. It must not be NULL. nID Specifies the static control's control ID. Return Value Nonzero if successful; otherwise 0.Res Construct a CStatic object in two steps. First, call the constructor CStatic, and then call Create, which creates the Windows static control and attaches it to the CStatic object. Apply the following window styles to a static control: WS_CHILD Always WS_VISIBLE Usually WS_DISABLED Rarely If you're going to display a bitmap, cursor, icon, or metafile in the static control, you'll need to apply one of the following static styles: SS_BITMAP Use this style for bitmaps. SS_ICON Use this style for cursors and icons. SS_ENHMETAFILE Use this style for enhanced metafiles. For cursors, bitmaps, or icons, you may also want to use the following style: SS_CENTERIMAGE Use to center the image in the static control. Example CStatic myStatic;// Create a child static control that centers its text horizontally. myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(10,10,150,50), pParentWnd); 需要翻译吗?
virtual BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam = NULL);CreateEx比Create多了1个参数DWORD dwExStyle,其中最主要的是一些扩展窗体风格的支持,Create不支持扩展风格。dwExStyleSpecifies the extended style of the CWnd being created. Apply any of the extended window styles to the window. Extended Window Styles WS_EX_ACCEPTFILES Specifies that a window created with this style accepts drag-and-drop files. WS_EX_CLIENTEDGE Specifies that a window has a 3D look — that is, a border with a sunken edge. WS_EX_CONTEXTHELP Includes a question in the title bar of the window. When the user clicks the question , the cursor changes to a question with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. WS_EX_CONTROLPARENT Allows the user to navigate among the child windows of the window by using the TAB key. WS_EX_DLGMODALFRAME Designates a window with a double border that may (optionally) be created with a title bar when you specify the WS_CAPTION style flag in the dwStyle parameter. WS_EX_LEFT Gives window generic left-aligned properties. This is the default. WS_EX_LEFTSCROLLBAR Places a vertical scroll bar to the left of the client area. WS_EX_LTRREADING Displays the window text using left-to-right reading order properties. This is the default. WS_EX_MDICHILD Creates an MDI child window. WS_EX_NOPARENTNOTIFY Specifies that a child window created with this style will not send the WM_PARENTNOTIFY message to its parent window when the child window is created or destroyed. WS_EX_OVERLAPPEDWINDOW Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles WS_EX_PALETTEWINDOW Combines the WS_EX_WINDOWEDGE and WS_EX_TOPMOST styles. WS_EX_RIGHT Gives a window generic right-aligned properties. This depends on the window class. WS_EX_RIGHTSCROLLBAR Places a vertical scroll bar (if present) to the right of the client area. This is the default. WS_EX_RTLREADING Displays the window text using right-to-left reading order properties. WS_EX_STATICEDGE Creates a window with a three-dimensional border style intended to be used for items that do not accept user input. WS_EX_TOOLWINDOW Creates a tool window, which is a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB. WS_EX_TOPMOST Specifies that a window created with this style should be placed above all nontopmost windows and stay above them even when the window is deactivated. An application can use the SetWindowPos member function to add or remove this attribute. WS_EX_TRANSPARENT Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated. WS_EX_WINDOWEDGE Specifies that a window has a border with a raised edge.
CStatic这个类没有Createx这个成员函数然后virtual BOOL Create(
LPCTSTR lpszText,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID = 0xffff
);
Parameters
lpszText
Specifies the text to place in the control. If NULL, no text will be visible.
dwStyle
Specifies the static control's window style. Apply any combination of static control styles to the control.
rect
Specifies the position and size of the static control. It can be either a RECT structure or a CRect object.
pParentWnd
Specifies the CStatic parent window, usually a CDialog object. It must not be NULL.
nID
Specifies the static control's control ID.
Return Value
Nonzero if successful; otherwise 0.Res
Construct a CStatic object in two steps. First, call the constructor CStatic, and then call Create, which creates the Windows static control and attaches it to the CStatic object. Apply the following window styles to a static control: WS_CHILD Always
WS_VISIBLE Usually
WS_DISABLED Rarely
If you're going to display a bitmap, cursor, icon, or metafile in the static control, you'll need to apply one of the following static styles: SS_BITMAP Use this style for bitmaps.
SS_ICON Use this style for cursors and icons.
SS_ENHMETAFILE Use this style for enhanced metafiles.
For cursors, bitmaps, or icons, you may also want to use the following style: SS_CENTERIMAGE Use to center the image in the static control.
Example
CStatic myStatic;// Create a child static control that centers its text horizontally.
myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(10,10,150,50), pParentWnd);
需要翻译吗?
CView的 Create不仅建立的窗口,而且建立了 Document/View联系,如果用CreateEx,这种联系没被正确建立。
BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam = NULL);CreateEx比Create多了1个参数DWORD dwExStyle,其中最主要的是一些扩展窗体风格的支持,Create不支持扩展风格。dwExStyleSpecifies the extended style of the CWnd being created. Apply any of the extended window styles to the window. Extended Window Styles
WS_EX_ACCEPTFILES Specifies that a window created with this style accepts drag-and-drop files.
WS_EX_CLIENTEDGE Specifies that a window has a 3D look — that is, a border with a sunken edge.
WS_EX_CONTEXTHELP Includes a question in the title bar of the window. When the user clicks the question , the cursor changes to a question with a pointer. If the user then clicks a child window, the child receives a WM_HELP message.
WS_EX_CONTROLPARENT Allows the user to navigate among the child windows of the window by using the TAB key.
WS_EX_DLGMODALFRAME Designates a window with a double border that may (optionally) be created with a title bar when you specify the WS_CAPTION style flag in the dwStyle parameter.
WS_EX_LEFT Gives window generic left-aligned properties. This is the default.
WS_EX_LEFTSCROLLBAR Places a vertical scroll bar to the left of the client area.
WS_EX_LTRREADING Displays the window text using left-to-right reading order properties. This is the default.
WS_EX_MDICHILD Creates an MDI child window.
WS_EX_NOPARENTNOTIFY Specifies that a child window created with this style will not send the WM_PARENTNOTIFY message to its parent window when the child window is created or destroyed.
WS_EX_OVERLAPPEDWINDOW Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles
WS_EX_PALETTEWINDOW Combines the WS_EX_WINDOWEDGE and WS_EX_TOPMOST styles.
WS_EX_RIGHT Gives a window generic right-aligned properties. This depends on the window class.
WS_EX_RIGHTSCROLLBAR Places a vertical scroll bar (if present) to the right of the client area. This is the default.
WS_EX_RTLREADING Displays the window text using right-to-left reading order properties.
WS_EX_STATICEDGE Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
WS_EX_TOOLWINDOW Creates a tool window, which is a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB.
WS_EX_TOPMOST Specifies that a window created with this style should be placed above all nontopmost windows and stay above them even when the window is deactivated. An application can use the SetWindowPos member function to add or remove this attribute.
WS_EX_TRANSPARENT Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated.
WS_EX_WINDOWEDGE Specifies that a window has a border with a raised edge.
CStatic::Create() // CStatic control’s window styleclass CStatic : public CWnd()
含义
SS_BLACKFRAME
指定一个具有与窗口边界同色的框(缺省为黑色)。
SS_BLACKRECT
指定一个具有与窗口边界同色的实矩形(缺省为黑色)。
SS_CENTER
使显示的正文居中对齐,正文可以回绕。
SS_GRAYFRAME
指定一个具有与屏幕背景同色的边框。
SS_GRAYRECT
指定一个具有与屏幕背景同色的实矩形。
SS_ICON
使控件显示一个在资源中定义的图标,图标的名字有Create函数的lpszText参数指定。
SS_LEFT
左对齐正文,正文能回绕。
SS_LEFTNOWORDWRAP
左对齐正文,正文不能回绕。
SS_NOPREFIX
使静态正文串中的&不是一个热键提示符。
SS_NOTIFY
使控件能向父窗口发送鼠标事件消息。
SS_RIGHT
右对齐正文,可以回绕。
SS_SIMPLE
使静态正文在运行时不能被改变并使正文显示在单行中。
SS_USERITEM
指定一个用户定义项。
SS_WHITEFRAME
指定一个具有与窗口背景同色的框(缺省为白色)。
SS_WHITERECT
指定一个具有与窗口背景同色的实心矩形(缺省为白色)。
除了上表中的风格外,一般还要为控件指定WS_CHILD和WS_VISIBLE窗口风格。一个典型的静态正文控件的风格为WS_CHILD|WS_VISIBLE|SS_LEFT。 对于用对话框模板编辑器创建的静态控件,可以在控件的属性对话框中指定表6.1中列出的控件风格。例如,可以在静态正文控件的属性对话框中选择Simple,这相当于指定了SS_SIMPLE风格。