odd declaration error

G

Guest

i added a from called "Splash" to my project and am trying to get it to show
up on a formload event...but it gives a buildtime error on the line below

static Splash * frm = new Splash();

c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C3845: 'Final::Form1::frm': only static
data members can be initialized inside a __gc class or value type
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2039: 'Splash' : is not a member of
'Final'
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2143: syntax error : missing ';' before
'*'
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2039: 'Splash' : is not a member of
'Final'
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2501: 'Final::Form1::frm' : missing
storage-class or type specifiers


what am i doing wrong?
 
G

Guest

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

//
//
//
static Splash * frm = new Splash();
//
//
static PictureBox * arrBoard[,] = new PictureBox * [10, 10];
//
//
static Threading::Thread * FillThread = new Threading::Thread(new
ThreadStart(0, &Form1::Fill));
//
//
private: System::Void Form1_Load(System::Object * sender, System::EventArgs
* e)
{
frm->Show();

FillThread->Start();
}

private: System::Void Fill()
{

try
{

arrBoard[0,0] = this->pica0;
arrBoard[0,1] = this->pica1;
arrBoard[0,2] = this->pica2;
arrBoard[0,3] = this->pica3;
arrBoard[0,4] = this->pica4;
arrBoard[0,5] = this->pica5;
arrBoard[0,6] = this->pica6;
arrBoard[0,7] = this->pica7;
arrBoard[0,8] = this->pica8;
arrBoard[0,9] = this->pica9;
arrBoard[1,0] = this->picb0;
arrBoard[1,1] = this->picb1;
arrBoard[1,2] = this->picb2;
arrBoard[1,3] = this->picb3;
arrBoard[1,4] = this->picb4;
arrBoard[1,5] = this->picb5;
arrBoard[1,6] = this->picb6;
arrBoard[1,7] = this->picb7;
arrBoard[1,8] = this->picb8;
arrBoard[1,9] = this->picb9;
arrBoard[2,0] = this->picc0;
arrBoard[2,1] = this->picc1;
arrBoard[2,2] = this->picc2;
arrBoard[2,3] = this->picc3;
arrBoard[2,4] = this->picc4;
arrBoard[2,5] = this->picc5;
arrBoard[2,6] = this->picc6;
arrBoard[2,7] = this->picc7;
arrBoard[2,8] = this->picc8;
arrBoard[2,9] = this->picc9;
arrBoard[3,0] = this->picd0;
arrBoard[3,1] = this->picd1;
arrBoard[3,2] = this->picd2;
arrBoard[3,3] = this->picd3;
arrBoard[3,4] = this->picd4;
arrBoard[3,5] = this->picd5;
arrBoard[3,6] = this->picd6;
arrBoard[3,7] = this->picd7;
arrBoard[3,8] = this->picd8;
arrBoard[3,9] = this->picd9;
arrBoard[3,0] = this->pice0;
arrBoard[4,1] = this->pice1;
arrBoard[4,2] = this->pice2;
arrBoard[4,3] = this->pice3;
arrBoard[4,4] = this->pice4;
arrBoard[4,5] = this->pice5;
arrBoard[4,6] = this->pice6;
arrBoard[4,7] = this->pice7;
arrBoard[4,8] = this->pice8;
arrBoard[4,9] = this->pice9;
arrBoard[5,0] = this->picf0;
arrBoard[5,1] = this->picf1;
arrBoard[5,2] = this->picf2;
arrBoard[5,3] = this->picf3;
arrBoard[5,4] = this->picf4;
arrBoard[5,5] = this->picf5;
arrBoard[5,6] = this->picf6;
arrBoard[5,7] = this->picf7;
arrBoard[5,8] = this->picf8;
arrBoard[5,9] = this->picf9;
arrBoard[6,0] = this->picg0;
arrBoard[6,1] = this->picg1;
arrBoard[6,2] = this->picg2;
arrBoard[6,3] = this->picg3;
arrBoard[6,4] = this->picg4;
arrBoard[6,5] = this->picg5;
arrBoard[6,6] = this->picg6;
arrBoard[6,7] = this->picg7;
arrBoard[6,8] = this->picg8;
arrBoard[6,9] = this->picg9;
arrBoard[7,0] = this->pich0;
arrBoard[7,1] = this->pich1;
arrBoard[7,2] = this->pich2;
arrBoard[7,3] = this->pich3;
arrBoard[7,4] = this->pich4;
arrBoard[7,5] = this->pich5;
arrBoard[7,6] = this->pich6;
arrBoard[7,7] = this->pich7;
arrBoard[7,8] = this->pich8;
arrBoard[7,9] = this->pich9;
arrBoard[8,0] = this->pici0;
arrBoard[8,1] = this->pici1;
arrBoard[8,2] = this->pici2;
arrBoard[8,3] = this->pici3;
arrBoard[8,4] = this->pici4;
arrBoard[8,5] = this->pici5;
arrBoard[8,6] = this->pici6;
arrBoard[8,7] = this->pici7;
arrBoard[8,8] = this->pici8;
arrBoard[8,9] = this->pici9;
arrBoard[9,0] = this->picj0;
arrBoard[9,1] = this->picj1;
arrBoard[9,2] = this->picj2;
arrBoard[9,3] = this->picj3;
arrBoard[9,4] = this->picj4;
arrBoard[9,5] = this->picj5;
arrBoard[9,6] = this->picj6;
arrBoard[9,7] = this->picj7;
arrBoard[9,8] = this->picj8;
arrBoard[9,9] = this->picj9;

FillThread->Abort();

}

catch (Exception * ex)
{

}

}

};
}

