Article View: cn.bbs.comp.lang.visual-basic
Article #20872Re: ��VB6����ôʹ�ù��ܼ�
From: Ľ�������
Date: Wed, 30 Jul 2003 08:08
Date: Wed, 30 Jul 2003 08:08
75 lines
4085 bytes
4085 bytes
����Ƚ��鷳��������API���к���
Private Sub Form_Load()
Show
Dim ret As Long
preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC) '��¼ԭ����window��
���ַ
ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf wndproc) '���Զ�
��������ԭ����window����
idHotKey = 1 'in the range ��h0000 through ��hBFFF
Modifiers = MOD_CONTROL 'MOD_ALT + MOD_SHIFT
uVirtKey = vbKeyH 'vbKeyG
ret = RegisterHotKey(Me.hwnd, idHotKey, Modifiers, uVirtKey) 'ע�ᷢ����
Ϣ�ȼ�
End Sub
��ģ���У�
Option Explicit
Public RemoteName As String
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVa
l hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVa
l hwnd As Long, ByVal nIndex As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (By
Val lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wPar
am As Long, ByVal lParam As Long) As Long
Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal
id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVa
l id As Long) As Long
Public Const WM_HOTKEY = &H312
'Public Const MOD_ALT = &H1 'Alt
Public Const MOD_CONTROL = &H2 'Ctrl
'Public Const MOD_SHIFT = &H4 'Shift
Public Const GWL_WNDPROC = (-4)
Public preWinProc As Long
Public Modifiers As Long, uVirtKey As Long, idHotKey As Long
Private Type taLong
ll As Long
End Type
Private Type t2Int
lWord As Integer
hword As Integer
End Type
Public Function wndproc(ByVal hwnd As Long, ByVal msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
If msg = WM_HOTKEY Then
If wParam = idHotKey Then
Dim lp As taLong, i2 As t2Int
lp.ll = lParam
LSet i2 = lp
If (i2.lWord = Modifiers) And i2.hword = uVirtKey Then
Debug.Print "HotKey Ctrl+ {Enter} Pressed "
'Shell "notepad", vbNormalFocus
'MsgBox "OK"
If frmMain.Visible And frmMain.WindowState = vbNormal Then
frmMain.Hide '�ȼ�ִ�в���
Else
frmMain.Show
frmMain.WindowState = vbNormal
End If
End If
End If
End If
'������ȼ���Ϣ�����ԭ���ij���
wndproc = CallWindowProc(preWinProc, hwnd, msg, wParam, lParam)
End Function
�� �� xiaodan (����) �Ĵ������ᵽ: ��
: ����VB�������������F1,F2,F3,....�ȹ��ܼ���簴F2����һ�����ڣ�
: лл
--
[m[1;37m�� ��Դ:��BBS ˮľ�廪վ smth.org��[FROM: 202.119.112.40][m
Technical Details
Message-ID:
<000000$25t@smth.org>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-05!sn-xit-08!supernews.com!newsfeed.news2me.com!elnk-nf2-pas!newsfeed.earthlink.net!sjc70.webusenet.com!news.webusenet.com!maily.cic.tsinghua.edu.cn!SMTHShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,GB X-Google-Thread: 10a1a8,2ae8b92613f34c36,start X-Google-Attributes: gid10a1a8,public X-Google-Thread: 109fdd,af25ba9634090b5a X-Google-Attributes: gid109fdd,public X-Google-ArrivalTime: 2003-07-30 01:25:08 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-05!sn-xit-08!supernews.com!newsfeed.news2me.com!elnk-nf2-pas!newsfeed.earthlink.net!sjc70.webusenet.com!news.webusenet.com!maily.cic.tsinghua.edu.cn!SMTH From: zaghost@smth.org (Ľ�������) Newsgroups: cn.bbs.comp.lang.visual-basic Subject: Re: ��VB6����ôʹ�ù��ܼ� Date: 30 Jul 2003 08:08:56 GMT Organization: BBS ˮľ�廪վ Message-ID: <000000$25t@smth.org> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: VisualBasic/W/M.1059552352.90 Lines: 75