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

DX: Full Screen GUI Development 2

作者:闵涛 文章来源:闵涛的学习笔记 点击数:4144 更新时间:2009/4/23 16:39:24
;   Case iEnabled

                    rectObject.Top = 0

                    rectObject.Bottom = iHeight

                Case iPressed

                    rectObject.Top = iHeight

                    rectObject.Bottom = iHeight * 2

            End Select

 

If you run the app, you抣l see the new buttons in the upper right hand corner of the window. You抣l also notice that we抳e added a caption for the window. This is held by the sCaption member of the clsWindow class.  If you look at the declarations section for the class you抣l also see two other new members:

 

Private iCaptionX As Integer

Private iCaptionY As Integer

 

These will be used to draw the caption where it is needed for the specific control type. If you look at the DrawObject function in the class you抣l see we抳e added the code necessary to handle the caption:

 

        Case BaseWindow

            ''''Nothing needed here since we use the base rectangle

            If Len(sCaption) > 0 Then

                iCaptionX = iX + 10

                iCaptionY = iY + 5

                bDrawCaption = True

            Else

                bDrawCaption = False

            End If

 

?/SPAN>

 

    If bDrawCaption Then

        lOldColor = objSurface.GetForeColor

        objSurface.SetForeColor RGB(255, 255, 255)

        objSurface.DrawText iCaptionX, iCaptionY, sCaption, False

        objSurface.SetForeColor lOldColor

    End If

 

The setup of the base window object has been changed to add the caption:

 

    With frmMain.Window

        .ObjectSurface = objDD.CreateSurfaceFromFile(App.Path & "\window.bmp", ddsdSurf2)

        .ParentX = 0

        .ParentY = 0

        .ParentHeight = 600

        .ParentWidth = 800

        .CenterX = True

        .CenterY = True

        .WindowName = "Base"

        .Caption = "Test Window"

    End With

 

The next thing that has been added is the event raising. Take a look at the MouseUp function in the clsWindow class:

 

Public Function MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) As Boolean

   

    Dim iLp As Integer

    Dim bRetVal As Boolean

   

    MouseUp = False

   

    If X >= iX And X <= iX + iWidth And Y >= iY And Y <= iY + iHeight Then

        For iLp = 1 To colChildren.Count

            ''''If a child handles the event no need to do anything else

            bRetVal = colChildren(iLp).MouseUp(Button, Shift, X, Y)

            If bRetVal Then Exit Function

        Next iLp

   

        If iObjectType >= CloseBtn Then

            iObjectState = iEnabled

            If iObjectType = CloseBtn Then

                RaiseEvent Clicked

            End If

        Else

            If Not (iObjectState = iDisabled) Then

                If iObjectState = iPressed And iObjectType = Btn Then

                    iObjectState = iEnabled

                    RaiseEvent Clicked

                End If

            End If

           

        End If

        MouseUp = True

       

    End If

   

End Function

 

If the control has been clicked we use RaiseEvent to notify the app that this is so. The app can then decide what to do based on which control has been clicked. In our case we do two things ?destroy the window and close the app:

 

Private Sub CloseButton_Clicked()

    Window.RemoveChildren

    Set Window = Nothing

End Sub

 

Private Sub OKButton_Clicked()

    gbRun = False

End Sub

 

You can recreate the window by pressing the F1 key. Try it and see. I抣l wait while you do. J

 

Got all that? Good, then lets more on to more cool stuff.

 

Next Up

 

Open up the WindowSample4 project and take a look at the modMain module. You抣l see we抳e added RadioBtn and FrameWnd enums. Also not the constant cFrameGrey. We抣l be using this a little later on to help draw the FrameWnd control.

 

Next take a look at the frmMain code. We抳e added declarations for the new frame and radio button objects. Notice the two sets of radio buttons ?WindowRadio1,2, and 3 and Radio1, 2, and 3. The WindowRadio controls will go on the base window and the Radio controls will be contained by the Frame control. You抣l see that you can change a control in one group without affecting the other, just as you can in VB. This is due to the Parent/Child relationship of the clsWindow objects. We抳e also added the code to support the RaiseEvent call in the class for each of the objects. We merely set two controls that weren抰 clicked to be unchecked.

 

Not much has changed in the modDirectDraw module. The only thing of significance is in setting up the radio buttons that are contained

上一页  [1] [2] [3] [4] [5]  下一页


[VB.NET程序]DX: Full Screen GUI Development 1  [Web开发]利用JavaScript创建功能强大的GUI
[JAVA开发]Java手机软件图形界面API之低级GUI组件  [SyBase]关于linux做nat出现“table full”的终极解决办法…
[MySql]Linux GUI编程笔记之GTK+篇(2)  [MySql]Linux GUI编程笔记之GTK+篇(1)
[电脑技术]如何使用wxPython设计gui  
教程录入: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……
    咸宁网络警察报警平台