470,815 Members | 1,133 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.


108 100+
Hi experts,

Can anyone explain to me about the Wndproc? I'm currently doing conversion from Borland C++ to C++.NET and this is my first to encounter this WndProc since i'm not a Windows programmer. Is there anything alternative for this in .net? Please give me some idea about it.

Sep 27 '07 #1
5 1936
7,872 Expert 4TB
WndProc() is the "message pump" for windows forms (actually I think any windows application can use it)
it gets all the messages like WM_MouseClick and things like that.

Now I'm unsure about the C++ in .NET, but VB.NET/C# don't really have a general use for overriding that function, as it has methods for mouseclicks and everything built in.
Sep 27 '07 #2
WndProc is a CALL BACK function used to respond the user events after the window has been created and displayed.It is not the message pump, the message pump is,
while(GetMessage(&msg, NULL, 0, 0))
The GetMessage() will get the message from the system message queue and give it to corresponding WndProc().The WndProc will handle the message accordingly.Since it is a CALLBACK function, Windows Operating system will call the WndProc() not our application.


Sep 28 '07 #3
7,872 Expert 4TB
Hehe I was going to say I got schooled there, but GetMessage() is a win32 api function (or so msdn would claim) and not part of the .NET framework specifically.
For access to windows messages, you would use the WndProc() function
Sep 28 '07 #4
108 100+
Thanks to all your response. I have a follow up questions to you guys.

How can I implement the WndProc in .Net? In Win32 it uses HWND as handle to the window but in .Net I think is only the message. If I have a SetTimer function which also need handle as parameter so how can I do that?

// Create a timer to schedule updates
SetTimer( Handle, // handle to window
TIMER, // timer identifier
ONE_SECOND, // 1-second interval
(TIMERPROC) NULL); // no timer callback

In Wndproc()
if ( Message.WParam == TIMER )
...Do this...

What will be the equivalent of Handle??

Hope you can help me guys.
Oct 1 '07 #5
7,872 Expert 4TB
The Message object in .NET has a property that is the handle to the window.
Oct 1 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by cyrille | last post: by
2 posts views Thread by Derrick | last post: by
3 posts views Thread by S Wheeler | last post: by
4 posts views Thread by Rob | last post: by
4 posts views Thread by Piotrekk | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.