⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 49.asp

📁 ASPWeb数据库范例总览
💻 ASP
📖 第 1 页 / 共 4 页
字号:
<P><FONT SIZE=+0>... 处理「按下滑鼠」讯息</FONT></P>

<P><FONT SIZE=+0>ElseIf lParam = WM_LBUTTONDBLCLK Then</FONT></P>

<P><FONT SIZE=+0>... 处理「双按滑鼠」讯息</FONT></P>

<P><FONT SIZE=+0>End If</FONT></P>

<P><FONT SIZE=+0>End If</FONT></P>

<P><FONT SIZE=+0>WndProcForIcon = CallWindowProc(prevWndProcForIcon, hWnd,
Msg, wParam, lParam)</FONT></P>

<P><FONT SIZE=+0>End Function</FONT></P>

<P> </P>
</DIR>
</UL>

<P>此一运作模式并不困难, 唯一要特别注意的事情是「讯息编号」(也就是 nid.uCallbackMessage
资料成员与视窗程序的 Msg 参数), 由於 Windows 已经定义了某些讯息(例如 WM_LBUTTONDOWN),
而这些讯息都具有特定意义, 因此我们选用的「讯息编号」绝对不可以与 Windows
已定义的讯息相冲突, 而要避免讯息的冲突, 程式可以使用编号在 WM_USER(=&amp;H400=1024)
以後的讯息, 因为 WM_USER 以後的讯息编号属於 Windows 未定义的讯息。</P>

<P> </P>

<P>此一问题特别困难, 建议您仔细阅读笔者所完成的范例, 如果不太能瞭解其中的意义,
请翻开上一期的「Windows 的讯息系统」, 复习一下。</P>

<P> </P>

<H2>附录 ─ 呼叫本文 API 函数所需之宣告式</H2>

<P> </P>

<P><FONT SIZE=-1>Option Explicit</FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 1、2、3 所需之宣告</P>

<P><FONT SIZE=-1>Public Const FO_MOVE = &amp;H1</FONT></P>

<P><FONT SIZE=-1>Public Const FO_COPY = &amp;H2</FONT></P>

<P><FONT SIZE=-1>Public Const FO_DELETE = &amp;H3</FONT></P>

<P><FONT SIZE=-1>Public Const FOF_NOCONFIRMATION = &amp;H10</FONT></P>

<P><FONT SIZE=-1>Public Const FOF_NOCONFIRMMKDIR = &amp;H200</FONT></P>

<P><FONT SIZE=-1>Public Const FOF_ALLOWUNDO = &amp;H40</FONT></P>

<P><FONT SIZE=-1>Type SHFILEOPSTRUCT</FONT></P>

<P><FONT SIZE=-1>hWnd As Long</FONT></P>

<P><FONT SIZE=-1>wFunc As Long</FONT></P>

<P><FONT SIZE=-1>pFrom As String</FONT></P>

<P><FONT SIZE=-1>pTo As String</FONT></P>

<P><FONT SIZE=-1>fFlags As Integer</FONT></P>

<P><FONT SIZE=-1>fAborted As Boolean</FONT></P>

<P><FONT SIZE=-1>hNameMaps As Long</FONT></P>

<P><FONT SIZE=-1>sProgress As String</FONT></P>

<P><FONT SIZE=-1>End Type</FONT></P>

<P><FONT SIZE=-1>Declare Function SHFileOperation Lib &quot;shell32.dll&quot;
Alias &quot;SHFileOperationA&quot; (lpFileOp As SHFILEOPSTRUCT) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 4 所需之宣告</P>

<P><FONT SIZE=-1>Public Const GWL_WNDPROC = (-4)</FONT></P>

<P><FONT SIZE=-1>Public Const WM_RBUTTONDOWN = &amp;H204</FONT></P>

<P><FONT SIZE=-1>Public Const WM_RBUTTONUP = &amp;H205</FONT></P>

