Hi all,

I am about to replace an existing program by a C#
version. The old program is startet by a main program.

If the program is startet a second time, it sends a user
defined windows message to the first instance and
terminates.

In win32 this is not problem, but how can I add a message
handler for a user defined windows message to a .NET
form???

Anybody out there who can tell???
Hans.

Re: How can I receive a user windows message in .NET by Bob

Bob
Tue Dec 16 04:07:19 CST 2003

Override the WndProc method and catch the message there.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Hans" <anonymous@discussions.microsoft.com> wrote in message
news:086e01c3c3a8$67264830$a301280a@phx.gbl...
> Hi all,
>
> I am about to replace an existing program by a C#
> version. The old program is startet by a main program.
>
> If the program is startet a second time, it sends a user
> defined windows message to the first instance and
> terminates.
>
> In win32 this is not problem, but how can I add a message
> handler for a user defined windows message to a .NET
> form???
>
> Anybody out there who can tell???
> Hans.



Re: How can I receive a user windows message in .NET by hirf-spam-me-here

hirf-spam-me-here
Tue Dec 16 04:22:45 CST 2003

* "Hans" <anonymous@discussions.microsoft.com> scripsit:
> I am about to replace an existing program by a C#
> version. The old program is startet by a main program.
>
> If the program is startet a second time, it sends a user
> defined windows message to the first instance and
> terminates.
>
> In win32 this is not problem, but how can I add a message
> handler for a user defined windows message to a .NET
> form???

Add this to your form:

\\\
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = ... Then
...
End If
End Sub
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Re: How can I receive a user windows message in .NET by Gerhard

Gerhard
Wed Dec 17 04:47:01 CST 2003

Herfried K. Wagner [MVP] wrote:

>>I am about to replace an existing program by a C#
>>version. The old program is startet by a main program.
>>
>>If the program is startet a second time, it sends a user
>>defined windows message to the first instance and
>>terminates.
>>
>>In win32 this is not problem, but how can I add a message
>>handler for a user defined windows message to a .NET
>>form???
>
>
> Add this to your form:
>
> \\\
> Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
> If m.Msg = ... Then
> ...
> End If
> End Sub
> ///
>

Hm, I doubt his C# compiler will like this code ...

Gerhard Menzl
--
Humans may reply by replacing the obviously faked part of my e-mail
address with "kapsch".


Re: How can I receive a user windows message in .NET by hirf-spam-me-here

hirf-spam-me-here
Wed Dec 17 04:55:35 CST 2003

* Gerhard Menzl <gerhard.menzl@spambucket.net> scripsit:
>>> In win32 this is not problem, but how can I add a message handler
>>> for a user defined windows message to a .NET form???
>
>> Add this to your form:
>
>> \\\
>
>> Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
>> If m.Msg = ... Then
>> ...
>> End If
>> End Sub
>> ///
>>
>
> Hm, I doubt his C# compiler will like this code ...

Siimply override the form's 'WndProc'...

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Re: How can I receive a user windows message in .NET by Jacek

Jacek
Thu Dec 18 03:05:26 CST 2003

And as a result you will end up controling every event in your form and will
be forced to reimplement almost every behaviuor.

You should pass all unporcessed messages to base.WndProc(ref m) for further
processing at the end of function call.

Jacek

Uzytkownik "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> napisal w
wiadomosci news:brpcmr$60p2b$1@ID-208219.news.uni-berlin.de...
> * Gerhard Menzl <gerhard.menzl@spambucket.net> scripsit:
> >>> In win32 this is not problem, but how can I add a message handler
> >>> for a user defined windows message to a .NET form???
> >
> >> Add this to your form:
> >
> >> \\\
> >
> >> Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
> >> If m.Msg = ... Then
> >> ...
> >> End If
> >> End Sub
> >> ///
> >>
> >
> > Hm, I doubt his C# compiler will like this code ...
>
> Siimply override the form's 'WndProc'...
>
> ;-)
>
> --
> Herfried K. Wagner [MVP]
> <http://www.mvps.org/dotnet>



Re: How can I receive a user windows message in .NET by hirf-spam-me-here

hirf-spam-me-here
Thu Dec 18 04:36:31 CST 2003

