Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2006

Tip: Looking for answers? Try searching our database.

WndProc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
S Wheeler - 05 Apr 2006 03:28 GMT
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
Bruno van Dooren - 05 Apr 2006 06:03 GMT
> 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?

Signature

Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

S Wheeler - 05 Apr 2006 14:32 GMT
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.

> > Hi -
> > I have a vc++ WinForms app. Can I override the WndProc so I can send
[quoted text clipped - 9 lines]
>
> Or is your library not a .NET class library perhaps?
Bruno van Dooren - 05 Apr 2006 19:01 GMT
> Now, I have a new problem I am getting linker errors:
>
[quoted text clipped - 11 lines]
> 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)
[quoted text clipped - 6 lines]
> }
> 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.

Signature

Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.