|
aaron_leese wrote: I have never had to access elements on the main form from outside it before.
Good, you don't want to... check out the Model-View-Controller[^] design pattern.
|
|
|
|
|
yeah I know, but I still want to ... it is not always desirable to have a couple layers of indirection between interface and data.
|
|
|
|
|
It's never desirable to have anything until it is desirable to have it. That is the entire point.... never mind.
aaron_leese wrote: yeah I know, but I still want to
Of course you do... I don't know what got into me.
|
|
|
|
|
aaron_leese wrote: int main(array ^args)
{
Application::Run(gcnew Form1());
Form1::textBox1->Text = "some text";
}
...........................................
This doesn't work of course, because I am referencing the header class itself, and not the form instance .... but what is the form instance ????
Hmm...seems to me this also doesn't work because Run() doesn't return until you exit the app by
closing the form.
Form1^ myForm = gcnew Form1; would work but it makes no sense to access controls in the form
before it's created.
Do you have a better example of what you're trying to do?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
sure .. here is all the grubby details....
I have a multithread program .... one thread monitors the gui events, the other looks for incoming midi messages.
There are certain midi messages that trigger subroutines .... and there are buttons that do the same. The gui appearance need to change to reflect when certain subroutines are running, etc.
most of the subroutines change some global variables, and the gui just polls those variables to determine the state of affairs and appear accordingly.
BUT ... sometimes this is not appropriate, and I need to get some of the subroutines to alter the gui directly. No problem is a button is pushed .... big problem if it's a midi command .... because that thread does not have access to the form elements.
so ... succinctly .... how do I get a thread to access a form which is running on another thread.
I think I can do it if i only knew the correct instance name of the generated form.
any thoughts ?
Aaron
|
|
|
|
|
Hi Frnz,
I need to find the version details of my exe file. My exe code is in C++. Can anybody help me for the same in C++ to find the Version of any exe.
Thnz in advance
poojaaa
|
|
|
|
|
First of all, please post non-managed C++ questions on the Visual C++/MFC board[^].
If your EXE has a VERSION resource, you can get it with the help of these APIs:
GetFileVersionInfoSize()
GetFileVersionInfo()
VerQueryValue()
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
can a reflected methode not return gcnew System::Windows::Forms::TextBox()
but just base types like INT ???
if not mean it can return TextBox
where do i go wrong ?
myType = SampleAssembly->GetType("Memory.What");
myObj = System::Activator::CreateInstance( myType );
myMethod = myType->GetMethod("Name");
myMethod->Invoke( myObj , nullptr ); <<<--- here is the error
i have a MessageBox::Show in Memory.What.Name wich is fiered and also shows TextBox->ToString() corect which shoud by returned
(ToString is for testing in the messagebox dont get confused)
An unhandled exception of type 'System.NullReferenceException' occurred in WhatsUp.exe
Additional information: Object reference not set to an instance of an object.
|
|
|
|
|
|
hi all
System::Reflection::Assembly^ SampleAssembly;<br />
System::Type^ myType;<br />
System::Activator::Object^ myObj;<br />
<br />
try {<br />
SampleAssembly = System::Reflection::Assembly::LoadFrom( Path );<br />
}<br />
catch (System::IO::FileNotFoundException^ catchException) <br />
{<br />
Form->_TabCon->_PageStatus->StatusText->Text += catchException->ToString() + System::Environment::NewLine;<br />
return 1;<br />
}<br />
<br />
try {<br />
myType = SampleAssembly->GetType("Memory.What"); <br />
if (!myType) throw (System::String^) "Can´t locate Base Function [incompatible plug ???]";<br />
} <br />
catch (System::String^ catchException)<br />
{<br />
Form->_TabCon->_PageStatus->StatusText->Text += catchException + System::Environment::NewLine;<br />
return 1;<br />
}<br />
myObj = System::Activator::CreateInstance( myType );
<big>What^ W = (What^)myObj;</big>
how can i cast to "What^" ?
i tryed to have a .h .cpp file whit the same declaration as in "Memmory.what" but i get an error
An unhandled exception of type 'System.InvalidCastException' occurred in WhatsUp.exe
Additional information: Unable to cast object of type 'Memory.What' to type 'WhatsUp.What'.
|
|
|
|
|
Try this:
What^ W = safe_cast<What^> (myObj);
|
|
|
|
|
unfortunaly no
same error
this is where i am in the moment :
myType = SampleAssembly->GetType("Memory.What");
myObj = System::Activator::CreateInstance( myType );
System::Reflection::MethodInfo^ mi = myType->GetMethod("Ver");
mi->Invoke(myObj , nullptr );
so i can call the methode but its not to elegant there muss by some other way
so that i can call it like :
LoadedDLL->Ver();
|
|
|
|
|
hi i am new in c++, just developed one c++ dll(win32) from VS2005.
I just want to know how can i use that dll from a simple console c++ application.
or from C#.
please help
[&]&&
My small attempt...
|
|
|
|
|
An unmanaged C++ question which mentions C#...posted on the managed C++ board.
Please take your question to the appropriate board, before I call security...
Visual C++/MFC[^]
C#[^]
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I’m trying to figure out what the best way is to learn C++. Book, on-line course etc. Has anybody here had any good or bad experiences with anything? I’m leaning towards some sort of self paced book.
I have some VB.NET background and one beginner level C++ class years ago. I remember nothing about the C++.
I need to learn enough to be able to take (and pass) a required upper level C++ class so that I can finish a degree that I’ve been working on for 10 years. Plus some C++ knowledge would be nice for my job.
Any help and or suggestions would be appreciated.
Thanks
Brad
|
|
|
|
|
This is the C++/CLI forum. C++/CLI would be easier for you, seeing as it contains the .NET framework that you already know. But, if you want to learn C++, I recommend a book, and if you have any questions about c++, I recommend the Visual c++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Alright. Thanks Christian.
|
|
|
|
|
Hello,
I try to compile exe at VS2005 and get this error:
uafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___wargv
uafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
Do you know what to look for?
Thanks!
|
|
|
|
|
Is it VS 2005 Express Edition?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727
|
|
|
|
|
hmmm I'm not sure - those variables should be in the C runtime (CRT) library.
I'm wondering if you're trying to make an MFC app with Visual Studio Express Edition.
That won't work.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
As making Libcmtd.lib - ignored (at linker) coused this problem...
|
|
|
|
|
Possibly. Try removing it. Also maybe make sure Ignore default libraries options are set to no.
You can also create a similar project from the wizard and look at its settings to give you a
starting point.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hi all
topic says it how can i do something like :
this ist NOT working but what ever i try i ending always by this problem -->
class1.h<br />
<br />
#pragma once<br />
<br />
ref class class1<br />
<br />
{<br />
<br />
public:<br />
<br />
class1(void);<br />
<br />
class2^ c2;<br />
<br />
};<br />
<br />
.cpp<br />
<br />
#include "StdAfx.h"<br />
<br />
#include "class1.h"<br />
<br />
#include "class2.h"<br />
<br />
class1::class1(void)<br />
<br />
{<br />
<br />
}<br />
<br />
<br />
<br />
class2.h<br />
<br />
#pragma once<br />
<br />
ref class class2<br />
<br />
{<br />
<br />
public:<br />
<br />
class2(void);<br />
<br />
class1^ c1;<br />
<br />
};<br />
<br />
.cpp<br />
<br />
#include "StdAfx.h"<br />
<br />
#include "class2.h"<br />
<br />
#include "class1.h"<br />
<br />
class2::class2(void)<br />
<br />
{<br />
<br />
}
|
|
|
|
|
Add forward declarations to the header files:
class1.h
#pragma once
ref class class2;
ref class class1
{
public:
class1(void);
class2^ c2;
};
.cpp
#include "StdAfx.h"
#include "class1.h"
#include "class2.h"
class1::class1(void)
{
}
class2.h
#pragma once
ref class class1;
ref class class2
{
public:
class2(void);
class1^ c1;
};
.cpp
#include "StdAfx.h"
#include "class2.h"
#include "class1.h"
class2::class2(void)
{
}
-- modified at 11:57 Thursday 7th June, 2007
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|