thats my entire form1 code, with the windows code taken out because its all
picturebox names, nothing thatw ould interfere with a second form. i dont
understand becuase when i use the namespace of the project, Final, in the
declaration it says the form doesnt exist under it even though its there in
the intelisense....ex:

static Final::Splash * frm = new Final::Splash();

throws that buildtime error even though its in intelisense
 
B

Bruno van Dooren

where and how is Splash declared?
different namespace perhaps?

kind regards,
Bruno.


iwdu15 said:
namespace Final
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

//
//
//
static Splash * frm = new Splash();
//
//
static PictureBox * arrBoard[,] = new PictureBox * [10, 10];
//
//
static Threading::Thread * FillThread = new Threading::Thread(new
ThreadStart(0, &Form1::Fill));
//
//
private: System::Void Form1_Load(System::Object * sender,
System::EventArgs
* e)
{
frm->Show();

FillThread->Start();
}

private: System::Void Fill()
{

try
{

arrBoard[0,0] = this->pica0;
arrBoard[0,1] = this->pica1;
arrBoard[0,2] = this->pica2;
arrBoard[0,3] = this->pica3;
arrBoard[0,4] = this->pica4;
arrBoard[0,5] = this->pica5;
arrBoard[0,6] = this->pica6;
arrBoard[0,7] = this->pica7;
arrBoard[0,8] = this->pica8;
arrBoard[0,9] = this->pica9;
arrBoard[1,0] = this->picb0;
arrBoard[1,1] = this->picb1;
arrBoard[1,2] = this->picb2;
arrBoard[1,3] = this->picb3;
arrBoard[1,4] = this->picb4;
arrBoard[1,5] = this->picb5;
arrBoard[1,6] = this->picb6;
arrBoard[1,7] = this->picb7;
arrBoard[1,8] = this->picb8;
arrBoard[1,9] = this->picb9;
arrBoard[2,0] = this->picc0;
arrBoard[2,1] = this->picc1;
arrBoard[2,2] = this->picc2;
arrBoard[2,3] = this->picc3;
arrBoard[2,4] = this->picc4;
arrBoard[2,5] = this->picc5;
arrBoard[2,6] = this->picc6;
arrBoard[2,7] = this->picc7;
arrBoard[2,8] = this->picc8;
arrBoard[2,9] = this->picc9;
arrBoard[3,0] = this->picd0;
arrBoard[3,1] = this->picd1;
arrBoard[3,2] = this->picd2;
arrBoard[3,3] = this->picd3;
arrBoard[3,4] = this->picd4;
arrBoard[3,5] = this->picd5;
arrBoard[3,6] = this->picd6;
arrBoard[3,7] = this->picd7;
arrBoard[3,8] = this->picd8;
arrBoard[3,9] = this->picd9;
arrBoard[3,0] = this->pice0;
arrBoard[4,1] = this->pice1;
arrBoard[4,2] = this->pice2;
arrBoard[4,3] = this->pice3;
arrBoard[4,4] = this->pice4;
arrBoard[4,5] = this->pice5;
arrBoard[4,6] = this->pice6;
arrBoard[4,7] = this->pice7;
arrBoard[4,8] = this->pice8;
arrBoard[4,9] = this->pice9;
arrBoard[5,0] = this->picf0;
arrBoard[5,1] = this->picf1;
arrBoard[5,2] = this->picf2;
arrBoard[5,3] = this->picf3;
arrBoard[5,4] = this->picf4;
arrBoard[5,5] = this->picf5;
arrBoard[5,6] = this->picf6;
arrBoard[5,7] = this->picf7;
arrBoard[5,8] = this->picf8;
arrBoard[5,9] = this->picf9;
arrBoard[6,0] = this->picg0;
arrBoard[6,1] = this->picg1;
arrBoard[6,2] = this->picg2;
arrBoard[6,3] = this->picg3;
arrBoard[6,4] = this->picg4;
arrBoard[6,5] = this->picg5;
arrBoard[6,6] = this->picg6;
arrBoard[6,7] = this->picg7;
arrBoard[6,8] = this->picg8;
arrBoard[6,9] = this->picg9;
arrBoard[7,0] = this->pich0;
arrBoard[7,1] = this->pich1;
arrBoard[7,2] = this->pich2;
arrBoard[7,3] = this->pich3;
arrBoard[7,4] = this->pich4;
arrBoard[7,5] = this->pich5;
arrBoard[7,6] = this->pich6;
arrBoard[7,7] = this->pich7;
arrBoard[7,8] = this->pich8;
arrBoard[7,9] = this->pich9;
arrBoard[8,0] = this->pici0;
arrBoard[8,1] = this->pici1;
arrBoard[8,2] = this->pici2;
arrBoard[8,3] = this->pici3;
arrBoard[8,4] = this->pici4;
arrBoard[8,5] = this->pici5;
arrBoard[8,6] = this->pici6;
arrBoard[8,7] = this->pici7;
arrBoard[8,8] = this->pici8;
arrBoard[8,9] = this->pici9;
arrBoard[9,0] = this->picj0;
arrBoard[9,1] = this->picj1;
arrBoard[9,2] = this->picj2;
arrBoard[9,3] = this->picj3;
arrBoard[9,4] = this->picj4;
arrBoard[9,5] = this->picj5;
arrBoard[9,6] = this->picj6;
arrBoard[9,7] = this->picj7;
arrBoard[9,8] = this->picj8;
arrBoard[9,9] = this->picj9;

FillThread->Abort();

}

catch (Exception * ex)
{

}

}

};
}

