开班课程| 学习形式| 时间| 状态
ACCP S1脱产班9月1日已满
ACCP S1脱产班10月13日已满
ACCP S1周末班10月20日余7座
ACCP S1脱产班11月11日已满
ACCP S1周末班11月9日已满
ACCP S1脱产班12月15日热招
ACCP S1周末班12月15日热招
学生就业:内在修养比面试技巧2008-11-19
大学生走上工作岗位如何站住脚2008-11-19
面试问题的准备2008-11-19
避免简历中6个常见错误2008-09-27
求职应该避免走三个极端2008-09-27
12种求职方式成功率排行榜2008-09-27
不可不看:规划你未来的10必2008-09-27
求职中务必躲开这5大圈套2008-09-27
具备什么样的知识水平可以报名2008-09-27
北大青鸟APTECH公司的优2008-09-27
可否直接学习第二学期或第二学2008-09-27
ACCP课程的特点体现在哪些2008-09-27
ACCP培训与微软以及其它I2008-09-27
ACCP课程在教学上有哪些特2008-09-27
什么是熟练的计算机用户?2008-09-27
为什么要学习第二年的课程,之2008-09-27
除了作为软件开发工程师,我还2008-09-27
学习ACCP课程能拿到什么样2008-09-27
你们颁发的证书具有何种效力?2008-09-27
参加学习的学员还可以得到其它2008-09-27
认证考试的题目由谁出?2008-09-27
学员参加考试认证的合格率如何2008-09-27
认证考试不及格有补考机会吗?2008-09-27
如何保证培训中心教师的质量?2008-09-27
学生如果在学习过程中因故休学2008-09-27
考试是什么形式的?2008-09-27
如何保证ACCP课程的先进性2008-09-27
学员完成学业后,中心如何推荐2008-09-27
  您现在的位置:首 页 >>> 窗口处理技巧大全
   你现在的位置:首页  >>>  学习园地
窗口处理技巧大全
更新时间:[2008-9-27 16:25:36]  来源:[]  浏览:[213]

   Vb提供了API函数SetWindowLong和GetWindowLong,可以让我们很容易取得对窗口的操作;通过对窗口属性的操作,可以更改窗口的显示风格。有些看来是正常情况下无法实现的窗口,现在你可以很容易的实现。只要你想到,更多希奇古怪的你也能做到。快试试下面的例子吧。

    一下例子中可能用到的API声明和常量、变量声明
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_DRAWFRAME = &H20
    Private Const GWL_STYLE = (-16)
    Private Const WS_THICKFRAME = &H40000
    Private Const WS_DLGFRAME = &H400000
    Private Const WS_POPUP = &H80000000
    Private Const WS_CAPTION = &HC00000
    Private Const WS_SYSMENU = &H80000
    Private Const WS_MINIMIZEBOX = &H20000
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const WS_MINIMIZE = &H20000000
    Private Const WS_MAXIMIZE = &H1000000

--------------------------------------------------------------------------------

    例子一:任何一个控件(只要有窗口,这是我们的前提,下同),你可以在运行时随便更改它的大小。     Private Sub ControlSize(ControlName As Control, SetTrue As Boolean)
    Dim dwStyle As Long
    dwStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
    If SetTrue Then
        dwStyle = dwStyle Or WS_THICKFRAME
    Else
        dwStyle = dwStyle - WS_THICKFRAME
    End If
    dwStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, dwStyle)
    SetWindowPos ControlName.hwnd, ControlName.Parent.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End Sub
    用法:ControlSize picture1,true;设置第二个参数为False取消这种设置,下同

--------------------------------------------------------------------------------

    例子二:任何一个控件,我们都可以控制其显示风格为对话框的风格。
    Private Sub ControlDialog(ControlName As Control, SetTrue As Boolean)
    Dim dwStyle As Long
    dwStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
    If SetTrue Then
        dwStyle = dwStyle Or WS_DLGFRAME
    Else
        dwStyle = dwStyle - WS_DLGFRAME
    End If
    dwStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, dwStyle)
    SetWindowPos ControlName.hwnd, ControlName.Parent.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End Sub
    用法:ControlSize picture1,true

--------------------------------------------------------------------------------

    例子三:任何一个控件,我们都可以控制其显示风格为模式对话框的风格
    Private Sub ControlModal(ControlName As Control, SetTrue As Boolean)
    Dim dwStyle As Long
    dwStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
    If SetTrue Then
        dwStyle = dwStyle Or WS_POPUP
    Else
        dwStyle = dwStyle - WS_POPUP
    End If
    dwStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, dwStyle)
    SetWindowPos ControlName.hwnd, ControlName.Parent.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End Sub
    用法:ControlModal Picture1,true

--------------------------------------------------------------------------------

    例子四:任何一个控件,我们都可以给它加上标题栏,通过拖动标题栏,可以实现控件的运行时移动。
    Private Sub ControlCaption(ControlName As Control, SetTrue As Boolean)         Dim dwStyle As Long
    dwStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
    If SetTrue Then
        dwStyle = dwStyle Or WS_CAPTION
    Else
        dwStyle = dwStyle - WS_CAPTION
    End If
    dwStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, dwStyle)
    SetWindowPos ControlName.hwnd, ControlName.Parent.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End Sub
    用法:ControlCaption picture1,true

--------------------------------------------------------------------------------

    例子五:任何一个控件,我们都可以给它加上ControlBox(所谓ControlBox,就是窗体的图标+最小化+最大化+关闭按钮)。
    Private Sub ControlSysMenu(ControlName As Control, SetTrue As Boolean)
    Dim dwStyle As Long
    dwStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
    If SetTrue Then
        dwStyle = dwStyle Or WS_SYSMENU
    Else
        dwStyle = dwStyle - WS_SYSMENU
    End If
    dwStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, dwStyle)
    SetWindowPos ControlName.hwnd, ControlName.Parent.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End Sub
    用法:ControlCaption picture1,true:ControlSysmenu picture1,true

 

 相 关 信 息
C#中StringBuilder类的使用
Java和.Net的socket机制的比
C#实现更改IP功能源代码
通过java.net.Socket类抓取
JSF与WEB完美应用组合




北大青鸟集团 北大青鸟总部 印度APTECH公. 北京大学 国家劳动保障. 北大方正集团 北大未名生物..
北大资源公司 中国奥委会官. 北京博客网联 新疆人才招聘. 中国新疆人才. 新疆农业大学 新疆师范大学
新疆大学 新丝路 天山网 天脉网 中国互联网络. 新速腾网络科技  
关于我们  |  招聘信息  |  联系我们  |  在线报名  |  管理登录
Copyright ©版权所有 2008-2009 乌鲁木齐北大青鸟(英杰)授权培训中心 管理登录
联系地址:乌鲁木齐市解放北路39号(天百名店29层)  邮政编码:830000
联系电话:0991-6126666 传真:0991-6126666
新ICP备06003934号

技术支持:新疆新速腾网络科技有限公司 www.xjxst.com