473,396 Members | 1,789 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.

Problem with Pointers to a Form

4
Hi Guys,
I am trying to call a function CodeA which is present in all the forms. Only One form exists at any time. Form1 is the MainForm, the others children.
If I execute case 0 (MainForm) all is OK.
If I execute case 1 or 2 then MainForm->CodeA is called instead of Form2->CodeA or Form3->CodeA.

What am I doing wrong?.

Expand|Select|Wrap|Line Numbers
  1.  
  2. void __fastcall TForm1::rgFormClick(TObject *Sender)
  3. {
  4. //    TForm1    *DynForm;            // declared globally
  5.  
  6.     if (DynForm != this)
  7.         DynForm->Close();
  8.     switch (rgForm->ItemIndex)
  9.     {
  10.         case    0:
  11.             DynForm = this;
  12.             break;
  13.  
  14.         case    1:
  15.             (TObject *) DynForm = Form2;
  16.             break;
  17.  
  18.         case    2:
  19.             (TObject *) DynForm = Form3;
  20.     }
  21.     DynForm->Show();   // works fine
  22.     DynForm->CodeA();            // <--------------- Problem child
  23.  
  24. }
  25.  
  26.  
Regards
John
Nov 17 '06 #1
1 1073
zl1jk
4
Sorted it myself. For those that are interested.

void __fastcall TForm1::rgFormClick(TObject *Sender)
{

switch (rgForm->ItemIndex)
{
case 0:
if (DynForm)
DynForm->Hide();
(TForm1*) DynForm = dynamic_cast<TForm1*>(Form1);
break;

case 1:
if (DynForm)
if (LastIndex)
DynForm->Hide();
(TForm2*) DynForm = dynamic_cast<TForm2*>(Form2);
break;

case 2:
if (DynForm)
if (LastIndex)
DynForm->Hide();
(TForm3*) DynForm = dynamic_cast<TForm3*>(Form3);
break;
}
DynForm->Show();
DynForm->CodeA(); // <--------------- was the Problem child
LastIndex = rgForm->ItemIndex;
}
Nov 27 '06 #2

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

Similar topics

3
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
13
by: Joseph | last post by:
I was doing my assignment,but encountered a problem at last step!!!!!! for easy reading, i ommited lots of other things //=====================code begin================================...
3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a new page. Now, that some_dynamic_variable is...
4
by: Eric E | last post by:
Hi all, I have a fairly complex form in Access 2000. In particular, it has two subforms on separate tabs of a tab control. For the last two weeks, I've encountered the dreaded : "You can't...
6
by: Peter Oliphant | last post by:
Here is a simplification of my code. Basically, I have a class (A) that can be constructed using a function pointer to a function that returns a bool with no parameters. I then want to create an...
2
by: Chris | last post by:
Hi, I'm new to ASP.Net and Crystal but I've been playing with some samples and have run into a problem. If I put all my code into the Page_Init sub of a single form and run that form, the...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
9
by: David | last post by:
Hi all, I posted my question two days ago, and tried to solve this problem. but until now I didn't solve that. and I cut my codes so maybe this time it is more readable. ...
25
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void...
54
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...

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.