|
Do you mean C++/CLI, or are you in the wrong forum ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
hi, cam we make an exe appplication that works in a Dos mode using linux
and how it can be.
thank for your help
|
|
|
|
|
OK, you want it to run under linux. Well, this site is mostly about windows, this forum is entirely about C++/CLI ( that is, C++ with .NET ). Unless you're asking a Mono question, you're in the wrong forum.
But, a program that's written in C++ works in 'DOS mode' by default, if you mean in a console instead of with windows.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Visual C++ compiles windows exe. It doesn't work in pure DOS.
I suggest, you get a compiler, that compiles under pure dos. I suggest Turbo C++.
Visual c++ compilers will compile a dos box version, but it won't run in pure dos. Windows XP, and higher version, doesn't use dos. Windows 9x or lower still depending on dos.
In orther to use dos in linux, you have to get a linux version of dos emulator dosbox. In some distribution, it's included.
|
|
|
|
|
Hi all,
I have a situation where I need to return a fixed length string regardless of the length of a string that has been assigned to it. For example, if I wanted to have String1 which is made up of 12 spaces, then assing a returned value to a String2 which can be anything from 1 to 12 characters in length, how is this best done ?
The following may give you an idea where I'm coming from:
String^ Result; //This needs to be a fixed 12 characters.
String^ s1 = "ABC";<br />
<br />
Result = s1;
So I need Result to return 'ABC' + 9 spaces.
Hope this all makes some sense....
Fritzables.
|
|
|
|
|
String^ result;
String^ s1 = "ABC";
result = (s1->Length > 12 ? s1->Substring(0, 12) : s1)->PadRight(12);
Console::WriteLine("[{0}] Length={1}", result, result->Length);
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
George, you're a legend.... works a treat.
Thanks a million.
Regards
Pete <fritzables>
|
|
|
|
|
hi, i want to make a network application that can be used in a standard Dos
not in the windows that mean it work in Dos Mode, the application is a sniffer so i can recieve and transmit the whole packet. so is there any library that can i use it to achieve my point, and thanks for all
-- modified at 13:44 Friday 19th January, 2007
|
|
|
|
|
When you say DOS application, do you mean a Console application?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
You want to do this in C++/CLI ? The .NET framework has heaps of libraries, including ones for networking.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
IF you want to use C, you're definatley in the wrong forum
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
This is absolutely the most insane thing I've ever had to do in programming, and I don't even know if it's possible. Please help.
I have an app built with the /clr switch. I have a DLL that contains custom controls, built with the /clr:pure switch because building custom controls with the /clr switch freaks out the IDE designer and I get the message "Failed to load. Custom control will be removed from toolbox."
Now, the custom control in the DLL needs to trigger certain methods of an unmanaged class in the main app. If this was all managed code, I could use delegates. If this was all unmanaged code, I could use function pointers. But how do I pass the address of an unmanaged function to a managed class?
Right now, my unmanaged function signature is like:
public void MyClass::MyFunc(short);
My DLL control managed typedef is:
typedef void MyDllFunc(short); //matches the signature of the unmanaged main app method
My DLL control field is declared:
MyDllFunc *myCall;
In the main app I try to make the assignment:
myControl->myCall = &MyClass::MyFunc;
But I get the compiler error: "Cannot convert 'void(__thiscall MyClass::MyFunc::*)(short)' to 'void(__clrcall *)(short)'".
So what can I do to call an unmanaged function in the main app from a managed function in a DLL?
|
|
|
|
|
There are helper methods to do this. Nish is the person to ask. I'll ping him if I see him online - it's in his ( not yet published ) book.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I dont know if this will help but I used boost events to do something similar. I have a managed template that attaches to the boost event in the unmanaged class and exposes a dot net event with the same arguments. When the boost event fires the dot net event is raised
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
I think that will do the trick. I don't know why I didn't think of it, because I already do some similar conversions just within my main app. All of a sudden I'm talking about crossing over between the main app and a DLL and I lost my head. Thanks for pointing out that article!
|
|
|
|
|
I create dynamic event delegates (see code at end of question), which call a common method. When an event is fired, my dynamic method is called and in turn calls the common method.
My problem is that when in the common method the 'this' pointer is meaningless (as if it thinks its a static), so I can't access members of my class. I have a temporary work around where I build in the members to the dynamic method and pass them to the common method! however it still breaks in the debugger and I have to <continue> but gives the desired result.
There is something not right with my dynamic method and if anyone can put me on the right track then that would be greatly appreciated.
Thanks
Peter.
void EventHandler::CreateDynamicEventHandler()
{
System::Type ^ eventClass = m_eventSource->GetTarget()->GetType();
// Get event info and the type of delegate.
array<system::type^>^ args;
EventInfo ^ eventInfo = eventClass->GetEvent(m_eventName);
System::Type ^ tDelegate = eventInfo->EventHandlerType;
MethodInfo^ invoke = tDelegate->GetMethod( "Invoke" );
// The generated delegate will call a standard method (CommonEventHandler)
// to pass the events data onto Jade. Get the method info for that method.
array<system::type^>^ commonArgs = {System::String::typeid, array<system::object^>::typeid};
MethodInfo ^ methodInfo = EventHandler::typeid->GetMethod("CommonEventHandler", commonArgs);
// Create dynamic method
array<system::type^> ^ paramTypes = GetDelegateParameterTypes(tDelegate);
DynamicMethod ^ dynamicMethod = gcnew DynamicMethod("Dyna",
nullptr,
paramTypes,
::EventHandler::typeid);
// Generate method body
ILGenerator ^ ilGen = dynamicMethod->GetILGenerator();
// Create a local variable 'args'
int paramCount = paramTypes->Length;
LocalBuilder ^ localObj = ilGen->DeclareLocal(array<system::object^>::typeid);
// create object array of proper length
ilGen->Emit(OpCodes::Ldc_I4, paramCount);
ilGen->Emit(OpCodes::Newarr, System::Object::typeid);
ilGen->Emit(OpCodes::Stloc_0);
// Now put all arguments in the object array
for (System::Int32 i= 0; i<paramcount; i++)
="" {
="" system::byte="" b="System::Convert::ToByte(i);
" ilgen-="">Emit(OpCodes::Ldloc_0); // Local variable - the array
ilGen->Emit(OpCodes::Ldc_I4, i); // Index into array
ilGen->Emit(OpCodes::Ldarg_S, b); // Value to save is in bth argument to this method
if (paramTypes[i]->IsValueType)
ilGen->Emit(OpCodes::Box, paramTypes[i]); // Box value types
ilGen->Emit(OpCodes::Stelem_Ref, i);
}
// Call common method after pushing parameters
ilGen->Emit(OpCodes::Ldarg_0); // 'this' ptr (required for instance calls)
ilGen->Emit(OpCodes::Ldstr, m_eventName); // Just to help with debugging!
ilGen->Emit(OpCodes::Ldloc_0);
ilGen->EmitCall(OpCodes::Call, methodInfo, nullptr);
ilGen->Emit(OpCodes::Ret);
// Create delegate (Also completes dynamic method build)
System::Delegate ^ del = dynamicMethod->CreateDelegate(tDelegate);
// Add delegate to event's invocation list
MethodInfo ^ addHandler = eventInfo->GetAddMethod();
array<system::object^> ^ addHandlerArgs = {del};
addHandler->Invoke(m_eventSource->GetTarget(), addHandlerArgs);
}
|
|
|
|
|
i, i am newbie in C++/CLI WinForms.
I am trying to send text the textBox1 of Form1 at label1 in Form2 but i can send text of textbox2 of Form2 at label2 in Form1.
The #include "Form1.h" in form2 give problems.
I think in use a ref class.
--[ controlWindows.h ]--
namespace ControlWindows
{
using namespace System;
using namespace System::Windows::Forms;
ref class CWindows
{
static Form ^WindowsX2;
//static Form2 ^WindowsX22; // ERROR
static bool X2Status = false;
public:
// FORM2
static void ShowFormX2();
static void CloseFormX2();
static void ChangeCaptionX2();
static void MngVentanaX2(Object ^Obj);
};
}
-- EOF controlWindows.h --
--[ ControlWindows.cpp ]--
#include "controlWindows.h"
using namespace ControlWindows;
#include "Form1.h"
#include "Form2.h"
using namespace formToform;
void CWindows::ShowFormX2()
{
if ( X2Status == false)
{
WindowsX2 = gcnew Form2;
WindowsX2->Show();
X2Status = true;
}
}
void CWindows::CloseFormX2()
{
// cierra la ventana
WindowsX2->Close();
Estado = false;
}
void CWindows::ChangeCaptionX2()
{
WindowsX2->Text = L"Nuevo Caption";
WindowsX2->Update();
}
void CWindows::MngVentanaX2(Object ^Obj)
{
// WindowsX2->textBox1->Text = L"ASDASD"; // i dont get it
WindowsX2->Text = Obj->ToString();
// WindowsX2->textBox1->Text = Obj->ToString();
}
-- EOF controlWindows.cpp --
The Form2 has textBox1 but "static Form ^WindowsX2;" i get only access to form virgin, i dont have access to real form2 object
any idea?
thank
|
|
|
|
|
To communicate in both directios, you should use delegates, or pass a reference to your form1 in to form2.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
???????
I do not understand what you say to me.
|
|
|
|
|
form2 needs a copy of form1, a pointer, to call it's methods. Or, you can use delegates. (clue: when people use a word you don't know, google will define it for you )
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
An application written in C#-VS2005 needs to use a class exported in a VC6Dll.
I have googled around a bit about Data Marshalling using P/Invoke. But all I could find is information on how to use the exported functions from a dll OR a struct from a dll.
I could not find any info on how to use the (exported,unmanaged) class of the dll in my C# App.
Any help or link woud be helpful.
Thanks and Regards,
Arti Gujare
|
|
|
|
|
Don't cross post especially don't cross post into a C++ forum with a C# question.
led mike
|
|
|
|
|
Apologies.
This Mixed Mode coding makes me confused sometimes. :
|
|
|
|
|
Hi all...
I am working with visual studio 2005.In my application ,i need to transfer dataset content to local database table.I am using MS Access .Please help me...
Thanks
vinod
|
|
|
|