thats my entire form1 code, with the windows code taken out because its
all
picturebox names, nothing thatw ould interfere with a second form. i dont
understand becuase when i use the namespace of the project, Final, in the
declaration it says the form doesnt exist under it even though its there
in
the intelisense....ex:

static Final::Splash * frm = new Final::Splash();

throws that buildtime error even though its in intelisense
 
G

Guest

#pragma once

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 Final
{
/// <summary>
/// Summary for Splash
///
/// WARNING: If you change the name of this class, you will need to change
the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly with
localized
/// resources associated with this form.
/// </summary>
public __gc class Splash : public System::Windows::Forms::Form
{
public:
Splash(void)
{
InitializeComponent();
}

protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Timer * tmrrnd;
private: Control_Trial::percentProgressBar * prgLoad;

private: System::ComponentModel::IContainer * components;

private:
/// <summary>
/// Required designer variable.
/// </summary>


/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = new System::ComponentModel::Container();
this->tmrrnd = new System::Windows::Forms::Timer(this->components);
this->prgLoad = new Control_Trial::percentProgressBar();
this->SuspendLayout();
//
// prgLoad
//
this->prgLoad->Location = System::Drawing::point(40, 384);
this->prgLoad->Name = S"prgLoad";
this->prgLoad->PercentFontColor = System::Drawing::Color::Red;
this->prgLoad->PropBarColor1 =
System::Drawing::SystemColors::InactiveCaption;
this->prgLoad->PropBarColor2 = System::Drawing::SystemColors::Highlight;
this->prgLoad->Size = System::Drawing::Size(568, 32);
this->prgLoad->TabIndex = 0;
this->prgLoad->Text = S"percentProgressBar1";
//
// Splash
//
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(656, 486);
this->ControlBox = false;
this->Controls->Add(this->prgLoad);
this->Name = S"Splash";
this->ShowInTaskbar = false;
this->StartPosition =
System::Windows::Forms::FormStartPosition::CenterScreen;
this->ResumeLayout(false);

}

//
/*
Jonathan Miller
Period 3
1-2-06
Splash Screen
Final Project
*/

static bool load = true;

private: System::Void SplashScreen_Load(System::Object * sender,
System::EventArgs * e)
{

this->tmrrnd->Start();

}

private: System::Void tmrrnd_Tick(System::Object * sender,
System::EventArgs * e)
{

Random * rnd = new Random;

int rand = rnd->Next(9),
val = this->prgLoad->Value,
max = this->prgLoad->Maximum;


if (val + rand < max)
{

this->prgLoad->Value += rand;
this->prgLoad->Update();

}
else
{

this->prgLoad->Value += (this->prgLoad->Maximum - this->prgLoad->Value);
this->prgLoad->Update();

}

}
};
}

thats the splash code....same namespace and everything....and im trying to
get a declaraton...like in vb id do this

''Global Var
Private frm as new Splash

i dont know how to do that in C++
 
B

Bruno van Dooren

maybe a stupid question, but did you include Splash.h before Form1.h in the
CPP file in which Form1.h is included?
(that would be Form1.cpp??)
because otherwise the compiler will have no declaration for Splash while
trying to parse Form1.h

also, the line
static Splash * frm = new Splash();
seems to be placed outside a function scope. i think this is not allowed.
you try to instantiate a Splash screen, but you don't do it from inside a
function.

if that doesn't help you, could you post your project (or a stripped down
version with the same error) so that i can investigate in more detail?

also, your

kind regards,
Bruno.
 
G

Guest

i tried to send you an email but it said your mailbox wasnt available....i
added "splash" after the original form came up...and making it a local
variable in a method doesnt work either, and they are both part of the same
namespace
 
C

Carl Daniel [VC++ MVP]

iwdu15 said:
thats my entire form1 code, with the windows code taken out because
its all picturebox names, nothing thatw ould interfere with a second
form. i dont understand becuase when i use the namespace of the
project, Final, in the declaration it says the form doesnt exist
under it even though its there in the intelisense....ex:

static Final::Splash * frm = new Final::Splash();

throws that buildtime error even though its in intelisense

Intellisense will see things that the compiler can't see because it parses
all the files in your project, even if they're not included in the file
you're compiling.

Here's a prototypical arrangement with a couple of forms, one of which
references the other:

<code>
// Splash.h
namespace app
{
__gc class Splash : public System::Windows::Forms::Form
{
// TODO: add definition of Splash
};
}

// MainForm.h
#include "splash.h"

namespace app
{
__gc class MainForm : public System::Windows::Forms::Form
{
static Splash* m_splash = new Splash();

// TODO: add definition of MainForm
};
}

// FormsApp.cpp
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>

#include "mainform.h"

int main()
{
using namespace app;

MainForm* pm = new MainForm();
}

</code>

Note that MainFrom.h #includes Splash.h so the definition of Splash is
visible to the compiler. Note also that the definition of m_splash is a
static member variable, not a namespace-scoped variable. You can't declare
a namespace-scoped variable of type pointer-to-gc-class.

I hope that helps get you over this hurdle.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top