菜鸟求教:一个声明问题

firewoods 2008-03-20 04:36:38
学生在自学VB2005 应就是VB.net吧?

学生偶在这里发了个帖子 问了一个监控程序的方法
有位老师帮我解答了 很感谢他的!
但是学生又遇到没法解决的问题了
我的基础太差 又着急用 还请老师们不吝赐教吧!
谢谢!

那位老师帮我写出的如下:
API函数声明:
Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer) As Integer
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer


' ------------------------------------------------------------------------------------------------------
' Description: 获取与指定字符串相匹配的窗口类名或窗口名的最顶层窗口的窗口句柄
' Parameters: WindowName 指定的窗口类名或窗口名
' Return: 返回指定窗口的句柄
' ------------------------------------------------------------------------------------------------------
Public Function GetWindowHandle(ByVal WindowName As String) As Integer
Dim intAppHandle As Integer
intAppHandle = FindWindow(vbNullString, WindowName)
Return intAppHandle
End Function

调用如下:
intPSHandle =GetWindowHandle("adobe photoshop")
MoveWindow(intPSHandle, X的值, Y的值,Width的值,高的值, 1)

偶把以上内容贴到模块里了 但是出了点问题 软件提示:
intPSHandle 和 MoveWindow 应为声明
这个声明偶怎么改都不成
还请老师们帮忙

以下是我的代码

Module Module1
'声明公共变量
Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal bRepaint As Integer) As Integer
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer

Public Function GetWindowHandle(ByVal WindowName As String) As Integer
Dim intAppHandle As Integer
intAppHandle = FindWindow(vbNullString, WindowName)
Return intAppHandle
End Function

'未解决问题
Dim intPSHandle As String
intPSHandle =GetWindowHandle("adobe photoshop")
MoveWindow(intPSHandle, 500, 500,1)
End Module
...全文
85 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
firewoods 2008-03-21
  • 打赏
  • 举报
回复
解决了。。。。
请版主锁帖吧
谢谢了!
给大家添麻烦了
firewoods 2008-03-20
  • 打赏
  • 举报
回复
是否应该这样:

调用如下:
intPSHandle =GetWindowHandle("adobe photoshop")
MoveWindow(intPSHandle, X的值, Y的值,Width的值,高的值, 1)

是不是我应该把“调用”的那个两个函数放到“按钮”啥的下面? 刚才试了一下 没报错

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