473,382 Members | 1,480 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,382 software developers and data experts.

Do I need to include this project?

How can I communicate with a parent form if that parent form type isn't
included in the project?

my.EXE project references a.DLL. a.DLL has a couple of forms that
my.exe uses. When my.exe opens a form in a.DLL, users can edit data in
that form. This data came out of a DataGrid on my.exe, which in turn
came from master.db. On the form in a.DLL, the user edits the data
and clicks update. A method in a.DLL saves to the DB. Now I need to
refresh the DataGrid in my.exe. What is the best way to do that?

Normally, I could cast the sender from a.DLL and refresh the grid in
my.exe. I can't do that here because my.exe isn't referencing a.DLL.
I'd like to keep a.DLL very generic, which means not including my.exe
as a reference, since the form in a.DLL can be called by any
application.

Any suggestions?

Thanks,
Brett

Jan 13 '06 #1
6 1114
Brett,

What you should do is define an interface in c.dll (another dll
basically) which the forms in a.dll implement. Then, you can cast the forms
to that interface, since both a.dll and the exe can reference c.dll (with
the interface in it).

The interface would expose a method that the form in the exe can
subscribe to, which would tell it to notify itself.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
How can I communicate with a parent form if that parent form type isn't
included in the project?

my.EXE project references a.DLL. a.DLL has a couple of forms that
my.exe uses. When my.exe opens a form in a.DLL, users can edit data in
that form. This data came out of a DataGrid on my.exe, which in turn
came from master.db. On the form in a.DLL, the user edits the data
and clicks update. A method in a.DLL saves to the DB. Now I need to
refresh the DataGrid in my.exe. What is the best way to do that?

Normally, I could cast the sender from a.DLL and refresh the grid in
my.exe. I can't do that here because my.exe isn't referencing a.DLL.
I'd like to keep a.DLL very generic, which means not including my.exe
as a reference, since the form in a.DLL can be called by any
application.

Any suggestions?

Thanks,
Brett

Jan 13 '06 #2
That would mean in a.dll, the form I pass in will be of type c
(interface). From there, I should be able to reference the form,
assuming it is a property of the interface. For example:

c.Form1

The property defines Form1 as a type of myexe.Form1. Or do I need an
interface for each form? Why do you say I need to cast?

Thanks,
Brett

Jan 13 '06 #3
Brett,

I am saying go the other way. When the EXE creates the form in a.dll,
have it cast the instance of the form created to your interface, and then
subscribe to the event exposed by it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11********************@g43g2000cwa.googlegrou ps.com...
That would mean in a.dll, the form I pass in will be of type c
(interface). From there, I should be able to reference the form,
assuming it is a property of the interface. For example:

c.Form1

The property defines Form1 as a type of myexe.Form1. Or do I need an
interface for each form? Why do you say I need to cast?

Thanks,
Brett

Jan 13 '06 #4
Ok. Maybe I don't fully see it because I don't understand this part:

The interface would expose a method that the form in the exe can
subscribe to, which would tell it to notify itself.

Let's say the exposed event is the close button click in c.dll. Would
it look something similar to this:

[my.exe form1]
private I_cdll_interface someFormIn_ADLL;
this.someevent += new
someFormIn_ADLL.btnCloseEvent(this.Handlesomevent) ;

What event would I use in my.exe to and listen and take action? Where
would it be defined?

Thanks,
Brett

Jan 13 '06 #5
Brett Romero wrote:
Ok. Maybe I don't fully see it because I don't understand this part:

The interface would expose a method that the form in the exe can
subscribe to, which would tell it to notify itself.

Let's say the exposed event is the close button click in c.dll. Would
it look something similar to this:

[my.exe form1]
private I_cdll_interface someFormIn_ADLL;
this.someevent += new
someFormIn_ADLL.btnCloseEvent(this.Handlesomevent) ;
No - that would be subscribing to an event within the form in the EXE.
What event would I use in my.exe to and listen and take action? Where
would it be defined?


The event would be *declared* in the interface in the DLL. It would be
*implemented* by the forms in the DLL (and possibly by the forms in the
EXE, if you wanted). It would be *used* by the forms in the EXE, which
would then subscribe to the events using handlers which would probably
be in the EXE.

To change your example:

private I_cdll_interface someFormIn_ADLL = ...;

someFormIn_ADLL.someevent += new
someFormIn_ADLL.btnCloseEvent(this.Handlesomevent) ;

Jon

Jan 13 '06 #6
The problem here is that any other application that uses c.dll will
also need a.dll right? As more DLLs use the interface, that's more
DLLs the apps will have to drag around.

Brett

Jan 13 '06 #7

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

Similar topics

2
by: Alexandre MELARD | last post by:
Hi, My name is alexandre, I am 4th year student at the Napier university of edinburgh. I am finishing my year and do a presentation of my honours project next wednesday (the 5th of May). I am...
15
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit...
18
by: Tuckers | last post by:
My question is, if I have created my own library which lives in its own install directory, to refer to its header file is it better to use #include "MyLibrary.h" or #include <MyLibrary.h> ...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
13
by: Brett Baisley | last post by:
At school, we do all of our coding in emacs, but I am trying to get the example apps working at home using Visual C++.net. In the example, there are 4 .cpp files (canvas.cpp, main.cpp,...
4
by: Anders Eriksson | last post by:
Hello! I'm using VC++ 7.1 and MFC. In a header file that is located in a different directory that the main project I include a header file that is located in the main project directory. The...
3
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include...
8
by: Brett Romero | last post by:
I have this situation: myEXE <needs< DerivedClass <which needs< BaseClass Meaning, myEXE is using a type defined in DerivedClass, which inherits from BaseClass. I include a reference to...
5
by: BK-Chicago | last post by:
I am in the midst of porting a massive MFC application from VS6.0 to VS8.0. While i have fixed most of the compile time errors, i do have quite a linker error that i have not been able to resolve....
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.