<P><FONT SIZE=-1>Declare Function CallWindowProc Lib &quot;user32&quot;
Alias &quot;CallWindowProcA&quot; (ByVal lpPrevWndFunc As Long, ByVal hWnd
As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long)
As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function GetWindowLong Lib &quot;user32&quot;
Alias &quot;GetWindowLongA&quot; (ByVal hWnd As Long, ByVal nIndex As Long)
As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function SetWindowLong Lib &quot;user32&quot;
Alias &quot;SetWindowLongA&quot; (ByVal hWnd As Long, ByVal nIndex As Long,
ByVal dwNewLong As Long) As Long</FONT></P>

<P><FONT SIZE=-1>Public prevWndProc As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 5 所需之宣告</P>

<P><FONT SIZE=-1>Declare Function GetWindowsDirectory Lib &quot;kernel32&quot;
Alias &quot;GetWindowsDirectoryA&quot; (ByVal lpBuffer As String, ByVal
nSize As Long) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 6 所需之宣告</P>

<P><FONT SIZE=-1>Declare Function fCreateShellLink Lib &quot;vb5stkit.DLL&quot;
(ByVal folder As String, ByVal ShortCutName As String, ByVal ExePath As
String, ByVal Params As String) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 7 所需之宣告</P>

<P><FONT SIZE=-1>Public Const SW_SHOWMINIMIZED = 2</FONT></P>

<P><FONT SIZE=-1>Public Const SW_SHOWMAXIMIZED = 3</FONT></P>

<P><FONT SIZE=-1>Public Const SW_SHOW = 5</FONT></P>

<P><FONT SIZE=-1>Declare Function ShellExecute Lib &quot;shell32.dll&quot;
Alias &quot;ShellExecuteA&quot; (ByVal hWnd As Long, ByVal lpOperation
As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal
lpDirectory As String, ByVal nShowCmd As Long) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 8 所需之宣告</P>

<P><FONT SIZE=-1>Public Const SYNCHRONIZE = &amp;H100000</FONT></P>

<P><FONT SIZE=-1>Public Const INFINITE = &amp;HFFFFFFFF</FONT></P>

<P><FONT SIZE=-1>Declare Function OpenProcess Lib &quot;kernel32&quot;
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId
As Long) As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function CloseHandle Lib &quot;kernel32&quot;
(ByVal hObject As Long) As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function WaitForSingleObject Lib &quot;kernel32&quot;
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 9、12 所需之宣告</P>

<P><FONT SIZE=-1>Public Const EM_GETLINECOUNT = &amp;HBA</FONT></P>

<P><FONT SIZE=-1>Public Const EM_LINESCROLL = &amp;HB6</FONT></P>

<P><FONT SIZE=-1>Declare Function SendMessage Lib &quot;user32&quot; Alias
&quot;SendMessageA&quot; (ByVal hWnd As Long, ByVal wMsg As Long, ByVal
wParam As Long, lParam As Any) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 10 所需之宣告</P>

<P><FONT SIZE=-1>Public Const DRIVE_REMOVABLE = 2</FONT></P>

<P><FONT SIZE=-1>Public Const DRIVE_FIXED = 3</FONT></P>

<P><FONT SIZE=-1>Public Const DRIVE_REMOTE = 4</FONT></P>

<P><FONT SIZE=-1>Public Const DRIVE_CDROM = 5</FONT></P>

<P><FONT SIZE=-1>Public Const DRIVE_RAMDISK = 6</FONT></P>

<P><FONT SIZE=-1>Declare Function GetDriveType Lib &quot;kernel32&quot;
Alias &quot;GetDriveTypeA&quot; (ByVal nDrive As String) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 11 所需之宣告</P>

<P><FONT SIZE=-1>Public Const OFS_MAXPATHNAME = 128</FONT></P>

<P><FONT SIZE=-1>Public Const OF_READ = &amp;H0</FONT></P>

<P><FONT SIZE=-1>Type OFSTRUCT</FONT></P>

<P><FONT SIZE=-1>cBytes As Byte</FONT></P>

<P><FONT SIZE=-1>fFixedDisk As Byte</FONT></P>

<P><FONT SIZE=-1>nErrCode As Integer</FONT></P>

<P><FONT SIZE=-1>Reserved1 As Integer</FONT></P>

