不用MFC制作tab控件

huyanpeng2010 2010-04-09 09:55:42
本人用evc开发手机游戏,不用MFC直接用windows api做一个tab控件,就是CreateWindows这个函数
请高手指教给份资料最好
...全文
79 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
向立天 2010-04-17
  • 打赏
  • 举报
回复
您好
我是本版版主
此帖已多日无人关注
请您及时结帖
如您认为问题没有解决可按无满意结帖处理
另外本版设置了疑难问题汇总帖
并已在版面置顶
相关规定其帖子中有说明
您可以根据规定提交您帖子的链接
如您目前不想结帖只需回帖说明
我们会删除此结帖通知

见此回复三日内无回应
我们将强制结帖
相关规定详见界面界面版关于版主结帖工作的具体办法
Eleven 2010-04-09
  • 打赏
  • 举报
回复
INITCOMMONCONTROLSEX iccs;
iccs.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccs.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&iccs);

HWND hwnd = CreateWindowEx(0,
WC_TABCONTROL,
"TabCtrl",
0,
0, 0, 0, 0,
NULL,
NULL,
NULL,
NULL);
baili35 2010-04-09
  • 打赏
  • 举报
回复
贴msdn上面的东西给你
A tab control is analogous to a set of dividers in a notebook or labels in a file cabinet. In a property sheet, a user selects a tab in order to move from one page in a property sheet to another. The following screen shot shows a Windows CE tab control.


You send messages to a tab control to add tabs, and to affect the appearance and behavior of the control. Each message has a corresponding macro, which you can use instead of sending the message explicitly. Although you cannot disable an individual tab in a tab control, you can disable a tab control in a property sheet by disabling the corresponding page.

Each tab in a tab control consists of a label and application-defined data. This data is specified by a TCITEM structure. You can add tabs to a tab control, get the number of tabs, retrieve and set the contents of a tab, and delete tabs. Tabs are identified by their zero-based index.

Windows CE supports an extended style for the tab control. To set an extended style, you can use the TCM_SETEXTENDEDSTYLE message or its corresponding macro, TabCtrl_SetExtendedStyle. You can use the TCM_GETEXTENDEDSTYLE message or its corresponding macro, TabCtrl_GetExtendedStyle, to retrieve the extended style.

Note Because an extended style for a tab control is not the same as an extended window style, you cannot pass an extended style for a tab control to CreateWindowEx when you create a tab control.
The extended style for the tab control, known as the TCS_EX_FLATSEPARATORS style, draws a separator between tab items in tab controls that have the TCS_BUTTONS style or the TCS_FLATBUTTONS style. When you create a tab control that uses either the TCS_BUTTONS or the TCS_FLATBUTTONS style, the extended style for the tab control is set by default.

To create a tab control

Specify the WC_TABCONTROL class in the lpClassName parameter of the CreateWindowEx function.
Windows CE registers this class when it loads the DLL for the common control. You can use the InitCommonControls function to ensure that this DLL is loaded. To register the class for the tab control by using the InitCommonControlsEx function, specify the ICC_ TAB_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure that you pass in the lpInitCtrls parameter.

Specify a style for the tab control in the dwStyle parameter of the CreateWindowEx function.
You can add tabs to the control by using the TCM_INSERTITEM message, which specifies the position of the tab and the address of its TCITEM structure. You can retrieve and set the contents of an existing tab by using the TCM_GETITEM and TCM_SETITEM messages. For each tab, you can specify an icon, a label, or both.

You can associate application-defined data with each tab. For example, you might save information about each page with its corresponding tab. By default, a tab control allocates four extra bytes per tab for application-defined data. You can change the number of extra bytes per tab by using the TCM_SETITEMEXTRA message. You can use this message only when the tab control is blank.

The lParam member of the TCITEM structure specifies application-defined data. If you use more than four bytes of application-defined data, you need to define your own structure and use it instead of TCITEM. You can retrieve and set application-defined data in the same way that you retrieve and set other information about a tab, by using the TCM_GETITEM and TCM_SETITEM messages.

Note Windows CE does not support vertical text. If you create vertical tabs and want to use vertical text, you have to create a text bitmap and rotate it. Then, you can add the bitmap to an image list and attach it to the tab by specifying the index of the bitmap in the image list in the iImage member of the TCITEM structure or the TCITEMHEADER structure.
You use messages and styles to learn about tabs. You can determine the current bounding rectangle for a tab by using the TCM_GETITEMRECT message. You can determine which tab, if any, is at a specified location by using the TCM_HITTEST message. In a tab control that uses the TCS_MULTILINE style, you can determine the current number of rows of tabs by using the TCM_GETROWCOUNT message.

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