|
-
Nov 26th, 2001, 03:55 PM
#1
How to check messages:
Code:
Public Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
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 Const GWL_WNDPROC = (-4)
Public Const WM_USER = &H400
Public Const WM_MYMESSAGE = WM_USER + 100
Public WndProcOld As Long
Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'set up a case statement to trap the various messages
' you want to something with here.
' example
Select Case wMsg
case WM_QUIT '
Exit Function
case WM_KEYUP
case WM_LBUTTONUP - etc
' trap each message type and do stuff with it or not
End Select
' call the default winodw procedure so the message gets to it
WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
End Function
Sub SubClassWnd(hwnd As Long)
WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
End Sub
Sub UnSubclassWnd(hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
WndProcOld& = 0
End Sub
-
Nov 26th, 2001, 04:51 PM
#2
2. BroadcastSystemMessage works somewhat like SendMessage does, except it simplifies the process of sending to all windows, all desktops, all drivers etc. It also allows some options for you to configure, e.g: when to send messages, flush disk or not etc.
3. All they do is use region conbinations with a picture as the background. You can combine regions via the CombineRgn API. Depending on whether you specify AND, OR, XOR, OR, you can create complex shapes that you would otherwise not be able to create.
4. Form MSDN
A device context is a structure that defines a set of graphic objects and their associated attributes, and the graphic modes that affect output. The graphic objects include a pen for line drawing, a brush for painting and filling, a bitmap for copying or scrolling parts of the screen, a palette for defining the set of available colors, a region for clipping and other operations, and a path for painting and drawing operations.
The data type/variable hDC simply stands for "A handle to a device context"
-
Nov 27th, 2001, 12:43 PM
#3
Lively Member
(1) This is exactly what I did, I just didn't use & sign before the varibles. Is this the problem? What is it for anyway. It reminds me about putting & in front of variables in C to represent its address. Is it the same in VB?
(3) So it is very hard to make a shape after a picture. You know, like painting the shape in one color and than just it to shape the form. I suppose it's not that easy . So, is there any site that covers it good or something. It would be something
Thanks for your answers
/J Lindroos
"My opinions may be have changed, but not the fact that I am right"
< modified by admin. no advertising in sigs>
-
Nov 27th, 2001, 05:40 PM
#4
%, &, $ are kind of like cast operators in VB, and they are placed after a variable name.
& - makes a long
% - integer
$ - string
Consider downloading the apiveiwer and api-guide (free & multi-lingual, and very good) from www.allapi.net All of this stuff is in there.
There are examples for about 850 common api calls in the guide.
-
Nov 28th, 2001, 03:44 PM
#5
Originally posted by J Lindroos
(3) So it is very hard to make a shape after a picture. You know, like painting the shape in one color and than just it to shape the form. I suppose it's not that easy . So, is there any site that covers it good or something. It would be something
You can't create a region from a picture. You have to create the region separately. Yes, this can be hard, but with the right functions, you can accomplish it. You'll definetly need to use different combination flags (AND, OR, XOR etc.) to combine the regions. Each of these flags are explained in the MSDN reference for CombineRgn.
-
Nov 29th, 2001, 01:54 AM
#6
Lively Member
Ok, I'm using CreatePolygonRgn to make the region. Just defining the vertices in a good image viewer, and making it. Works fine, but there is one problem. The Polygon Region won't be combined with any other region using RGN_OR. But it is no problem with using RGN_XOR, to make a hole, but that's not what I want.
Any ideas?
/J Lindroos
"My opinions may be have changed, but not the fact that I am right"
< modified by admin. no advertising in sigs>
-
Nov 29th, 2001, 06:32 AM
#7
Junior Member
I have seen some samples where a picture is used to shape a window.
For what I can remember, a path is created (picturetopath? or beginpath endpath). That path is converted to a region. Finally that's applies to a window with SetWindowRegion.
Sorry, that's all I can help you with.
btw, my subclassing control (for getting window messages) doesn't crash! (or am I just pushing you now?)
-
Nov 30th, 2001, 12:17 PM
#8
Lively Member
Looks good
Ok, I hope this is for trapping messages sent to other windows in other apps, and not for just subclassing your own.
Someone else who know about regions? Post reply!
/J Lindroos
"My opinions may be have changed, but not the fact that I am right"
< modified by admin. no advertising in sigs>
-
Dec 1st, 2001, 05:19 AM
#9
Junior Member
Ok, I hope this is for trapping messages sent to other windows in other apps, and not for just subclassing your own.
In windows NT/2000/XP, you can't even subclass other application windows anymore!!!
See the MSDN for that.
subclassing info
SetWindowLong function
-
Dec 1st, 2001, 06:12 AM
#10
Lively Member
Yes but one of my systems is windows 95, and I'm intend to use it there
/J Lindroos
"My opinions may be have changed, but not the fact that I am right"
< modified by admin. no advertising in sigs>
-
Dec 1st, 2001, 07:25 AM
#11
Junior Member
Well, in that case. Use it - you can use it IF you know the window handle (HWND)
To you my subclass:
- Download the control
- put it in your windows\system directory.
- open VB, add the component (use the browse for file...)
- The control get's registered automatically.
- Drop the control on the a form (Form1).
- In the Form1 code window, add the event procedure for the ReceivedMessage event.
- Write this code: EventHandler1.Attached(Form1.hWnd) = True
If you can find out the HWND of a other window, you can use it aswell off course.
However, if you want to monitor every
message (also when your window is inactive),
please get familliar with hooking.
I also have a control for that
-
Dec 1st, 2001, 12:20 PM
#12
Lively Member
Yes, I wrote a Enum Windows application and now I want to expand it. With this application you list all windows in a treeview and you can change parents, text and position. You can also send message, disable, bring to front, show, destroy etc.
So, yes, I want the user to select what window to watch messages at. and then have a window that just display the message and pass it to the window.
I will try your hook control
/J Lindroos
"My opinions may be have changed, but not the fact that I am right"
< modified by admin. no advertising in sigs>
-
Dec 2nd, 2001, 08:53 AM
#13
Junior Member
Thanks. - Feedback is always welcome.
BTW, why don't u use SPY++?
Or do you want to make something funny, like that, yourself?
or alternatively, check the MSDN what kind messages a specific window class can receive... (check my previous link about the subclassing)
geez.. this thread is getting long ;D
-
Dec 2nd, 2001, 12:07 PM
#14
Re: Looks good
Originally posted by J Lindroos
Ok, I hope this is for trapping messages sent to other windows in other apps, and not for just subclassing your own.
Someone else who know about regions? Post reply!
In order to subclass another window, your code needs to be in a standard DLL. How do you want your subclassing to work? Before the message is sent to the window? After it's been processed by the window? Or while it's in the message queue?
-
Dec 4th, 2001, 02:30 PM
#15
Lively Member
Well, I just wanna know what messages it gets so no matter when I get it.
And yes, I'm making this program just for fun
/J Lindroos
"My opinions may be have changed, but not the fact that I am right"
< modified by admin. no advertising in sigs>
-
Dec 4th, 2001, 07:40 PM
#16
Do you also want this to be a learning experience for you? If not, you can just use Spy++ to view the messages. All the work is done for you 
If you do want this to be a learning experience, then I would suggesting installing a WH_GETMESSAGE hook.
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
|