473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to send a message (with result) from child control to parent form?

HaLo2FrEeEk
404 256MB
I've got an inherited panel on my form which overrides WndProc() and catches the 0x84 (WM_NCHITTEST) message. I do some processing on it and I'd like to know if there's a way to send that message, along with the result that I calculate, up to the parent form that contains the panel. I looked into the API method SendMessage(), but all you can send is the message (0x84), lparam and wparam, not the result (unless I'm missing something).

Does anyone know a way I could do this? I want to use this panel to control the sizing and moving of the form. Right now I can size and move the panel just fine, as though it were its own window, but I need to send it up to the parent.
Jan 11 '11 #1
7 4995
Rabbit
12,516 Expert Mod 8TB
This is out of my area of experience so I can only offer a general suggestion. Couldn't you also override the parent WndProc()?
Jan 11 '11 #2
GaryTexmo
1,501 Expert 1GB
I may be wrong, but I think the result goes into wparam and lparam somehow, doesn't it? To be honest, I've never used this.

Having said that, since this is within your app, why not set up some delegates to pass data to the parent form?

*Edit: err, it occurred to me that you might mean the parent class, if that's the case I have no idea. If you mean the parent form (that contains the control), then yes you should be able to use a delegate.
Jan 11 '11 #3
HaLo2FrEeEk
404 256MB
I could override the parent WndProc too, but it's not receiving the message, the panel is. I want to catch the message with the panel, calculate the result, and send it to the parent, so that when I resize the panel control, the parent form is resized as well.

The form contains the inherited panel, I access the parent with Parent.[property], but it sees the parent as a control and not as a form, so I can't access its wndproc or any other methods, or other controls.
Jan 11 '11 #4
Rabbit
12,516 Expert Mod 8TB
Would it be possible to use SendMessage() to send it to the parent form and then do the calculations at that level instead?
Jan 11 '11 #5
hype261
207 100+
Halo,

Like GaryTexmo mentioned this is a perfect place to use events and delegates to solve your problem. Have your panel create a custom event and delegate and then have your form hook into that event. When ever you catch the 0x84 (WM_NCHITTEST) message just raise the event.
Jan 11 '11 #6
HaLo2FrEeEk
404 256MB
Erm...I don't know how to do that. I know I can do Parent.Invoke(), is that what I'm looking for?
Jan 11 '11 #7
hype261
207 100+
Halo,

Here is a tutorial on how to use events and delegates.

http://www.csharp-station.com/Tutorials/lesson14.aspx
Jan 11 '11 #8

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

Similar topics

1
by: Lumpierbritches | last post by:
Thank you in advance. Is there a way to anchor a child form say beside the parent form, when that data is needed? Michael
3
by: Omar Llanos | last post by:
I have Form1 and Form2 (which is inherited from Form1), and I created a button in Form2 that will fill up a textbox in Form1. What code would do that? I tried the simplest way: //from child...
2
by: Fred | last post by:
Is there a good code sample, in C#, showing how to send eamil with attachment, from a Windows Form like 'Send To' in Word, that will pickup Contacts in Outlook/Exchange 2000. I have searched...
5
by: mimi | last post by:
Hi, I've been searching all the posts and articles but couldn't find any example on how to send attachments with pop3 using C#. Does anyone have one or know how? Thanks
2
by: Paul | last post by:
Hi this is related to a previous post, hopefully just a bit clearer description o the problem. I have a parent form that opens a new form (child form) while still leaving the parent form open....
3
by: LEE | last post by:
I'd like to call a function of child from parent form, there is an issue: Form1 (parent) calls "LoadMe" Sub in Form2 (child), it works using the codes (in Form1): Dim frm As New Form3()...
16
by: John | last post by:
Hi I have posted this question several times but have received no reply. I have a main form which contains a panel which in turn contains a child form, like this; MainForm->MyPanel->ChildForm....
3
by: mabond | last post by:
Firstly I hope I'm in the right forum ..... if not can someone re-direct me please. I have an application with a main form properties set to mdiparent = true. Toolbar button allows user to open...
4
by: FNA access | last post by:
I have read through many posts that are relevant to my topic and have not had any success. I want to click a button on my form and send an email to a list of people I have stored in a table with...
8
by: svibuk | last post by:
i have a div element with a child control in it which gets populated with data depending on data teh control expands and also the div. if i set the div width the data overflows in the extended...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.