473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

New to MC++

Greetings,

I'm trying to create a Managed C++ library that extends the console features
beyond System::Console capabilities. I chose MC++ over C++/CLI because I
need it to work on the 1.1 framework. I haven't programmed C++ in years and
I'm very very new to Managed C++. Thus, I'm having issues getting even the
simplest thing to work, and not for the fact, that finding good information
about using API calls and such from within a managed class isn't as easy to
find as I thought it would be.

In particular, my true lack of understanding is this: I have a __gc class.
I'm using win32 api. So I need to pass a native struct into a native method
call. Do I need to do anything special at this point, such as mark it __gc*
or something?

The following code won't compile. Was wondering if anyone could explain how
to make it compile. I marked the offending line of code with a comment.
Search for "Compile error"

* common.h
* console.h
* console.cpp
* stdafx.h
common.h
--------
#pragma once
#if !defined (common_h)
#define common_h

// .NET Access Modifiers
//
#define PUBLIC public public
#define PROTECTED public protected
#define PRIVATE private private
#define INTERNAL private public
#endif // !defined (common_h)
--------
console.h
--------
#pragma once

using namespace System;
namespace Test
{
public __gc class Console
{
PUBLIC:
PROTECTED:
PRIVATE:
const static byte EMPTY = 32;
const static int CAPTION_LENGTH = 1024;

static HANDLE hConsoleOutput; // handle to output buffer
static HANDLE hConsoleInput; // handle to input buffer
static int OriginalConsolePen;
static int CurrentConsolePen;

static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
static COORD ConsoleOutputLocation;

public:
static void Clear();
};
}
----------
console.cpp
----------
// This is the main DLL file.

#include "stdafx.h"

#include "console.h"
namespace Test
{
void Console::Clear()
{
DWORD chars = 0;

CONSOLE_SCREEN_BUFFER_INFO info;
COORD home;

home.X = 0;
home.Y = 0;

CONSOLE_SCREEN_BUFFER_INFO consoleInfo;

hConsoleInput = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOutput, &consoleInfo); // <-- Compile
error happens here

if (GetConsoleScreenBufferInfo(hConsoleInput, &info) == 0) {
System::Console::Write(S"\x0c");
return;
}

FillConsoleOutputCharacter(
hConsoleOutput,
EMPTY,
info.dwSize.X * info.dwSize.Y,
home,
&chars
);

FillConsoleOutputAttribute(
hConsoleOutput,
CurrentConsolePen,
info.dwSize.X * info.dwSize.Y,
home,
&chars
);

SetConsoleCursorPosition(
hConsoleOutput,
home
);
}
}
--------
stdafx.h
---------
#pragma once

#include <wtypes.h>
#include <wincon.h>

#include "common.h"
Dec 8 '05 #1
3 1203
> I'm trying to create a Managed C++ library that extends the console
features
beyond System::Console capabilities. I chose MC++ over C++/CLI because I
need it to work on the 1.1 framework.

Why restrict yourself to v1.1? Why not use v2.0?

Dec 9 '05 #2
Hmmm a question, what do you mean you choose MC++?
You are referring to VC++ 2003? That one uses the .NET framework v1.1

But VS 2005 is going to compile with the .NET framework 2.0, so forcing it
to use only v1.1 is going to give you head-aches.
Dec 9 '05 #3
> Hmmm a question, what do you mean you choose MC++?
You are referring to VC++ 2003? That one uses the .NET framework v1.1

But VS 2005 is going to compile with the .NET framework 2.0, so forcing it
to use only v1.1 is going to give you head-aches.


It must work with the 1.1 framework because our company isn't moving to 2.0
anytime soon. When we do, it'll still compile with Visual C++ 2005, but we
can then rewrite it against C++/CLI as we see fit (usually we're about 18
months behind when it comes to rewriting anything for a specific new
technology even though we'll adopt the technology much sooner (6 months) all
we do is migrate the code and not do much changes otherwise for existing
code). But, if I write it in C++/CLI first, it won't be source-code
compatible with a compiler that will target the 1.1 framework.

I hope I didn't give the impression I was using 2005, I'm using VS.NET 2003
for now. I'm well aware of the different IDE's targeting different
runtimes. But using the 2005 IDE right now isn't an option for this
project.

Thanks,
Shawn
Dec 9 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Daniel Lidström | last post by:
Hi, I've been trying a long time now to generate some XML using MC++ and XmlSerializer. I have a piece of C# code that produces exactly what I want, but I simply can't get the MC++ code to write...
1
by: Philip | last post by:
I am trying to return a string from a mc++ method back to an invoking C# module. In the invoking C# module I have the string defined as.... String strString;.... in mc++ the method definition is...
3
by: Philip | last post by:
I am invoking a mc++ method from C# via an unsafe code block. The reason for the unsafe code block is that I am receiving a int as a return parameter. I am invoking the method with a "ref...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
2
by: Lev | last post by:
Hi, I have some code that does reflection on an assembly I load. When I try to get the attributes on one of the methods implemented in the assembly, the MC++ version does not return anything....
0
by: Peter Insley via .NET 247 | last post by:
Hi, have been searching for an answer for this for quite a while,I would be greatfull for any help. We are developing a codebase that of components that we wouldlike to be able to write in MC++ or...
0
by: Maxwell | last post by:
Hello, I recently completed a MC++ (VS2003) DLL that wraps a non MFC C++ DLL and need to use it in a MC++ Console Application (no forms/guis of any kind just output to console). Trouble is...
8
by: WebSnozz | last post by:
I have an application written in C that does a lot of low level stuff. It does a lot of things like casting from void*'s. I want to create a new GUI for it in either C# or MC++, but reuse the...
3
by: Bruno LIVERNAIS | last post by:
Hi, We are currently installing a DB2 V9 ESE on a Linux server (RHEL4U4-x86_64). Installation runs successfully on each node. Database user environment is OK and the instance is well created. To...
1
by: A. Nonymous | last post by:
First off, I would like to state that I'm using VS.2003 / .NET Framework 1.1 and the MC++ that comes with it. I am stuck with this IDE for the time being as I am supporting some older platforms. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.