手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Asp.Net编程>列表

DX: Full Screen GUI Development 2

来源:互联网 作者:西部数码 时间:2008-04-10
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

If iObjectType <> FrameWnd Then lRet = objSurface.Blt(rectBitmap, objBitmap, rectObject, lBltFlags)

If bDrawCaption Then

lOldColor = objSurface.GetForeColor

objSurface.SetForeColor RGB(255, 255, 255)

objSurface.DrawText iCaptionX, iCaptionY, sCaption, False

objSurface.SetForeColor lOldColor

End If

For iLp = 1 To colChildren.Count

colChildren(iLp).DrawObject objSurface

Next iLp

Exit Function

DrawObjectErr:

objErr.WriteLine "Error drawing " & sName & " - " & Err.Description

Exit Function

End Function

As you can see the changes are pretty extensive. The function now has to handle the two new controls and the new Caption member. The RadioBtn is fairly simple since it pretty much acts like the ChkBox inside the class. If you looked at the files included with this project you抣l notice that there抯 no bitmap for the frame object. That抯 because it uses DirectDraw抯 DrawLine function to draw the outline of the frame. Open the framesample.bmp file and zoom in to see how it抯 actually drawn.

We抳e added a function in the class to return a child object. This is necessary to change the RadioBtn抯 ObjectState member when one radio button in a group is clicked:

Public Function GetChild(ByVal sKey As String) As clsWindow

Set GetChild = colChildren(sKey)

End Function

The AddChild method was changed to specify a key when adding a child in order to support this function:

Public Sub AddChild(clsChild As clsWindow)

colChildren.Add clsChild, clsChild.WindowName

End Sub

Take a minute to run the app and play with the new controls. There are a couple of things that could be changed to make the class better but I抣l leave them up to you. Some things could be:

  • Add members to allow the font type, size and color to be changed.
  • Add a Style member to allow the ChkBox and RadioBtn objects to be graphical similar to the way the VB controls act.
  • Change the frame drawing to not draw under the caption.
  • Adapt the class to add a LabelWnd object type. This would just use the Caption property

That抯 it for this lesson. I hope it抯 been fun and interesting. The next lesson will attempt to cover listboxes and comboboxes. Hope to see you there.

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!