473,998 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WndProc Message Forwarding

Hi,
Does anyone know if there is a way to foward messages that a form
receives to another application form.
I was thinking i could override WndProc, but i don't know how to
forward any messages to another application?!

Any ideas greatfully appreciated (in advance!).
James Randle.

Jul 12 '06 #1
7 3232

pi**********@ho tmail.com wrote:
Hi,
Does anyone know if there is a way to foward messages that a form
receives to another application form.
I was thinking i could override WndProc, but i don't know how to
forward any messages to another application?!

Any ideas greatfully appreciated (in advance!).
James Randle.

You can forward messages by using SendMessage or PostMessage from the
Win32 API. Check pinvoke.net for the signatures.

Jul 12 '06 #2
Hello James,

Redirecting all of the messages that a form receives might not be a good
approach of what you would like to accomplish because messages such as
WM_PAINT contain information about that particular form's invalidated region.

If you still would like to do it, you can use the Win32 API SendMessage to
send the received message and its related parameters to another HWND -- the
handle to the desired window. You can find it using FindWindow if you know
its title and/or class name.

The P/Invoke signature for SendMessage and FindWindow can be found at
http://www.pinvoke.net/default.aspx/user32.SendMessage and
http://www.pinvoke.net/default.aspx/user32.FindWindow. Remember to include
the System.Runtime. InteropServices namespace to the file where you include
these functions' definitions.

You will have to override WndProc and make a call to SendMessage:

SendMessage(m.H Wnd, m.Msg, m.WParam, m.LParam);

I hope this helps you.
--
Best regards,

Stanimir Stoyanov
ad***@nospam.st oyanoff.info
"pi**********@h otmail.com" wrote:
Hi,
Does anyone know if there is a way to foward messages that a form
receives to another application form.
I was thinking i could override WndProc, but i don't know how to
forward any messages to another application?!

Any ideas greatfully appreciated (in advance!).
James Randle.

Jul 12 '06 #3
Thankyou both for you rapid replies.

Stanimir, thanks for pointing out the 'unwanted' events. Presumably i
can just process these in WndProc as per normal?

Thanks again :-)

Jul 12 '06 #4
Yes, you can check if the Msg ID is one of these and simply not redirect them.
--
Best regards,

Stanimir Stoyanov
ad***@nospam.st oyanoff.info
"pi**********@h otmail.com" wrote:
Thankyou both for you rapid replies.

Stanimir, thanks for pointing out the 'unwanted' events. Presumably i
can just process these in WndProc as per normal?

Thanks again :-)

Jul 12 '06 #5
Hi again,
I've managed to get all the messages forwarding to a different
application window (notepad for simplicity), but they dont seem to be
processed properly. I can see them getting there in Spy++.

For instance, if i click on my form in the region that represents the
other applications mainmenu region, nothing happens!

Do i need to send the messages to different child windows depending on
their location? And if so, how can i get a handle to the menu?

So many questions!!
Again, thanks in advance.

Stanimir Stoyanov wrote:
Yes, you can check if the Msg ID is one of these and simply not redirect them.
--
Best regards,

Stanimir Stoyanov
ad***@nospam.st oyanoff.info
"pi**********@h otmail.com" wrote:
Thankyou both for you rapid replies.

Stanimir, thanks for pointing out the 'unwanted' events. Presumably i
can just process these in WndProc as per normal?

Thanks again :-)
Jul 12 '06 #6
>I've managed to get all the messages forwarding to a different
>application window (notepad for simplicity), but they dont seem to be
processed properly. I can see them getting there in Spy++.
You can't just blindly forward window messages to another application
and expect it to work. Many message parameters contain pointers and
handles that will be invalid in the other process.

>For instance, if i click on my form in the region that represents the
other applications mainmenu region, nothing happens!

Do i need to send the messages to different child windows depending on
their location? And if so, how can i get a handle to the menu?
If you want to fake input in another application there are other APIs
to use.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 13 '06 #7
Mattias,
Cheers for replying. Do you have any ideas what these APIs are?

James

Mattias Sjögren wrote:
I've managed to get all the messages forwarding to a different
application window (notepad for simplicity), but they dont seem to be
processed properly. I can see them getting there in Spy++.

You can't just blindly forward window messages to another application
and expect it to work. Many message parameters contain pointers and
handles that will be invalid in the other process.

For instance, if i click on my form in the region that represents the
other applications mainmenu region, nothing happens!

Do i need to send the messages to different child windows depending on
their location? And if so, how can i get a handle to the menu?

If you want to fake input in another application there are other APIs
to use.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 14 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6647
by: Beach Potato | last post by:
Hi: I've searched newsgroups and various archives, including MSDN & MFC sources, but at this point failed to locate an accurate and simple implementation of WndProc function for MSWindows window objects. Something like: class BaseWindow { virtual LRESULT WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
0
2540
by: sshuangw | last post by:
Hello: I am encountering a very weird issue with MDI child, Overriden WndProc function and hidden form. Basically, the application has two forms, Form1(parent form), Form2(Child form), Form2's WndProc method is overriden, if the message is CLOSE message, just hide the form. I first initialize and show the child form, then close it by clicking the Close(X) button, the overriden WndProc method gets invoked, and the form is hidden. Then
2
21484
by: Ed Sutton | last post by:
How can a WndProc be created inside a component? Currently I have a WndProc in my frmMain. It looks for WM_DEVICECHANGE messages for connection and removal events for a USB/Serial device. My frmMain uses a component to communicate with a USB/Serial device. I would prefer that this component handle the WM_DEVICECHANGE messages internally and only fires events to my frmMain when my USB device connects or disconnects. In case anyone...
0
4516
by: cyrille | last post by:
Hello from example from web i did a little code to avoiding columnHeader resize. this code seems to work well, but when I put a 'normal' ListView on the same Form than my overrided ListView it seems to stop working. if I'm resizing 'normal' ListView ColumnHeaders, then I can resizing ColumnHeaders of my overrided ListView. If I don't resizing 'normal' ListView ColumnHeaders, then resizing of my overrided ListView ColumnHeaders is...
2
2478
by: dworthem | last post by:
if I have the compiler option /clr:oldSyntax in a Windows Forms application protected: void WndProc(System::Windows::Forms::Message* m) is called If I remove oldSyntax protected:
2
3945
by: Derrick | last post by:
Hello all; I'm trying to create a UI that's a little atypical. In the main form's Paint event handler, I draw an image on the form - this is what I want to by my "real" UI. I turned off the form border, and set the form's background and transparency key to be the same value. As you know, because of this there is no sign of the form, just the image I painted. So far, so good. Since the form border - and hence the title bar - is...
2
4101
by: Chris Ashley | last post by:
Hi, I'm overriding WndProc to process some custom messages like so: protected override void WndProc(ref Message m) { if (m.Msg == ImageFileMsg.MSG_IF_NEW_DATA) { ProcessNewDataMessage(m);
3
3356
by: Newbie Coder | last post by:
I am trying to override WndProc like I would in this VB.NET sub. How do I do it? <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissi ons.SecurityAction.Demand, Name:="FullTrust")_ Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_QUERYENDSESSION Then ShutDownWindows = True End If MyBase.WndProc(m)
0
1347
by: makifsar | last post by:
I am using a comserver to communicate remote equipments. This server gives response via WndProc. First I call READ function to start communication and remote equipment gives response this via WndProc. Mw request is, I want to sleep READ thead and after taking right message from WndProc, wake up this thead return this value to main thead. I am trying some methods using delagate but I can not achive it. My Program like this Public Void...
0
10425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10241
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11944
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11504
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11756
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11010
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5271
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3855
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.