Solved

Borland C++, Calling public function from parent form

Posted on 2007-11-15
4
1,190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Industry Leaders: 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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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