| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1040 人关注过本帖
标题:这个程序,用户定义类型如何定义?
只看楼主 加入收藏
yuma
Rank: 12Rank: 12Rank: 12
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1934
专家分:3012
注 册:2009-12-22
结帖率:89.13%
收藏
 问题点数:0 回复次数:4 
这个程序,用户定义类型如何定义?
这个程序,用户定义类型如何定义?

这个程序是通过API的方法,最小化窗口。用于操作第三方程序的最大化、最小化、还原?


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
    Private Const SW_SHOWMINIMIZED = 2
    Private Const SW_SHOWMAXIMIZED = 3
    Private Const SW_SHOWNORMAL = 1
   

Private Sub Form_Load()
Dim hwnd As Long, Thwnd As Long
Shell "notepad.exe", 1 '打开一个记事本
hwnd = FindWindow("Notepad", "无标题 - 记事本") '得到记事本句柄
SetWindowPlacement hwnd, 2
End Sub

[此贴子已经被作者于2023-2-9 15:15编辑过]

搜索更多相关主题的帖子: hwnd Long 定义 用户 Private 
2023-02-09 15:14
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
VB6 自带的 API 阅读器带该结构 定义
我一般是按子结构放前面的原则 排列代码(C 要求)

Public Type POINTAPI
        x As Long
        y As Long
End Type

Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Public Type WINDOWPLACEMENT
        Length As Long
        flags As Long
        showCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPosition As Rect
End Type

具体 每个参数是什么意思,自己百度一下。

授人于鱼,不如授人于渔
早已停用QQ了
2023-02-09 16:21
yuma
Rank: 12Rank: 12Rank: 12
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1934
专家分:3012
注 册:2009-12-22
收藏
得分:0 
代码废了。

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWNORMAL = 1
   
Private Type POINTAPI
        x As Long
        y As Long
End Type

Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Type WINDOWPLACEMENT
        Length As Long
        flags As Long
        showCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPosition As RECT
End Type

Private Sub Form_Load()
Dim app_hwnd As Long
Dim wp As WINDOWPLACEMENT
Shell "notepad.exe", 1 '打开一个记事本
app_hwnd = FindWindow("Notepad", "无标题 - 记事本") '得到记事本句柄
wp.showCmd = SW_SHOWMINIMIZED
SetWindowPlacement app_hwnd, wp.showCmd
End Sub



心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2023-02-09 19:02
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
SetWindowPlacement app_hwnd, wp.showCmd

要求传入 一个结构,你还只传一个值干嘛?

'-----WINXP+VB6测试通过----------
Dim app_hwnd As Long
Dim wp As WINDOWPLACEMENT
Shell "notepad.exe", 1 '打开一个记事本
app_hwnd = FindWindow("Notepad", "无标题 - 记事本") '得到记事本句柄
wp.showCmd = SW_SHOWMAXIMIZED        '最大化
wp.Length = Len(wp)                  '结构体长度
SetWindowPlacement app_hwnd, wp      '传入结构体

授人于鱼,不如授人于渔
早已停用QQ了
2023-02-09 19:34
yuma
Rank: 12Rank: 12Rank: 12
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1934
专家分:3012
注 册:2009-12-22
收藏
得分:0 
可以,WIN10下测试通过。

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2023-02-09 20:55
快速回复:这个程序,用户定义类型如何定义?
数据加载中...
 
   



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

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