<P><FONT SIZE=-1>Reserved2 As Integer</FONT></P>

<P><FONT SIZE=-1>szPathName(OFS_MAXPATHNAME) As Byte</FONT></P>

<P><FONT SIZE=-1>End Type</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>Type SYSTEMTIME</FONT></P>

<P><FONT SIZE=-1>wYear As Integer</FONT></P>

<P><FONT SIZE=-1>wMonth As Integer</FONT></P>

<P><FONT SIZE=-1>wDayOfWeek As Integer</FONT></P>

<P><FONT SIZE=-1>wDay As Integer</FONT></P>

<P><FONT SIZE=-1>wHour As Integer</FONT></P>

<P><FONT SIZE=-1>wMinute As Integer</FONT></P>

<P><FONT SIZE=-1>wSecond As Integer</FONT></P>

<P><FONT SIZE=-1>wMilliseconds As Integer</FONT></P>

<P><FONT SIZE=-1>End Type</FONT></P>

<P><FONT SIZE=-1>Type FileTime</FONT></P>

<P><FONT SIZE=-1>dwLowDateTime As Long</FONT></P>

<P><FONT SIZE=-1>dwHighDateTime As Long</FONT></P>

<P><FONT SIZE=-1>End Type</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>Type BY_HANDLE_FILE_INFORMATION</FONT></P>

<P><FONT SIZE=-1>dwFileAttributes As Long</FONT></P>

<P><FONT SIZE=-1>ftCreationTime As FileTime</FONT></P>

<P><FONT SIZE=-1>ftLastAccessTime As FileTime</FONT></P>

<P><FONT SIZE=-1>ftLastWriteTime As FileTime</FONT></P>

<P><FONT SIZE=-1>dwVolumeSerialNumber As Long</FONT></P>

<P><FONT SIZE=-1>nFileSizeHigh As Long</FONT></P>

<P><FONT SIZE=-1>nFileSizeLow As Long</FONT></P>

<P><FONT SIZE=-1>nNumberOfLinks As Long</FONT></P>

<P><FONT SIZE=-1>nFileIndexHigh As Long</FONT></P>

<P><FONT SIZE=-1>nFileIndexLow As Long</FONT></P>

<P><FONT SIZE=-1>End Type</FONT></P>

<P><FONT SIZE=-1>Type TIME_ZONE_INFORMATION</FONT></P>

<P><FONT SIZE=-1>bias As Long</FONT></P>

<P><FONT SIZE=-1>StandardName(32) As Integer</FONT></P>

<P><FONT SIZE=-1>StandardDate As SYSTEMTIME</FONT></P>

<P><FONT SIZE=-1>StandardBias As Long</FONT></P>

<P><FONT SIZE=-1>DaylightName(32) As Integer</FONT></P>

<P><FONT SIZE=-1>DaylightDate As SYSTEMTIME</FONT></P>

<P><FONT SIZE=-1>DaylightBias As Long</FONT></P>

