473,787 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting C++ Console Program

Several years ago I wrote a console program in Visual C++, which I am still
using. In converting this program to C#, I have encountered the following
problems:

1. I build my console display in a back ground buffer and use the function
"SetConsoleActi veScreenBuffer( hForegroundBuff er)" to switch the console
display to the new buffer. I couldn't find a corresponding function in C#.

2. I use the function "SetConsoleCurs orPosition(hFor egroundBuffer,p os)" to
set the position of the cursor. Again, I couldn't find a corresponding
function in C#.

3. I display some lines of data in red and some in black, and use the
function "SetConsoleText Attribute()" to accomplish that. Again, I couldn't
find a corresponding function in C#.

Perhaps the book I am using (Programming C#, by Jesse Liberty) is just
incomplete. If that is true, where can I find a more complete list of
functions available in C#?
Nov 15 '05 #1
2 1657
Jerry,

There is not a one to one mapping between the windows API and .NET.
..NET is lacking on the console support. However, all of the functions from
the windows API that you mentioned can be accessed through the P/Invoke
layer. If you need help in declaring these functions in C#, just post which
ones you need help with, and I or someone else would be more than happy to
help.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com

"Jerry chapman" <je*******@worl dnet.att.net> wrote in message
news:6J******** *************** @bgtnsc05-news.ops.worldn et.att.net...
Several years ago I wrote a console program in Visual C++, which I am still using. In converting this program to C#, I have encountered the following
problems:

1. I build my console display in a back ground buffer and use the function "SetConsoleActi veScreenBuffer( hForegroundBuff er)" to switch the console
display to the new buffer. I couldn't find a corresponding function in C#.

2. I use the function "SetConsoleCurs orPosition(hFor egroundBuffer,p os)" to set the position of the cursor. Again, I couldn't find a corresponding
function in C#.

3. I display some lines of data in red and some in black, and use the
function "SetConsoleText Attribute()" to accomplish that. Again, I couldn't
find a corresponding function in C#.

Perhaps the book I am using (Programming C#, by Jesse Liberty) is just
incomplete. If that is true, where can I find a more complete list of
functions available in C#?

Nov 15 '05 #2
Jerry chapman wrote:

[Missing functions in System.Console]

The System.Console class isn't "finished", one could say. It has only
the most important functions like Read, ReadLine, Write, WriteLine and
so on. All other console functions have to done via PInvoke.
Perhaps the book I am using (Programming C#, by Jesse Liberty) is just
incomplete. If that is true, where can I find a more complete list of
functions available in C#?


First: No, your book doesn't seem to be incomplete. Second: These are
_not_ functions of C# but the .net Framework.

May be

http://www.csharphelp.com/archives2/archive354.html

is a good point to start for you, as you're experienced in API programming.

HTH,

Michael

--
Michael Kremser
http://great.dynu.com/

Nov 15 '05 #3

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

Similar topics

4
5401
by: Prabhu | last post by:
Hi, We are having problem in converting a byte array to string, The byte array has char(174), char(175), char(240), char(242) and char(247) as delimiters for the message. when we use "System.Text.Encoding.ASCII.GetString(bytearray)" of .Net library, we found that the char (delimiters) specified above are replaced with different char.
1
12552
by: Darrel | last post by:
I am using binary writer to write an array of bytes to disk. However, my data starts out as an array of sbytes. I am currently type casting each array element in a for loop. Is there a faster method for converting an array of sbytes to an array of bytes? Thanks, Darrel
3
9849
by: Mark Scott | last post by:
I have downloaded some code for a pascal program to generate permutations of letters to solve anagrams: program Anagramm; { Gibt alle möglichen Anagramme zu einem Wort aus. Copyright (c) 8/99 by Bastisoft Int'l, Inc. All rights reserved. Reproduction in part or in total prohibited by Lower Saxonian and international law. }
0
1677
by: Edward Diener | last post by:
I have some questions about the instructions for creating a mixed mode DLL in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode" in the "Managed Extensions for C++ Reference". 1) The first instruction in converting to mixed mode is to link with /NOENTRY. This occurs despite the fact that a pure mode DLL is already set up with this option in the linker, and the previous...
9
2592
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and explain it. I have some questions about the instructions for creating a mixed mode DLL in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode" in the "Managed Extensions for C++ Reference"....
4
2265
by: sal | last post by:
Greets, All Converting array formula to work with datatables/dataset tia sal I finally completed a formula I was working on, see working code below. I would like to change this code so it will work with a variable mutl- row, 5 column datatable where the users select items. Anyone have any suggestions on where to start? Or changes in the current code that might be made.
1
3662
by: James | last post by:
this is a console program to convert ANSI to UTF8 format. Although in notepad i open the source file (which is ansi), and after running the program below, and re-open in notepad (it shows utf8 encoding), does it mean that it has been correctly converted ? Pls let me know what i have done wrong in conversion ... Module Module1
4
2335
by: Ted Lyngmo | last post by:
Hi! I'm new (but please do continue reading) to C++ in the VS environment and wanted to create a standalone program (or preferably, a static library, compatible with other Windows compilers) that; 1. Takes an URI as an argument. 2. Prints the proxy for that URI to stdout (or in the static library case, returns the resulting string).
2
2225
by: raylopez99 | last post by:
Here is a short program demonstrating using IEnumberable, Linq, predicates, extension methods and some tricks and how to convert an IEnumberable sequence into an array. For future reference, not intended as a question. RL Main(): int numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11};
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.