WndProc

S

S Wheeler

Hi -
I have a vc++ WinForms app. Can I override the WndProc so I can send custom
messages to my app. Is there any way to do this? I need to notify the main
form of events from a library. How is this done in VC++?
Thanks
 
B

Bruno van Dooren

Hi -
I have a vc++ WinForms app. Can I override the WndProc so I can send
custom
messages to my app. Is there any way to do this? I need to notify the main
form of events from a library. How is this done in VC++?
Thanks

Since you talk about WinForms, I assume you mean that you use .NET.
Normally your class library exposes a number of events (if that is
applicable of course) and your form application would provide delegates to
the class library to be called whenever the event is raised.

Or is your library not a .NET class library perhaps?

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
S

S Wheeler

Hi Bruno-
My library is a mixed mode, mulit-threaded dll. It was orginally a static
library but I could never get delegates to work using a static library.

Now, I have a new problem I am getting linker errors:

Generating Code...
Compiling managed resources...
Read in 68 resources from 'z:\Development\Project\DLL
Version\Gui\Form1.resX'
Writing resource file... Done.
Compiling resources...
Linking...
LINK : error LNK2020: unresolved token (0600003B) Host.Utils.Xml::Serialize
LINK : error LNK2020: unresolved token (0600003C)
Host.Utils.Xml::Deserialize
LINK : error LNK2020: unresolved token (0600003D) Host.Utils.Xml::Clone
LINK : fatal error LNK1120: 3 unresolved externals


These are my dot net methods (they are not exported) I was able to compile
and link as a static library with no problems - do you think this is a
namespace issue? Or do I need some "special" handling for mixed mode? Thanks
for your help!


I am trying to make my static lib a dll so I can (hopefully) use delegates,
but noted a number of articles showing sending messages to a wndproc and I
am concerned about delegates from worker threads (recall COM connection
points) so I considered using windows messages instead. Can a Form1 default
WndProc be overriddend - i.e.

protected:
void Form1::WndProc(Message* m)
{
switch(m->Msg)
{
default:
WndProc(m);
}
}
This crashes! So I suspect not.
 
B

Bruno van Dooren

Now, I have a new problem I am getting linker errors:
Generating Code...
Compiling managed resources...
Read in 68 resources from 'z:\Development\Project\DLL
Version\Gui\Form1.resX'
Writing resource file... Done.
Compiling resources...
Linking...
LINK : error LNK2020: unresolved token (0600003B)
Host.Utils.Xml::Serialize
LINK : error LNK2020: unresolved token (0600003C)
Host.Utils.Xml::Deserialize
LINK : error LNK2020: unresolved token (0600003D) Host.Utils.Xml::Clone
LINK : fatal error LNK1120: 3 unresolved externals

What is the declaration for those methods?
protected:
void Form1::WndProc(Message* m)
{
switch(m->Msg)
{
default:
WndProc(m);
}
}
This crashes! So I suspect not.

It should be possible to override WndProc:
http://www.codeproject.com/useritems/DisableNormalWindowState.asp

Comparing that to your example, I think you need to call base::WndProc
Your code goes into an infinite loop.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top