Solved

Borland C++, Calling public function from parent form

Posted on 2007-11-15
4
1,184 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 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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 viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now