|
-
Aug 31st, 2000, 10:47 AM
#1
Thread Starter
Frenzied Member
This is VB(like tou didn't know).
Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam)
If uMsg = WM_RBUTTONDOWN Then
MsgBox "Ok..."
End If
End Function
PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC, AddressOf WindowProc)
How do i do this in VC++?
To subclass a window, to make that msg pop on some WM.
-
Aug 31st, 2000, 01:11 PM
#2
I am not very good in C++. but I'll try 
Code:
LONG WindowProc(HWND hwnd,LONG uMsg,LONG wParam,LONG lParam)
WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam);
If (uMsg == WM_RBUTTONDOWN) {
MessageBox()//I am not sure of the Arg's of MessageBox right now
}
}
PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC,&WindowProc)
-
Aug 31st, 2000, 01:47 PM
#3
Keep in mind that C++ datatypes are different from VB. In VB, we would declare almost everything as Long but here we can be more specific.
Code:
LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
Regarding MessageBox arguments:
Code:
int nRes = MessageBox("MessageBox Text", "MyProgram", MB_OK | MB_ICONEXCLAMATION);
-
Aug 31st, 2000, 01:58 PM
#4
Monday Morning Lunatic
Megatron - you missed the first argument to MessageBox...
Code:
int MessageBox(HWND hWndOwner, LPCTSTR lpszText, LPCTSTR lpszTitle, UINT nFlags);
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 31st, 2000, 03:04 PM
#5
Strange. The one I use is:
Code:
MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, UNIT nType)
-
Aug 31st, 2000, 03:12 PM
#6
Lively Member
The MFC version doesnt need an HWND, the regular API one does. At least that is how I understand it.
-
Aug 31st, 2000, 03:19 PM
#7
Monday Morning Lunatic
In MFC, the function without an HWND is a member function of CWnd. Since CWnd has a member variable m_hwnd - it doesn't bother you with having to type it in. I think it expands to something like:
Code:
int CWnd::MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, UINT nFlags) {
return ::MessageBox(m_hWnd, lpszTest, lpszCaption, nFlags);
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|