[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Allen Maki

6/3/2007 12:25:00 AM

/*

Console::WriteLine() I am trying to use message box instead of
Console::WriteLine() to upgrade my code from just using the console to using
GUI.

In the bottom 2 lines, #1 works, but I have hard time to make # 2 works. Can
anybody give a hand here to make the information to be shown on the message
box instead of being shown on the console.

I am using visual C++ .NET 2003

Thanks

*/


#include "stdafx.h"

#include <gcroot.h>

#using <mscorlib.dll>

using namespace System;

using namespace System::Runtime::InteropServices;

typedef void* HWND;

[DllImportAttribute("User32.dll", CharSet=CharSet::Auto)]

extern "C" int MessageBox(HWND hw, String* text,

String* caption, unsigned int type);

__gc class MClass

{

public:

int val;

MClass(int n) //costructor

{

val = n;

}

};

class UClass

{

public :

gcroot<MClass*> mc;

UClass(MClass* pmc) //constructor

{

mc = pmc;

}

int getValue() //get function

{

return mc->val;

}

};

int _tmain()

{

Console::WriteLine(S"Testing...");

//Create a managed object and assign 3 to it

MClass* pm = new MClass (3);

//Create an unmanaged object and assign the value of the manged object (pm)
to it

UClass uc(pm);


Console::WriteLine(S"Value is {0}", __box(uc.getValue())); //<-------- This
will work # 1

//MessageBox(0, uc.getValue(), S"Message Box...", 0 ); //<------- this will
not work # 2





return 0;

}



1 Answer

GS

6/17/2007 1:44:00 AM

0

don't know much about c++ but in vb and in c# I can use the .net framework
(2.x)
MessageBox.Show("YourStrMsg","strTitle",....)
the Visual studio intellexsense should be able to assist you with the rest

"Allen Maki" <allenmaki@sbcglobal.net> wrote in message
news:7Tn8i.6581$y_7.5314@newssvr27.news.prodigy.net...
> /*
>
> Console::WriteLine() I am trying to use message box instead of
> Console::WriteLine() to upgrade my code from just using the console to
using
> GUI.
>
> In the bottom 2 lines, #1 works, but I have hard time to make # 2 works.
Can
> anybody give a hand here to make the information to be shown on the
message
> box instead of being shown on the console.
>
> I am using visual C++ .NET 2003
>
> Thanks
>
> */
>
>
> #include "stdafx.h"
>
> #include <gcroot.h>
>
> #using <mscorlib.dll>
>
> using namespace System;
>
> using namespace System::Runtime::InteropServices;
>
> typedef void* HWND;
>
> [DllImportAttribute("User32.dll", CharSet=CharSet::Auto)]
>
> extern "C" int MessageBox(HWND hw, String* text,
>
> String* caption, unsigned int type);
>
> __gc class MClass
>
> {
>
> public:
>
> int val;
>
> MClass(int n) //costructor
>
> {
>
> val = n;
>
> }
>
> };
>
> class UClass
>
> {
>
> public :
>
> gcroot<MClass*> mc;
>
> UClass(MClass* pmc) //constructor
>
> {
>
> mc = pmc;
>
> }
>
> int getValue() //get function
>
> {
>
> return mc->val;
>
> }
>
> };
>
> int _tmain()
>
> {
>
> Console::WriteLine(S"Testing...");
>
> //Create a managed object and assign 3 to it
>
> MClass* pm = new MClass (3);
>
> //Create an unmanaged object and assign the value of the manged object
(pm)
> to it
>
> UClass uc(pm);
>
>
> Console::WriteLine(S"Value is {0}", __box(uc.getValue())); //<--------
This
> will work # 1
>
> //MessageBox(0, uc.getValue(), S"Message Box...", 0 ); //<------- this
will
> not work # 2
>
>
>
>
>
> return 0;
>
> }
>
>
>