工具栏进行设置LPCREA TESTRUCT是一个指向结构CREA TESTRUCT的指针.以下是该结构的信息:The CREA TESTRUCT structure defines the initialization parameters passed to the window procedure of an application.typedef struct tagCREA TESTRUCT { // csLPVOID lpCreateParams;HINSTANCE hInstance;HMENU hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;LPCTSTR lpszName;LPCTSTR lpszClass;DWORD dwExStyle;} CREA TESTRUCT;MemberslpCreateParamsContains additional data which may be used to create the window. If the window is being created as a result of a call to the CreateWindow or CreateWindowEx function, this member contains the value of the lpParam parameter specified in the function call.If the window being created is an MDI window, this member contains a pointer to an MDICREA TESTRUCT structure.Windows NT: If the window is being created from a dialog template, this member is the address of a SHORT value that specifies the size, in bytes, of the window creation data. The value is immediately followed by the creation data. For more information, see the following Remarks section.hInstanceHandle to the module that owns the new window.hMenuHandle to the menu to be used by the new window.hwndParentHandle to the parent window, if the window is a child window. If the window is owned, this member identifies the owner window. If the window is not a child or owned window, this member is NULL.cySpecifies the height of the new window, in pixels.cxSpecifies the width of the new window, in pixels.ySpecifies the y-coordinate of the upper left corner of the new window. If the new window is a child window, coordinates are relative to the parent window. Otherwise, the coordinates are relative to the screen origin.xSpecifies the x-coordinate of the upper left corner of the new window. If the new window is a child window, coordinates are relative to the parent window. Otherwise, the coordinates are relative to the screen origin.styleSpecifies the style for the new window.lpszNamePointer to a null-terminated string that specifies the name of the new window.lpszClassPointer to a null-terminated string that specifies the class name of the new window.dwExStyleSpecifies the extended style for the new window.RemarksWindows NT: Y ou should access the data represented by the lpCreateParams member using a pointer that has been declared using the UNALIGNED type, because the pointer may not be DWORD aligned. This is demonstrated in the following example:typedef struct tagMyData{// Define creation data here.} MYDA TA;typedef struct tagMyDlgData{SHORT cbExtra;MYDA TA myData;} MYDLGDA TA, UNALIGNED *PMYDLGDA TA;PMYDLGDA TA pMyDlgdata =(PMYDLGDA TA) (((LPCREA TESTRUCT) lParam)->lpCreateParams);The WM_CREA TE message is sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. The window procedure of the new window receives this message after the window is created, but before the window becomes visible. The message is sent before the CreateWindowEx or CreateWindow function returns.WM_CREA TElpcs = (LPCREA TESTRUCT) lParam; // structure with creation dataParameterslParamV alue of lParam. Pointer to a CREA TESTRUCT structure that contains information about the window being created. The members of CREA TESTRUCT are identical to the parameters of the CreateWindowEx function.Return V aluesIf an application processes this message, it should return 0 to continue creation of the window. If the application returns –1, the window is destroyed and the CreateWindowEx or CreateWindow function returns a NULL handle.QuickInfo工具栏何志丹主要内容:1,概要。
2,常用函数3,实例。
4,动态建立工具条5,在工具栏中嵌控件6,用对话框加位图按钮作工具条我们可以在资源编辑器的ToolBar上单击右键,选择Insert ToolBar,选中一个工具栏后,在右边双击它的一项就可以编辑了。
我们可以用图形工具条及颜色盒画它的外表,它的属性有ID,长,宽及鼠标指向它时的说明。
一般CToolBar定义在CMainFrame中,其实现在CMainFrame的OnCreate函数中完成。
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |WS_VISIBLE | CBRS_TOP| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY |CBRS_SIZE_DYNAMIC) ||!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)){TRACE0("Failed to create toolbar ");return -1; // fail to create}m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);EnableDocking(CBRS_ALIGN_ANY);DockControlBar(&m_wndToolBar);Bool Create(CWnd *pParentWnd,DWORD dwStu;e = WS_CHILD | WS_VISIBLE |CBRS_TOP,UINT nID = AFX_IDW_TOOLBAR);pParentWnd指定所属窗口。
dwStyle 指定工具栏风格CBRS_TOP 允许工具栏位于框架窗口顶端。
CBRS_BOTTOM 允许工具栏位于框架窗口底端CBRS_NOALIGN 父窗口改变尺寸后工具栏位置不变CBRS_TOOLTIPS 工具栏显示提示条CBRS_SIZE_DYNAMIC 工具幸是动态的CBRS_SIZE_FIXED 工具栏是固定的CBRS_FLOATING 工具栏是浮动的CBRS_FLYBY 当鼠标从命令按钮上掠过时显示提示信息CBRS_HIDE_INPLACE 工具栏对用户不可见SetButtonStyle()函数用来设定命令按钮的风格或间隔区,或设为一组,按钮的风格决定了按钮的外貌和对用户的反应方式.Void SetButtonStyle(int nIndex,UINT nStyle);nIndex 指定工具栏中按钮或间隔的索引号.nStyle TBBS_BUTTON 标准按钮,此为默认值TBBS_SEPARATOR 间隔区TBBS_CHECKBOX 自动确认区TBBS_GROUP 标记为一组按钮的开始TBBS_CHECKGROUP 标记为一组确认框的开始ControlBar类的EnableDocking函数和CFrameWnd类的DockControlBar函数配合,设定工具栏的可活动性.Void EanbleDocking(DWORD dwStyle)CBRS_ALIGN_TOP 允许工具栏位于客户区上侧CBRS_ALIGN_BOTTOM 允许工具栏位于客房区下侧CBRS_ALIGN_LEFT 允许工具栏位于客户区左侧CBRS_ALIGN_RIGHT 允许工具栏位于客户区右侧CBRS_ALIGN_ANY 允许工具栏位于客户区的任意位置CBRS_FLOAT_MULTI 允许多个控制栏在一个迷你框架窗口中浮动Void DockControlBar(….)pBar 要浮动的控制栏指针.nDockBarID指定允许浮动的位置,或为0则不允许浮动,可以由下列值组合而成:AFX_IDW_DOCKBAR_TOP 控制栏置于框架窗口上侧;AFX_IDW_DOCKBAR_BOTTOM 控制栏置于框架窗口下侧AFX_IDW_DOCKBAR_LEFT 控制栏置于框架窗口左侧AFX_IDW_DOCKBAR_RIGHT 控制栏置于框架窗口右侧改变工具栏的命令按钮风格,工具栏的按钮一般默认为命令按钮,当放开标鼠标,命令按钮就”弹出来”,如果我们希望命令按钮能留在被按上的状态,就可以把命令按钮的风格设为确认框。