VC对VB的优势之界面编程
来源:互联网 发布:手机日语游戏汉化软件 编辑:程序博客网 时间:2024/06/07 06:43
一:继承
实例一:在属性页控件中显示不同属性页
VB
VC
控件
TabStrip
Tab Control
VB实现原理:
将不同的属性页设计在一个Picture控件数组中,通过对数组元素的
Visible属性值的设置来在点击一个属性页标题时显示一个属性页。控件的
初始化和属性页的处理多很麻烦。
VB实现代码:
Function creattabs() ‘创建TabStrip控件
Dim intX As Integer
TEST.TabStrp.Tabs.Clear
Set reftbs = TEST.TabStrp.Tabs.Add(, , "Results")
reftbs.ToolTipText = "The results of the test"
Set reftbs = TEST.TabStrp.Tabs.Add(, , "Passed")
reftbs.ToolTipText = "The report of passed products"
Set reftbs = TEST.TabStrp.Tabs.Add(, , "Failed")
reftbs.ToolTipText = "The report of failed products"
For intX = 0 To 3
With TEST.Picture1(intX)
.BorderStyle = 0
.Left = TEST.TabStrp.ClientLeft
.Top = TEST.TabStrp.ClientTop
.Width = TEST.TabStrp.ClientWidth
.Height = TEST.TabStrp.ClientHeight
.Visible = False
End With
Next intX
End Function
Function selecttabs()
If tab1 Then
TEST.Picture1(0).Visible = True
TEST.Picture1(1).Visible = False
TEST.Picture1(2).Visible = False
TEST.Picture1(3).Visible = False
End If
If tab2 Then
TEST.Picture1(0).Visible = False
TEST.Picture1(1).Visible = True
TEST.Picture1(2).Visible = False
TEST.Picture1(3).Visible = False
End If
If tab3 Then
TEST.Picture1(0).Visible = False
TEST.Picture1(1).Visible = False
TEST.Picture1(2).Visible = True
TEST.Picture1(3).Visible = False
End If
If tab4 Then
TEST.Picture1(0).Visible = False
TEST.Picture1(1).Visible = False
TEST.Picture1(2).Visible = False
TEST.Picture1(3).Visible = True
End If
End Function
Dim intX As Integer
TEST.TabStrp.Tabs.Clear
Set reftbs = TEST.TabStrp.Tabs.Add(, , "Results")
reftbs.ToolTipText = "The results of the test"
Set reftbs = TEST.TabStrp.Tabs.Add(, , "Passed")
reftbs.ToolTipText = "The report of passed products"
Set reftbs = TEST.TabStrp.Tabs.Add(, , "Failed")
reftbs.ToolTipText = "The report of failed products"
For intX = 0 To 3
With TEST.Picture1(intX)
.BorderStyle = 0
.Left = TEST.TabStrp.ClientLeft
.Top = TEST.TabStrp.ClientTop
.Width = TEST.TabStrp.ClientWidth
.Height = TEST.TabStrp.ClientHeight
.Visible = False
End With
Next intX
End Function
Function selecttabs()
If tab1 Then
TEST.Picture1(0).Visible = True
TEST.Picture1(1).Visible = False
TEST.Picture1(2).Visible = False
TEST.Picture1(3).Visible = False
End If
If tab2 Then
TEST.Picture1(0).Visible = False
TEST.Picture1(1).Visible = True
TEST.Picture1(2).Visible = False
TEST.Picture1(3).Visible = False
End If
If tab3 Then
TEST.Picture1(0).Visible = False
TEST.Picture1(1).Visible = False
TEST.Picture1(2).Visible = True
TEST.Picture1(3).Visible = False
End If
If tab4 Then
TEST.Picture1(0).Visible = False
TEST.Picture1(1).Visible = False
TEST.Picture1(2).Visible = False
TEST.Picture1(3).Visible = True
End If
End Function
VC实现原理:
利用面向对象编程的继承原理,将Page页从已经设计好的Dialog继
承过来,控件初始化时只需将属性页的指针指向对应的Dialog即可,属性
页的处理有Dialog自己来完成,向普通的Dialog处理一样。
VC实现代码:
在头文件(.h)中声明:
CPage1 m_Page1; // 出勤页
CPage2 m_Page2; // 加班页
CPage3 m_Page3; // 请假页
CPage4 m_Page4; // 出差页
CPropertySheet m_Sheet;
CPage2 m_Page2; // 加班页
CPage3 m_Page3; // 请假页
CPage4 m_Page4; // 出差页
CPropertySheet m_Sheet;
在初始化中加入如下代码:
m_Sheet.AddPage(&m_Page1); // 加第1页
m_Sheet.AddPage(&m_Page2); // 加第2页
m_Sheet.AddPage(&m_Page3); // 加第3页
m_Sheet.AddPage(&m_Page4); // 加第4页
m_Sheet.Create(this, WS_CHILD | WS_VISIBLE, 0); // 创建窗口
m_Sheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT);
m_Sheet.ModifyStyle( 0, WS_TABSTOP ); // 修改风格
// 设置窗口位置
m_Sheet.SetWindowPos( NULL, 0, 100, 0, 0,
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE );
m_Sheet.AddPage(&m_Page2); // 加第2页
m_Sheet.AddPage(&m_Page3); // 加第3页
m_Sheet.AddPage(&m_Page4); // 加第4页
m_Sheet.Create(this, WS_CHILD | WS_VISIBLE, 0); // 创建窗口
m_Sheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT);
m_Sheet.ModifyStyle( 0, WS_TABSTOP ); // 修改风格
// 设置窗口位置
m_Sheet.SetWindowPos( NULL, 0, 100, 0, 0,
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE );
- VC对VB的优势之界面编程
- VB界面,VC核心
- VC编程实现IE风格的界面之叙述
- VC++界面编程之--阴影窗口的实现详解
- VC++界面编程之--阴影窗口的实现详解
- 字符界面的优势
- VC++界面编程之--使用分层窗口实现界面皮肤
- Linux字符界面的优势
- 字符界面的优势 xsell
- VC编程实现IE风格的界面
- VC编程实现IE风格的界面
- VB编程之路-如何让界面美化
- 界面编程:vc美化界面
- SIMD 编程的优势
- SIMD 编程的优势
- VC++ 界面编程
- VC++ 界面编程
- VC++ 界面编程
- 我想你了
- C语言编程中的双刃剑
- server push具体实现教你彻底玩转FLV格式Flash视频
- 解决了CListCtrl控件当字体改变后,自动调整每行的宽度的问题.
- 什么是FLV格式,及FLV格式如何应用
- VC对VB的优势之界面编程
- 求32位整数二进制1的个数
- Flash Media Server起步(1)初识
- 转::图像几何变换(缩放、旋转)中的插值算法
- MFC的串行化编程
- 怎么也戒不了的你
- Flash Media Server 起步(2)连接
- 让一切自由连通:ICF (一)
- 如何架设流媒体服务器 [2]