* "Jacek" <infodata@acn.waw.pl> scripsit:
> And as a result you will end up controling every event in your form and will
> be forced to reimplement almost every behaviuor.
>
> You should pass all unporcessed messages to base.WndProc(ref m) for further
> processing at the end of function call.

ACK. Sorry, I forgot to write this line...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Re: How can I receive a user windows message in .NET by Saurabh

Saurabh
Thu Dec 18 09:52:05 CST 2003

I handled WM_NCPAINT and painted an additional button in the title bar. I
called the base.WndProc at the end of the function and it doesn't work, my
button just flickers for a moment and the title bar becomes blank again. I
moved the call to the base class implementation as first line of the
function and it all seems to work fine.

Should the call to base class be at the beginning or end of the function?

--Saurabh

"Jacek" <infodata@acn.waw.pl> wrote in message
news:%23uvpiYUxDHA.540@tk2msftngp13.phx.gbl...
> And as a result you will end up controling every event in your form and
will
> be forced to reimplement almost every behaviuor.
>
> You should pass all unporcessed messages to base.WndProc(ref m) for
further
> processing at the end of function call.
>
> Jacek
>
> Uzytkownik "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> napisal w
> wiadomosci news:brpcmr$60p2b$1@ID-208219.news.uni-berlin.de...
> > * Gerhard Menzl <gerhard.menzl@spambucket.net> scripsit:
> > >>> In win32 this is not problem, but how can I add a message handler
> > >>> for a user defined windows message to a .NET form???
> > >
> > >> Add this to your form:
> > >
> > >> \\\
> > >
> > >> Protected Overrides Sub WndProc(ByRef m As
> System.Windows.Forms.Message)
> > >> If m.Msg = ... Then
> > >> ...
> > >> End If
> > >> End Sub
> > >> ///
> > >>
> > >
> > > Hm, I doubt his C# compiler will like this code ...
> >
> > Siimply override the form's 'WndProc'...
> >
> > ;-)
> >
> > --
> > Herfried K. Wagner [MVP]
> > <http://www.mvps.org/dotnet>
>
>



Re: How can I receive a user windows message in .NET by Claes

Claes
Fri Dec 19 06:58:57 CST 2003

It depends. If you process the message yourself you (probably)
don't want to call the base class

In your case the base class will paint over the stuff that you
just painted.

For WM_NCPAINT you should also set m.Result = IntPtr.Zero

/claes

"Saurabh" <saurabh@nagpurcity.net> wrote in message
news:%23BTic8XxDHA.2528@TK2MSFTNGP10.phx.gbl...
> I handled WM_NCPAINT and painted an additional button in the title bar. I
> called the base.WndProc at the end of the function and it doesn't work, my
> button just flickers for a moment and the title bar becomes blank again. I
> moved the call to the base class implementation as first line of the
> function and it all seems to work fine.
>
> Should the call to base class be at the beginning or end of the function?
>
> --Saurabh
>
> "Jacek" <infodata@acn.waw.pl> wrote in message
> news:%23uvpiYUxDHA.540@tk2msftngp13.phx.gbl...
> > And as a result you will end up controling every event in your form and
> will
> > be forced to reimplement almost every behaviuor.
> >
> > You should pass all unporcessed messages to base.WndProc(ref m) for
> further
> > processing at the end of function call.
> >
> > Jacek
> >
> > Uzytkownik "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> napisal
w
> > wiadomosci news:brpcmr$60p2b$1@ID-208219.news.uni-berlin.de...
> > > * Gerhard Menzl <gerhard.menzl@spambucket.net> scripsit:
> > > >>> In win32 this is not problem, but how can I add a message handler
> > > >>> for a user defined windows message to a .NET form???
> > > >
> > > >> Add this to your form:
> > > >
> > > >> \\\
> > > >
> > > >> Protected Overrides Sub WndProc(ByRef m As
> > System.Windows.Forms.Message)
> > > >> If m.Msg = ... Then
> > > >> ...
> > > >> End If
> > > >> End Sub
> > > >> ///
> > > >>
> > > >
> > > > Hm, I doubt his C# compiler will like this code ...
> > >
> > > Siimply override the form's 'WndProc'...
> > >
> > > ;-)
> > >
> > > --
> > > Herfried K. Wagner [MVP]
> > > <http://www.mvps.org/dotnet>
> >
> >
>
>