Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Borland C++, Calling public function from parent form

Posted on 2007-11-15
4
Medium Priority
?
1,197 Views
Last Modified: 2010-04-21
I have 2 forms. TBowling calls TFormGame, but how can I call MoveBowlingPin from TFormGame?
__fastcall TBowling::TBowling(TComponent* Owner)
    : TForm(Owner)
{
    FormGame = new TFormGame(this);
    FormGame->Show();
}
void TBowling::MoveBowlingPin(int id, double x, double y, double z, double rx, double ry, double rz)
{
    for(int i=0;i<Figures->Count;i++)
    {
 
        Figure3d *figure = ((Figure3d*)Figures->Items[i]);
 
        if(figure->kind == id)
        {
            figure->Move(x,y,z);
            figure->Rotate(rx,ry,rz);
        }
 
    }
}
 
// --------------------------------------------------
 
__fastcall TFormGame::TFormGame(TComponent* Owner)
    : TForm(Owner)
{
    // Code to call
    // MoveBowlingPin( ... ) ?
}

Open in new window

0
Comment
Question by:avatar-e
  • 2
4 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20290779
you have to post back a message with PostMessage() function, and override the DefWndProc() function of the parent dialog.
0
 
LVL 7

Author Comment

by:avatar-e
ID: 20290831
Ok, but can you provide a small code snippet with those instructions please (I'm mainly a C#, VB, Java developer)
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 20290940
Since your 'TBowling' class is the owner of 'TFormGame', you could just

__fastcall TFormGame::TFormGame(TComponent* Owner)
    : TForm(Owner)
{
    TBowling* p =(TBowling*) Owner;
   
    p->MoveBowlingPin( ... );
}
0
 
LVL 7

Author Closing Comment

by:avatar-e
ID: 31409375
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question