-
Feb 27th, 2013, 03:30 AM
#1
DoEvents Replacement
In my program, I wanna replace DoEvents with something faster and close to how C++ does it. The only events I wanna check are painting events, mouse events, and keyboard events, window moving and resizing. I plan on using the GetMessage TranslateMessage and DispatchMessage APIs but can't find the stinking constant values to messages such as WM_PAINT as well as the others, if not all of em. I know there are other ways, and I'm well aware of em as I tinkered with this stuff in the past (literally all of em such as GetQueueStatus, GetInputState etc.) But I don't wanna use them. I had the code to do the GetMessage TranslateMessage and DispatchMessage APIs a few years ago, but the code is long gone, and Google isn't even helping much either. The setup I know is kinda like this:
Code:
Public Type Message_Type
hwnd As Long
Message As Long
wParam As Long
lParam As Long
Time As Long
ptX As Long
ptY As Long
End Type
Public Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As Message_Type, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Public Declare Function TranslateMessage Lib "user32" (lpMsg As Message_Type) As Long
Public Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As Message_Type) As Long
Public Msg As Message_Type
Public Sub DoEvents_Replacement()
While GetMessage(Msg, frmMain.hWnd, 0, 0)
TranslateMessage Msg
DispatchMessage Msg
Wend
End Sub
Just that I don't know what the constants are for the messages, and practically forgot completely on how to handle em. It's 3 in the morning so I'll get back to respond sometime when I'm actually awake. Thanks in advance.
-
Feb 27th, 2013, 04:01 AM
#2
Re: DoEvents Replacement
You'll find the most authoritative source for things like window message constants to be the C header files included in the Windows SDK.
As time goes on it becomes hard to find the older SDKs anymore. I think only the Win7 and Win8 versions are still readily available for free downloading without an MSDN subscription.
Here is a link to the most recent version relative to Win7:
https://www.microsoft.com/en-us/down...s.aspx?id=8279
Here is the order page for ordering disks, and this goes back further:
http://mssdk.orderport.net/22221848/showall.asp
-
Feb 27th, 2013, 08:13 AM
#3
Re: DoEvents Replacement
Have you tried using PeekMessage instead of GetMessage? You can specify in the wRemoveMsg parameter the message types that you want to be processed.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Feb 27th, 2013, 11:08 AM
#4
Re: DoEvents Replacement
Yea but the point is, is that I don't know the constants because as dillentante pointed out, its getting harder and harder to find any documentation as time goes by and vb6 slowely gets killed off. Its funny that MS abandons support for vb6 entirely, yet its still a widely used language do to its ease of use. But thats another topic. Anyways I might just stick with DoEvents in the mean time just to avoid the hassle incase no solutions are present.
-
Feb 27th, 2013, 11:54 AM
#5
Re: DoEvents Replacement
Well my point was that support for old versions of Windows becomes less available over time.
As far as playing around with window messages goes... that has never been what you could call "normal" VB6 programming. I'm not saying that nobody does it, but it really isn't something within the domain of higher level languages like VB6.
There are alternatives to using DoEvents calls already built into VB6 and encouraged in the VB6 manuals. But I'm sure you are aware of them and have discarded them as unsuitable for reasons of your own.
Here's a thought though:
If there is a way to make a DoEvents substitute that truly avoids all of the warts of DoEvents don't you think we'd all be using it? We've had 32-bit VB now since 1995 after all.
-
Feb 27th, 2013, 12:07 PM
#6
Re: DoEvents Replacement
WINUSER.H is the header you want. You might well have it already if you have installed any of the windows kits.
You can also find it online easily enough, here's a link.
Also you can usually find values with a web search by including define in your search term i.e. "#define WM_PAINT".
-
Feb 27th, 2013, 12:14 PM
#7
Re: DoEvents Replacement
Depends on which message you need.
I usually let Windows index the Include directory, and create a desktop or Start Menu shortcut to take me there quickly. Once there I can paste the name of the message constant into the search box, then open the file or files that come up in Notepad and do a Find.
This works well for all kinds of API constants.
-
Feb 27th, 2013, 07:29 PM
#8
Re: DoEvents Replacement
Here are quite a few of them already defined in VB syntax.
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
|