Solved

Borland C++, Calling public function from parent form

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Outlook creates tmp files 2 43
Selecting Operating System at boot screen 4 62
Removing line numbers from left column in config file 7 52
Change size 15 43
Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

770 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