PDA

Tam Sürümünü Görmek İçin : VC++ .Net 2003 platformunda child form dan parent formun public üyelerine erişememe


kkirtac
02/05/2006, 15:09
selam arkadaşlar, bir mdiparent form bir de mdichild form um var, ancak child dan parent ın public üyelerine erişemiyorum, daha doğrusu child da parent için bir işaretçi oluşturuyorum ve bu satırda hata veriyor, koddan bir bölüm sunayım belki daha açlıklayıcı olur:
//Parent form's header file -> Form1.h
#include "costForm.h" //this is the child form's header
namespace Segmentation
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:: Data;
using namespace System:: Drawing;
using namespace System::IO;

public __gc class Form1 : public System::Windows::Forms::Form
{

public:

Form1(void)
{
InitializeComponent();
}

public: static Bitmap* source;
public: static double* img;
public: static Node* nodes;

public: costForm *cform; //declaring the pointer for child
//...
//...
//...
//...
//...

private: System::Void dynamicCostMenuItem_Click(System::Object * sender, System::EventArgs * e)
{
costselected = true;
cform = new costForm(this); //creating an object of thechild
cform->MdiParent = this;
this->ClientSize = System:: Drawing::Size(source->Width+ cform->Width, source->Height);
(cform->Location).X = (this->pictureBox1->Location).X + cform->Width ;
(cform->Location).Y = (this->Location).Y ;

cform->Show();

}

parent form da child ın bir işaretçisini tanımlayıp child ın public üyelerine erişmede sorun yok

bu da child ın header dosyası
#include "Form1.h" // burada parent ın header ı dahil edildi

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:: Data;
using namespace System:: Drawing;

namespace Segmentation
{

public __gc class costForm : public System::Windows::Forms::Form
{
public:
costForm( Form* f)
{
InitializeComponent();
parent = f; //equalize the 'parent' member of the child form
//to the reference taken before
}

private: Form1 *parent; // declaring the pointer of the parent

//errors : error C2143: syntax error : missing ';' before '*'
//'Segmentation::costForm::Form1' : missing storage-class or type specifiers
these errors are in the line of "private: Form1 *parent;"

hata neden kaynaklanıyor? bu işlem aslında VB ve C# ta bu şekilde sorunsuz yapılıyor ama c++ ta problem çıkıyor..


acehreli
02/05/2006, 21:12
Soylediklerinden anladigim kadariyla costForm'u Form1'den turetmek istiyorsun ama sanki oyle yapmamissin. (?)

Ali

kkirtac
02/05/2006, 21:36
aslında Form1 den türetme gibi bir niyetim yok, bu iş için Form1 den türetmemin şart olduğunu düşünmüyorum haksız mıyım? yapmak istediğim sadece Form1 in public birkaç üyesine child ı olan costForm dan erişebilmek..

acehreli
03/05/2006, 01:24
parent ve child sozcukleri beni yaniltti herhalde.

Bilmedigim icin sussam daha iyi olacak :) ama parent'in taniminda da __gc mi kullanman gerekiyor acaba...

Sustum... :x
Ali

Revne
03/05/2006, 20:05
#include "Form1.h" // burada parent ın header ı dahil edildi
.....
namespace Segmentation
{

public __gc class costForm : public System::Windows::Forms::Form
{
public:
costForm( Form* f)
{
InitializeComponent();
parent = f; //equalize the 'parent' member of the child form
//to the reference taken before
}
private: Form* parent; // declaring the pointer of a form
.....


seklinde bir denermisin???

veya


#include "Form1.h" // burada parent ın header ı dahil edildi
.....
namespace Segmentation
{

public __gc class costForm : public System::Windows::Forms::Form
{
public:
costForm( Form1* f)
{
InitializeComponent();
parent = f; //equalize the 'parent' member of the child form
//to the reference taken before
}
private: Form1* parent; // declaring the pointer of a form
.....


seklinde bir denermisin???

kkirtac
05/05/2006, 05:43
pardon orası Form1 olmalı zaten haklısınız, daha doğrusu önceden öyleydi zaten ama olmadı yine..teşekkürler

Revne
05/05/2006, 14:30
Anladıgım kadarıyla Child Formda ana formun tipini tanımıyor...
using namespace Segmentation;
seklinde bir ekleme yapabilirmisin Child forma....
Not: Gerci Formların her ikiside aynı namespace palasıyorlar... Ama bir dene belki sorun budur :D

kkirtac
05/05/2006, 19:38
malesef sorun o değil...ilginç ama çare yok galiba..neyse tasarımı değiştirmek başka çarem kalmadı..:)