Foxtable(狐表)用户栏目专家坐堂 → [原创]全局代码报错


  共有1910人关注过本帖树形打印复制链接

主题:[原创]全局代码报错

帅哥哟,离线,有人找我吗?
天一生水
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
[原创]全局代码报错  发帖心情 Post By:2017/11/1 9:36:00 [只看该作者]

嵌入exe程序到当前窗口的全局代码,原封不动的复制进项目,保存时报错:

 


此主题相关图片如下:2017-11-1.jpg
按此在新窗口浏览图片

 

全局代码:


 

<DllImport("user32.dll", EntryPoint := "FindWindow")> _
Public Function FindWindow(lpClassName As String, lpWindowName As String) As Integer
End Function

<DllImport("user32.dll", EntryPoint := "SetParent")> _
Public Function SetParent(hWndChild As Integer, hWndNewParent As Integer) As Integer
End Function

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 GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As String) As Integer

Public  Declare Function GetWindow Lib "user32" (ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer
Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Integer
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Integer) As Integer
Public Delegate Function   EnumWindowsProc(ByVal   hwnd   As   Integer,   ByVal   lParam   As   Integer)   As   Boolean
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Integer) As Integer
Public Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Integer
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Integer) As Integer
Public Const WM_CLOSE = &H10

<DllImport("user32.dll", SetLastError:=True)> _
Public Function GetForegroundWindow() As IntPtr
End Function


<DllImport("user32.dll")> _
Public Function GetWindowTextLength(hWnd As Integer) As Integer
End Function

Public Function EnumWindowsProcCallBack(ByVal   hwnd   As   Integer,   ByVal   lParam   As   Integer)   As   Boolean
      Return Functions.Execute("EnumWindowsProcCallBack", hwnd, lparam)
End   Function

Public Const GW_HWNDFIRST =0
Public Const GW_HWNDLAST = 1
Public Const GW_HWNDNEXT = 2
Public Const GW_HWNDPREV = 3
Public Const GW_OWNER = 4

Public jbs As new List (of String)


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/1 9:48:00 [只看该作者]

 代码没有问题,你应该在全局代码,还写有了类似的相同的代码,比如,下面的代码,如果写了两次,就有问题

 

<DllImport("user32.dll", EntryPoint := "FindWindow")> _
Public Function FindWindow(lpClassName As String, lpWindowName As String) As Integer
End Function

 

<DllImport("user32.dll", EntryPoint := "FindWindow")> _
Public Function FindWindow(lpClassName As String, lpWindowName As String) As Integer
End Function


 回到顶部
帅哥哟,离线,有人找我吗?
天一生水
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
  发帖心情 Post By:2017/11/1 14:42:00 [只看该作者]

谢谢田老师!

还剩下一句代码有冲突,去掉哪一边都不行,合在一起也不行,改不了:

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Integer) As Integer

这句与“无边框可移动”的一句全局代码有冲突:

Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer,ByVal wMsg As Integer, ByVal
wParam As Integer, lParam As Integer) As Integer
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Public Sub Panel_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs)
If e.Button=MouseButtons.Left Then
    ReleaseCapture()
    SendMessage(sender.Parent.Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/1 15:50:00 [只看该作者]

删掉这句

 

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer,ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Integer) As Integer


 回到顶部