473,396 Members | 2,020 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,396 software developers and data experts.

Communicating Between Two Forms

How can I call a function located in Form1 while in the scope of Form2?

I've tried Form1.MyFunction() but I get a compile errors. Any ideas?

Thanks.
Jul 21 '05 #1
4 1186
Well, in order to call a function of a class, it must be instantiated
(unless it is a static method). Make sure you have a reference to the
second form (assuming this in a WindowsForm application), then you should be
able to call any public method.

What is the compiler error that you are getting?

"ReMEn" <Re***@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
How can I call a function located in Form1 while in the scope of Form2?

I've tried Form1.MyFunction() but I get a compile errors. Any ideas?

Thanks.

Jul 21 '05 #2
Let me further explain this...I have 2 forms, one is a Main form, the other
is equivalent to a dialoag box.

In my main form, Main.h - I have included "Dialog.h" for use within my main
class. I removed my Dialog.cpp which the form designer creates because I
don't think there is a need for it.

I have a button on my main form in which when you click it, it will dispay
the Dialog form. This is why I have dialog.h included before my main class.

Within my dialog, I have a procedure which must call a function found in the
main form class. You asked for the compile errors, and they are:
"Form1 is not a class or namespace name" and
"MyFunction identifier not found, even with argument dependant lookup"

After giving some thought, I'm thinking the reason I get compile errors is
because I have included the dialog.h before the main class is even processed.
Can that make a difference?

Is there any way around this?

Thanks
Jul 21 '05 #3
I am not a C++ guy, but maybe I can help. You are trying to access
method from your main form in the dialog form, right? Maybe you should
import the Main.h in the Dialog.h to work? The compilator says that it
cannot find Form1 is (it is in your Main.h and you need to import it in
your Dialog.h)

Regards,

Philip Hristov.

Jul 21 '05 #4
ReMen,

I think that the way you want to use it is not very much accoording OOP.

Why do you not create a component where in is your method and use that in
both forms.

Cor
Jul 21 '05 #5

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

Similar topics

1
by: Martin | last post by:
This is probably a very easy one but I just can't put my finger on the communicating events name:- I have a MDIform with a couple of child forms. The child forms scroll vertically at run time...
13
by: Craig | last post by:
Hey all, Here's the situation: - two websites, one on domain1 and the other on domain2 - domain1 opens a new window which is a javascript app from domain2 - domain1 needs to communicate with...
3
by: Stan | last post by:
Hallo, I have developed an application in MS Access 2000 (Polish version) under MS Windows XP prof (also Polish). Now I would like to run this code on MS Windows XP EN and MS Access XP EN. I have...
1
by: Serdar C. | last post by:
hello again, i have another question... i am writing a program with 2 windows forms... first form have a search button and several text buttons to list the data loaded from an sql database ...
1
by: TGF | last post by:
Hello, I have a little dilemma (At least it is to me). I have two classes, Class A and class B, where Class A contains the UI thread and class B contains another thread. I want to be able to...
6
by: AMeador | last post by:
I have a form where a user will check boxes next to items that have been completed. They will click a button on the form to mark the items as completed. When they do this, I will have the 'parent'...
6
by: PaulN | last post by:
I need to instantiate a class (Class1) in the startup form (Form1), set some of Class1's properties then open another form (Form2) and have it read Class1's properties and set the remainder of...
4
by: ReMEn | last post by:
How can I call a function located in Form1 while in the scope of Form2? I've tried Form1.MyFunction() but I get a compile errors. Any ideas? Thanks.
2
by: Jasper Jones | last post by:
I have a main form which has a list of items from a table on my database. If I click one of these items it brings up a second form which lets you edit the details for that item. If I change an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
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.