| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 883 人关注过本帖
标题:运行中隐藏标题栏的问题
只看楼主 加入收藏
周斌
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-10-19
收藏
 问题点数:0 回复次数:6 
运行中隐藏标题栏的问题
我练习编一个在运行中隐藏显示标题栏的程序 ,但是隐藏时整个窗口都被隐藏,大家能看看哪里错了吗?窗体上只有一个checkbox控件
Private Sub Check1_Click()
If Check1.Value = 1 Then
   TitleBar False
Else
   TitleBar True
End If
End Sub
Public Function TitleBar(ByVal bstate As Boolean)
Dim lstyle As Long
Dim tr As RECT
GetWindowRect Me.hwnd, tr
lstyle = GetWindowLong(Me.hwnd, -16)
If bstate Then
   Me.Caption = Me.Tag
   If Me.ControlBox Then
     lstyle = lstyle Or &H80000
   End If
   If Me.MaxButton Then
     lstyle = lstyle Or &H10000
   End If
   If Me.MinButton Then
     lstyle = lstyle Or &H20000
   End If
   If Me.Caption <> "" Then
     lstyle = lstyle Or &HC00000
   End If
 Else
   Me.Tag = Me.Caption
   Me.Caption = ""
   lstyle = lstyle Or Not &H80000
   lstyle = lstyle Or Not &H10000
   lstyle = lstyle Or Not &H20000
   lstyle = lstyle Or Not &HC00000
 End If
 SetWindowLong Me.hwnd, -16, lstyle
 SetWindowPos Me.hwnd, 0, tr.left, tr.top, tr.right - tr.left, tr.bottom - tr.top, &H200 Or &H4 Or &H20
End Function
搜索更多相关主题的帖子: 隐藏 运行 
2008-10-21 10:57
jxyga111
Rank: 8Rank: 8
来 自:中華人民共和國
等 级:贵宾
威 望:33
帖 子:6015
专家分:895
注 册:2008-3-21
收藏
得分:0 
你直接將窗體的樣式調成為無邊框不就可以了

烈焰照耀世界,斌凍凍千萬裏
2008-10-21 11:56
周斌
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-10-19
收藏
得分:0 
行是行,但是不能再显示出来了那样
2008-10-21 12:45
jxyga111
Rank: 8Rank: 8
来 自:中華人民共和國
等 级:贵宾
威 望:33
帖 子:6015
专家分:895
注 册:2008-3-21
收藏
得分:0 
那麼你就再將窗體的樣式變為有邊框不就行了

烈焰照耀世界,斌凍凍千萬裏
2008-10-21 13:40
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
BorderStyle 属性

返回或设置对象的边框样式。对 Form 对象和 Textbox 控件在运行时是只读的。

授人于鱼,不如授人于渔
早已停用QQ了
2008-10-21 18:55
jxyga111
Rank: 8Rank: 8
来 自:中華人民共和國
等 级:贵宾
威 望:33
帖 子:6015
专家分:895
注 册:2008-3-21
收藏
得分:0 
Private Sub Command1_Click()
    Unload Me
    form2.Show
   
End Sub
這樣啦,如果要隱藏就打開別外一個,不是隱藏就打開ME,關閉FORM2

烈焰照耀世界,斌凍凍千萬裏
2008-10-22 11:47
三断笛
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:31
帖 子:1621
专家分:1617
注 册:2007-5-24
收藏
得分:0 
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As Rect) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_CAPTION = &HC00000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_SYSMENU = &H80000

Public Const WS_EX_LAYERED = &H80000
Public Const GWL_EXSTYLE = (-20)

Public Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Function ShowTitleBar(Frm As Form, ByVal bState As Boolean, Optional H As Long, Optional W As Long)  '去除窗体标题栏
    Dim lStyle As Long
    Dim tR As Rect

    GetWindowRect Frm.hWnd, tR
    lStyle = GetWindowLong(Frm.hWnd, GWL_STYLE)
    If (bState) Then
    '    Frm.Caption = Frm.Tag
            If Frm.ControlBox Then
                lStyle = lStyle Or WS_SYSMENU
            End If
            If Frm.MaxButton Then
                lStyle = lStyle Or WS_MAXIMIZEBOX
            End If
            If Frm.MinButton Then
                lStyle = lStyle Or WS_MINIMIZEBOX
            End If
            If Frm.Caption <> "" Then
                lStyle = lStyle Or WS_CAPTION
            End If
    Else
        'Frm.Tag = Frm.Caption
        'Frm.Caption = ""
        lStyle = lStyle And Not WS_SYSMENU
        lStyle = lStyle And Not WS_MAXIMIZEBOX
        lStyle = lStyle And Not WS_MINIMIZEBOX
        lStyle = lStyle And Not WS_CAPTION
    End If
    SetWindowLong Frm.hWnd, GWL_STYLE, lStyle
    Frm.Height = H
    Frm.Width = W
End Function
2008-10-22 12:28
快速回复:运行中隐藏标题栏的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035197 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved