|
-
Apr 30th, 2009, 10:01 PM
#1
Thread Starter
New Member
createwindowex event handling.......
I'm using vs2008, and I've been stuck trying to use createwindowex to create a button on an external application. I have been able to successfully create the button, I just can't figure out the workings of catching the events.
I'm calling a function that returns lhWnd:
Code:
Public Function butToTab(ByVal tabHWND As Integer)
Dim rhWnd As Integer = System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32()
lhWnd = CreateWindowEx(0, "BUTTON", "test", WS_VISIBLE Or WS_CHILD, a, 1, d, e, tabHWND, 0, rhWnd, 0) ' Or SS_OWNERDRAW Or BM_CLICK
newWinT1 = lhWnd 'newWinT1 is public
Return lhWnd
End Function
I call the function like so:
Code:
SendMessage(butToTab(tab1HWND), WM_CTLCOLORBTN, 0&, 0&)
(I would like to note, even though I'm sure it's obvious, I am still new to this. I'm really just trying to get it to work, and gain somewhat of an understanding for it.)
The part I am completely confused, is finding and adding events to incoming messages only for this button. I've tried numerous times to use wndproc, and WindowProc, etc.... but I couldn't get the right messages.
For example, I have used:
Code:
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case WM_COMMAND
If m.HWnd = Me.Handle Then
MsgBox("WM_COMMAND")
End If
Case BM_SETSTATE
MsgBox("BM_SETSTATE")
Case BM_CLICK
MsgBox("BM_CLICK")
Case BN_CLICKED
MsgBox("BN_CLICKED")
End Select
MyBase.WndProc(m)
When I use Spy++, The button only uses BM_SETSTATE, and WM_IME_NOTIFY (I know they don't have to do really with the click itself, but its the closest thing to it).
My question is, if I just wanted that button to have a messagebox popup when I clicked it, what would I need to do? I set up the wndproc so it is constantly catching messages, but do I need to run it through another function?
I'm sorry for posting such a broad question, but I've been stuck on this for a long time, and decided I needed major help. Thanks for your replies.
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
|