<P><FONT SIZE=-1>End Type</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>Declare Function GetTimeZoneInformation Lib &quot;kernel32&quot;
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function OpenFile Lib &quot;kernel32&quot; (ByVal
lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As
Long</FONT></P>

<P><FONT SIZE=-1>Declare Function GetFileInformationByHandle Lib &quot;kernel32&quot;
(ByVal hFile As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION)
As Long</FONT></P>

<P><FONT SIZE=-1>' Declare Function CloseHandle Lib &quot;kernel32&quot;
(ByVal hObject As Long) As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function FileTimeToSystemTime Lib &quot;kernel32&quot;
(lpFileTime As FileTime, lpSystemTime As SYSTEMTIME) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 13 所需之宣告</P>

<P><FONT SIZE=-1>Declare Function CreateSolidBrush Lib &quot;gdi32&quot;
(ByVal crColor As Long) As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function SelectObject Lib &quot;gdi32&quot; (ByVal
hdc As Long, ByVal hObject As Long) As Long</FONT></P>

<P><FONT SIZE=-1>Declare Function FloodFill Lib &quot;gdi32&quot; (ByVal
hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As
Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 14 所需之宣告</P>

<P><FONT SIZE=-1>Declare Function GetDiskFreeSpace Lib &quot;kernel32&quot;
Alias &quot;GetDiskFreeSpaceA&quot; (ByVal lpRootPathName As String, lpSectorsPerCluster
As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters
As Long) As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 15 所需之宣告</P>

<P><FONT SIZE=-1>Public Const NIM_ADD = 0</FONT></P>

<P><FONT SIZE=-1>Public Const NIM_MODIFY = 1</FONT></P>

<P><FONT SIZE=-1>Public Const NIM_DELETE = 2</FONT></P>

<P><FONT SIZE=-1>Public Const NIF_MESSAGE = 1</FONT></P>

<P><FONT SIZE=-1>Public Const NIF_ICON = 2</FONT></P>

<P><FONT SIZE=-1>Public Const NIF_TIP = 4</FONT></P>

<P><FONT SIZE=-1>Type NOTIFYICONDATA</FONT></P>

<P><FONT SIZE=-1>cbSize As Long</FONT></P>

<P><FONT SIZE=-1>hWnd As Long</FONT></P>

<P><FONT SIZE=-1>uID As Long</FONT></P>

<P><FONT SIZE=-1>uFlags As Long</FONT></P>

<P><FONT SIZE=-1>uCallbackMessage As Long</FONT></P>

<P><FONT SIZE=-1>hIcon As Long</FONT></P>

<P><FONT SIZE=-1>szTip As String * 64</FONT></P>

<P><FONT SIZE=-1>End Type</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>Public Const WM_LBUTTONDOWN = &amp;H201</FONT></P>

<P><FONT SIZE=-1>Public Const WM_LBUTTONDBLCLK = &amp;H203</FONT></P>

<P><FONT SIZE=-1>Public Const WM_USER = &amp;H400</FONT></P>

<P><FONT SIZE=-1>Public prevWndProcForIcon As Long</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>Declare Function Shell_NotifyIconA Lib &quot;SHELL32&quot;
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 4 所需之视窗程序</P>

<P><FONT SIZE=-1>Function WndProc(ByVal hWnd As Long, ByVal Msg As Long,
ByVal wParam As Long, ByVal lParam As Long) As Long</FONT></P>

<P><FONT SIZE=-1>If Msg = WM_RBUTTONDOWN Then</FONT></P>

<P><FONT SIZE=-1>' 吃掉这个讯息</FONT></P>

<P><FONT SIZE=-1>Else</FONT></P>

<P><FONT SIZE=-1>WndProc = CallWindowProc(prevWndProc, hWnd, Msg, wParam,
lParam)</FONT></P>

<P><FONT SIZE=-1>End If</FONT></P>

<P><FONT SIZE=-1>End Function</FONT></P>

<P><FONT SIZE=-1> </FONT></P>

<P><FONT SIZE=-1>' 问题</FONT> 15 所需之视窗程序</P>

<P><FONT SIZE=-1>Function WndProcForIcon(ByVal hWnd As Long, ByVal Msg
As Long, ByVal wParam As Long, ByVal lParam As Long) As Long</FONT></P>

<P><FONT SIZE=-1>If Msg = WM_USER Then</FONT></P>

<P><FONT SIZE=-1>If lParam = WM_LBUTTONDOWN Then</FONT></P>

<P><FONT SIZE=-1>MsgBox &quot;按下滑鼠</FONT>&quot;, vbInformation + vbSystemModal</P>

<P><FONT SIZE=-1>ElseIf lParam = WM_LBUTTONDBLCLK Then</FONT></P>

<P><FONT SIZE=-1>MsgBox &quot;双按滑鼠</FONT>&quot;, vbInformation + vbSystemModal</P>

<P><FONT SIZE=-1>End If</FONT></P>

<P><FONT SIZE=-1>End If</FONT></P>

<P><FONT SIZE=-1>WndProcForIcon = CallWindowProc(prevWndProcForIcon, hWnd,
Msg, wParam, lParam)</FONT></P>

<P><FONT SIZE=-1>End Function</FONT></P>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -