Click here to Skip to main content
16,004,919 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Avoid pasting any content in textbox Pin
Guffa23-Sep-06 4:54
Guffa23-Sep-06 4:54 
GeneralRe: Avoid pasting any content in textbox Pin
Vipul Mehta24-Sep-06 18:29
Vipul Mehta24-Sep-06 18:29 
AnswerRe: Avoid pasting any content in textbox Pin
Guffa24-Sep-06 21:02
Guffa24-Sep-06 21:02 
GeneralRe: Avoid pasting any content in textbox Pin
Vipul Mehta24-Sep-06 23:57
Vipul Mehta24-Sep-06 23:57 
AnswerRe: Avoid pasting any content in textbox Pin
Guffa25-Sep-06 9:16
Guffa25-Sep-06 9:16 
QuestionAdd-in For SourceSafe Pin
Tad McClellan22-Sep-06 11:35
professionalTad McClellan22-Sep-06 11:35 
QuestionCollection Change notification [modified] Pin
nicknotyet22-Sep-06 7:44
nicknotyet22-Sep-06 7:44 
QuestionPassing a Form handle to a constructor. Pin
JayThomas200622-Sep-06 4:48
JayThomas200622-Sep-06 4:48 
I'm just starting to use Managed C++ and .NET. I'm still in the early learning stages.

Basically, I have a Window Form that has a value for MyClass to use. I thought I could use the following code to pass the Form1 handle to the Myclass constructor.

I forward declare the Form1 class in "MyClass.h". In the constructor definition I pass the Form1 handle to a local variable just to see if the handle gets to the construtor. When the 'myTestVar = ' line is commented out, the program compiles and when I run the debugger I can see the Form1 handle being passed to the constructor and hTest being set equal to hForm. So I know at this point, I can pass the Form1 handle to the constructor.

When I remove the comments from the 'myTestVar = ' line, I get compiler errors. I can't figure out what's wrong.

1>.\MyClass.cpp(12) : error C2027: use of undefined type MyProject::Form1'
1> c:\visual studio 2005\projects\praxflow\praxflow\MyClass.h(4) : see
declaration of 'MyProject::Form1'

Currently, I have a private member method within the Form1 class called setMyClass( ^Form1 ) which works but this doesn't seem very OOP to me.



//----MyClass.h----
#pragma once

namespace MyProject
{
ref class Form1; //forward declaration
}

public ref class CMyClass
{
public:
CMyClass( MyProgram::Form1 ^hForm );

private:
int myTestVar;
}

//----MyClass.cpp----
#pragma once

#include "StdAfx.h"
#include "MyClass.h"

CMyClass::CMyClass( hForm )
{
MyProject::Form1 ^hTest;
hTest = hForm;

// myTestVar = Convert::ToInt32( hForm->txtFieldFromForm1->Text );
}

//----Form1.h----
#pragma once

#include "MyClass.h"

namespace MyProject
{
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
//--- initializing stuff
}
protected:
//---destructor
private:

private: System::Void btnInitMyClass_Click(System::Object^ sender, System::EventArgs^ e)
{
CMyClass MyClass = gcnew CMyClass( this ); //Instantiate and initialize using the Form1 handle.
}
};
}
Questionneed a trick [modified] Pin
milleusi22-Sep-06 4:20
milleusi22-Sep-06 4:20 
AnswerRe: need a trick Pin
leckey23-Sep-06 18:51
leckey23-Sep-06 18:51 
AnswerRe: need a trick Pin
Hamid_RT28-Sep-06 8:56
Hamid_RT28-Sep-06 8:56 
Question.NET Question, twice i was asked by the interviewers Pin
Prabhurishi22-Sep-06 0:36
Prabhurishi22-Sep-06 0:36 
AnswerRe: .NET Question, twice i was asked by the interviewers Pin
Christian Graus22-Sep-06 1:33
protectorChristian Graus22-Sep-06 1:33 
AnswerRe: .NET Question, twice i was asked by the interviewers Pin
Hamid_RT28-Sep-06 8:57
Hamid_RT28-Sep-06 8:57 
QuestionUsing remoting features inside a .NET applet loaded in a tag object Pin
Lambuz21-Sep-06 4:27
Lambuz21-Sep-06 4:27 
QuestionProblem with Strong Typed Dataset with DataGridView Pin
kakarato21-Sep-06 3:12
kakarato21-Sep-06 3:12 
AnswerRe: Problem with Strong Typed Dataset with DataGridView Pin
Tristan Rhodes25-Sep-06 3:46
Tristan Rhodes25-Sep-06 3:46 
QuestionAssembly versions Pin
livez21-Sep-06 1:23
livez21-Sep-06 1:23 
AnswerRe: Assembly versions Pin
Dave Kreskowiak21-Sep-06 3:06
mveDave Kreskowiak21-Sep-06 3:06 
GeneralRe: Assembly versions Pin
livez21-Sep-06 3:10
livez21-Sep-06 3:10 
GeneralRe: Assembly versions Pin
Dave Kreskowiak21-Sep-06 8:41
mveDave Kreskowiak21-Sep-06 8:41 
GeneralRe: Assembly versions Pin
ddecoy22-Sep-06 0:21
ddecoy22-Sep-06 0:21 
GeneralRe: Assembly versions Pin
Dave Kreskowiak22-Sep-06 2:12
mveDave Kreskowiak22-Sep-06 2:12 
GeneralRe: Assembly versions Pin
ddecoy25-Sep-06 22:01
ddecoy25-Sep-06 22:01 
GeneralRe: Assembly versions Pin
Dave Kreskowiak26-Sep-06 1:58
mveDave Kreskowiak26-Sep-06 1:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.