473,573 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1123
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.co m

"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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.co m

"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** ************@g4 3g2000cwa.googl egroups.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_interfac e someFormIn_ADLL ;
this.someevent += new
someFormIn_ADLL .btnCloseEvent( this.Handlesome vent);

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_interfac e someFormIn_ADLL ;
this.someevent += new
someFormIn_ADLL .btnCloseEvent( this.Handlesome vent);
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_interfac e someFormIn_ADLL = ...;

someFormIn_ADLL .someevent += new
someFormIn_ADLL .btnCloseEvent( this.Handlesome vent);

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
1647
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 doing a project of data mining, and I run a mysql database to store my data. the database structure:
15
3665
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 cumbersome to always include std. I somewhere found a trick to overcome this problem. By using using std::cout;
18
2616
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> Assume that this library will be used by other groups. I think the answer
7
3294
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 buffer into the character pointer. The code looks like the following: #include <stdio.h> #include <stdlib.h> #include "stdafx.h" BOOL APIENTRY...
13
2906
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, myDisplay.cpp and tween.cpp) a header file (canvas.h) and a makefile that compiles it for linux. The tween.cpp is the main file, and it only contains...
4
5815
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 project is called SCLaser. When I right-click on the #include "SCLaserDoc.h" and select Open Document SCLaserDoc.h, it can't find the file and...
3
2691
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 directories contain a file named "cppfile1.h". In my main project I #include "cppfile1.h". I rely on the order of paths in additional include...
8
3481
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 DerivedClass in myEXE, which gives this error: The type 'BaseAssembly.SomeClass' is defined in an assembly that is not referenced. You must add a...
5
3261
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. The error i get is Error 100 error LNK2001: unresolved external symbol "public: virtual void __thiscall CWnd::PostNcDestroy(void)"...
10
2088
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 don't somehow share the code. So, I copy the folder P1 is in, change the new folder name, and is VS2005 to change all occurrences of P1's name tp...
0
8033
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. ...
1
7796
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...
0
8077
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...
0
6426
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...
0
3734
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3739
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2224
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
1
1316
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1044
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...

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.