|
-
Feb 15th, 2002, 01:39 PM
#1
Thread Starter
Hyperactive Member
Get the message
hi everybody
i am using following piece of code to catch the messages. Now
MSDN says that you can only use the low word of the message
parameter of the MSG structure. I know this is very much possible
by using LOWORD in windows programming with C, but how can i read the low word of message from VB?
VB Code:
Private Sub getMessage()
Dim MS As MSG
Do While 1
DoEvents
PeekMessage MS, Me.hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE
Select Case MS.message
'This is where i need help
End Select
Loop
End Sub
Please help me.
Thanks in advance.
-
Feb 16th, 2002, 03:46 AM
#2
Thread Starter
Hyperactive Member
Nobody?
-
Feb 16th, 2002, 07:00 AM
#3
Hyperactive Member
Try:
VB Code:
Private Function HiWord(lParam As Long) As Long
HiWord = lParam \ &H10000 And &HFFFF&
End Function
Private Function LoWord(lParam As Long) As Long
LoWord = lParam And &HFFFF&
End Function
W#Ć€V€® W¦|| ߀ W¦|| ߀, ÄÑÐ †#€®€ ¦§ ÑÖ†#¦Ñ6 ¥Öµ ©ÄÑ ÐÖ ÄßÖµ† ¦†, §Ö §¦† ßÄ©K, ®€|ÄX ÄÑÐ |€† ¦† #ÄÞÞ€Ñ.
(Whatever will be will be, and there is nothing you can do about it, so sit back, relax and let it happen.)
-
Feb 18th, 2002, 01:17 PM
#4
Frenzied Member
I think that you're going to find that this method very unreliable. Your program might process the message before your routine has a chance to handle it.
-
Feb 19th, 2002, 12:57 AM
#5
Thread Starter
Hyperactive Member
This means even if i create a callback function for my app., i cannot gurantee its performance. I cant assure that it will
process each and every message it is supposed to handle. Isn't
it?
Any suggestions?
-
Feb 19th, 2002, 09:23 AM
#6
Frenzied Member
Originally posted by abhid
This means even if i create a callback function for my app., i cannot gurantee its performance. I cant assure that it will
process each and every message it is supposed to handle. Isn't
it?
Pretty Much
Any suggestions?
Subclass your form.
-
Feb 20th, 2002, 06:51 AM
#7
Thread Starter
Hyperactive Member
Originally posted by Shawn N
[B Subclass your form. [/B]
hmm...
I have used subclassing technique only once in VB. can you show
me?
Any links or tutorials?
-
Feb 20th, 2002, 06:48 PM
#8
Here's a basic skeleton:
Add to a Module
VB Code:
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Public Const GWL_WNDPROC = (-4)
Public WinProcOld As Long
Public Function WinProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = WM_MYMESSAGE Then
End If
WinProc = CallWindowProc(WinProcOld&, hwnd&, wMsg&, wParam&, lParam&)
End Function
Sub SubClassWnd(hwnd As Long)
WinProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WinProc)
End Sub
Sub UnSubclassWnd(hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, WinProcOld&
WinProcOld& = 0
End Sub
Add to your Form
VB Code:
Private Sub Form_Load()
SubClassWnd Me.hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubclassWnd Me.hwnd
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|