标题:这个程序,用户定义类型如何定义?
只看楼主
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册: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
帖 子:4912
专家分:29900
注 册: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: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册: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
帖 子:4912
专家分:29900
注 册: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: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
得分:0 
可以,WIN10下测试通过。

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2023-02-09 20:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-511243-1-1.html




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

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