转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
Skinning Your Application         ★★★★

Skinning Your Application

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1818 更新时间:2009/4/23 16:38:10
e inputs to load all of the configuration information.


Note   There are several points in the LoadCoordinates routine where I simply read a line into a variable called strJunk and never do anything further with that line. These correspond to the comments that are embedded into each configuration file.
Sub LoadCoordinates()
Dim intDay As Integer
Dim intLocs As Integer
Dim strJunk As String

'''' Open the configuration file for the current skin.
ceFile.Open App.Path & "\" & strCurrentSkin & ".cfg", fsModeInput, fsAccessRead

'''' Load the heading location.
strJunk = ceFile.LineInputString
intDateLocX = ceFile.LineInputString
intDateLocY = ceFile.LineInputString

'''' Load the item location.
strJunk = ceFile.LineInputString
intAppointmentLocX = ceFile.LineInputString
intAppointmentLocY = ceFile.LineInputString

'''' Load the button locations.
For intDay = 1 To 7
strJunk = ceFile.LineInputString
For intLocs = 1 To 4
intButtons(intDay, intLocs) = CInt(ceFile.LineInputString)
Next intLocs
Next intDay

'''' Load text colors.
strJunk = ceFile.LineInputString
lngTitleColor = ceFile.LineInputString
strJunk = ceFile.LineInputString
lngItemColor = ceFile.LineInputString

'''' Clean up.
ceFile.Close

End Sub

Displaying Appointments for a Given Day


I won''''t dwell much on this section of the Skin Demo application as it mostly handles the displaying of hard-coded content. There are some key points to discuss though. First, the Skin Demo uses the Picture Box control''''s DrawText method to display individual items. This allows us to control exactly where on the skin the content is displayed. Second, the Picture Box control''''s Cls method is used to clear off any previous content that may be displayed before adding new content.

Sub DisplayAppointments()
'''' This routine displays the appointments for the selected date.
Dim strDayOfWeek As String

'''' Clear off previous appointment information.
picSkin.Cls

'''' Display the present date.
picSkin.FontBold = True
picSkin.ForeColor = lngTitleColor
Select Case DatePart("w", datCurrent)
Case 1:
strDayOfWeek = "Sunday"
Case 2:
strDayOfWeek = "Monday"
Case 3:
strDayOfWeek = "Tuesday"
Case 4:
strDayOfWeek = "Wednesday"
Case 5:
strDayOfWeek = "Thursday"
Case 6:
strDayOfWeek = "Friday"
Case 7:
strDayOfWeek = "Saturday"
End Select
picSkin.DrawText strDayOfWeek & ", " & MonthName(Month(datCurrent)) & " " & _
Day(datCurrent) & " " & Year(datCurrent), intDateLocX, intDateLocY

'''' Display the appointments for this date.
'''' NOTE: These are hard-coded just for the purpose of this demo.
picSkin.FontBold = False
picSkin.ForeColor = lngItemColor
Select Case strDayOfWeek
Case "Sunday"
picSkin.DrawText "no appointments today", intAppointmentLocX, intAppointmentLocY
Case "Monday"
picSkin.DrawText "08:00 drop car off", intAppointmentLocX, intAppointmentLocY
Case "Tuesday"
picSkin.DrawText "10:00 status meeting", intAppointmentLocX, intAppointmentLocY
picSkin.DrawText "13:00 presentation to management", _
intAppointmentLocX, intAppointmentLocY + 200
Case "Wednesday"
picSkin.DrawText "09:30 conference call", intAppointmentLocX, intAppointmentLocY
picSkin.DrawText "11:00 interview", intAppointmentLocX, intAppointmentLocY + 200
picSkin.DrawText "14:00 product meeting", intAppointmentLocX, intAppointmentLocY + 400
picSkin.DrawText "15:30 doctor appointment", intAppointmentLocX,_
intAppointmentLocY + 600
Case "Thursday"
picSkin.DrawText "10:00 project meeting", intAppointmentLocX, intAppointmentLocY
picSkin.DrawText "14:00 presentation to management", _
intAppointmentLocX, intAppointmentLocY + 200
Case "Friday"
picSkin.DrawText "12:00 lunch with Lauren", intAppointmentLocX, intAppointmentLocY
Case "Saturday"
picSkin.DrawText "10:00 soccer game", intAppointmentLocX, intAppointmentLocY
End Select

End Sub

Changing Skins


When the user selects a new skin from the menu, the new skin is implemented using the following small bit of code. The name of the skin is passed as an argument to the event procedure. This makes it extremely simple to switch to a new skin.

Private Sub ceMenuBar_MenuClick(ByVal Item As MenuBarLib.Item)

'''' Change the skin.
strCurrentSkin = Item.Caption
picSkin.Picture = App.Path & "\" & strCurrentSkin & ".bmp"
LoadCoordinates
DisplayAppointments

End Sub

Handling Button Taps


All that is left is handling user taps on a button. This is handled through the MouseDown event of the Picture Box control. The essence behind this routine is to take the location that the user tapped, and compare it against the coordinates for each of the buttons on a skin. If a match is found, the appointments for the selected day are displayed.

Private Sub picSkin_MouseDown(ByVal Button As Long, ByVal Shift As Long, _
ByVal x As Double, ByVal y As Double)
Dim intCounter As Integer

'''' Uncomment this line to help debug your button locations.
'''' MsgBox "X:" & x & " Y:" & y

'''' Check to see if the user tapped a button.
For intCounter = 1 To 7
If (x >= intButtons(intCounter, 1)) Then
If (y >= intButtons(intCounter, 2)) Then
If (x <= intButtons(intCounter, 3)) Then
If (y <= intButtons(intCounter, 4)) Then
datCurrent = datWeek(intCounter)
DisplayAppointments
End If
End If
End If
End If
Next intCounter

End Sub

Summary of Skinning Your Application


That''''s it, everything that you need to skin-enable your eMbedded Visual Basic applications. The process of creating the skins and the configuration files take a bit of work, but the result is, well, for lack of a better word, just plain cool. Remember, if you are going to have other controls as part of your interface, you have to set the ZOrder property so that they sit on top of the Picture Box control.


Back on the Road


That''''s it for this month. I''''m going to go stare out my window at the ocean. However, from several thousand miles away, I''''ll have a hard time making out details. Until next month, I''''m back on the road.

上一页  [1] [2] 


[Delphi程序]delphi create  Http link on your form  [VB.NET程序]Store Images in Your Database
[VB.NET程序]Create Your Own Visual Basic Add-Ins  
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台