473,471 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dialog object access to caller's "this"?

Hello,

I am opening a modal dialog in the standard way using something like:

....all the standard setup stuff...
dlg.ShowDialog();

I need the dialog object to be able to access some of the methods back in
the object that created it (the code above). Is there some attribute,
method, or whatever within the dialog object that provides such access or do
I need to pass a reference to the calling object into the dialog object
after it is created but before ShowDialog is called?

Thanks,
Ray Mitchell
Nov 15 '05 #1
3 1861
You will need to pass it in.
"Ray Mitchell" <Ra*********@MeanOldTeacher.com> wrote in message
news:pt****************@newsread4.news.pas.earthli nk.net...
Hello,

I am opening a modal dialog in the standard way using something like:

...all the standard setup stuff...
dlg.ShowDialog();

I need the dialog object to be able to access some of the methods back in
the object that created it (the code above). Is there some attribute,
method, or whatever within the dialog object that provides such access or do I need to pass a reference to the calling object into the dialog object
after it is created but before ShowDialog is called?

Thanks,
Ray Mitchell

Nov 15 '05 #2
When you create an instance of your dialog object, you can pass a reference
to the owner in the constructor.

"Ray Mitchell" <Ra*********@MeanOldTeacher.com> wrote in message
news:pt****************@newsread4.news.pas.earthli nk.net...
Hello,

I am opening a modal dialog in the standard way using something like:

...all the standard setup stuff...
dlg.ShowDialog();

I need the dialog object to be able to access some of the methods back in
the object that created it (the code above). Is there some attribute,
method, or whatever within the dialog object that provides such access or do I need to pass a reference to the calling object into the dialog object
after it is created but before ShowDialog is called?

Thanks,
Ray Mitchell

Nov 15 '05 #3
Hi Ray,

You will need to pass the object through the Form Dialog's
constructor so that the dialog can reference back the object that
created it.
class Parent
{
void MyMethodThatCreatesTheDialog()
{
MyDialog form = new MyDialog(this);
MyDialog.ShowDialog();
}

// ...

}

Then MyDialog's constructor can keep a reference to the object
that created it.

MyDialog(Parent parent)
{
this._myParent = parent;
}

If the creating object is a windows based itself that will be the parent,
then you might like to use the ShowDialog(IWin32Window) overloaded method
to pass a reference to the parent dialog form.

Regards,
Aravind C
"Ray Mitchell" <Ra*********@MeanOldTeacher.com> wrote in message
news:pt****************@newsread4.news.pas.earthli nk.net...
Hello,

I am opening a modal dialog in the standard way using something like:

...all the standard setup stuff...
dlg.ShowDialog();

I need the dialog object to be able to access some of the methods back in
the object that created it (the code above). Is there some attribute,
method, or whatever within the dialog object that provides such access or do I need to pass a reference to the calling object into the dialog object
after it is created but before ShowDialog is called?

Thanks,
Ray Mitchell

Nov 15 '05 #4

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

Similar topics

1
by: Christoph | last post by:
newFieldElement = document.createElement( 'INPUT' ); newFieldElement.onblur = new Function( "calculatePremiumOptionTotal( this );" ); In my (dynamically generated) javascript, I've never had a...
32
by: Christopher Benson-Manica | last post by:
Is the following code legal, moral, and advisable? #include <iostream> class A { private: int a; public: A() : a(42) {}
7
by: relient | last post by:
Question: Why can't you access a private inherited field from a base class in a derived class? I have a *theory* of how this works, of which, I'm not completely sure of but makes logical sense to...
60
by: Dave | last post by:
I'm never quite sure whether to use "this." or not when referring to fields or properties in the same class. It obviously works just fine without it but sometimes I wonder if using this....
4
by: craig | last post by:
During construction of an object "parent", if you create a subobject that stores a pointer to the parent (through the "this" pointer), will that pointer be valid when the subobject is later called?...
2
by: Bryan | last post by:
Hello all, Can anyone explain when one should use the "document" object and when one should use the "this" object? Also, is the "self" object the same as the "document" or "this" object?
10
by: Angel Tsankov | last post by:
Hello! Is the following code illformed or does it yield undefined behaviour: class a {}; class b {
5
by: Polaris431 | last post by:
I notice that the Dataset designer generates code for properties that look like this: public string ID { get { try { return ((string) (this)); } catch (System.InvalidCastException e) {
6
by: andrew.bell.ia | last post by:
Hi, I've got this very simple code that I don't understand (output follows code). Why does access to the _field variable fail without the "this"? I thought that once _field was added to the...
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
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...
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,...
1
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...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.