473,800 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tasks which are more difficult than they should be

While I really like VS C++.NET 2005, there are a number of tasks which are
harder than they should be. Conversion from old 'char' arrays to new String
entities for instance. This thread is to list problems that seem like they
should be easy, but are a bit kludgy. Then solutions can be pointed to or
described! I'll begin:

(*) It is not easy to create a mouse cursor based on an arbitrary bitmap,
even one with restrictions such as dimensional size and use of colors. In
fact, it is tough to customize a mouse cursor in general.

(*) It is tough to insert a single character into a String. As a corollary,
it is tough to convert a single character into a String (Note: ToString
doesn't do this).

(*) It is tough to create an array of objects INSTANCES based on custom
classes. It is easy to create an array of POINTERS to custom objects, but an
array of custom objects have to be VALUE objects and not REF objects. Thus,
they can't have constructors or any other method as part of their definition
(they are what old 'structs' use to be, data but no code).

(*) It requires a sub-system to place a simple shape (e.g., solid-colored
box) on the screen permanently (that is, not only does one have to put code
in the Paint even handler to be run every screen refresh, but one must
actually manually refresh the portion of the screen when and where there are
any changes for them to be seen).

(*) The lack of multiple inheritance means one can't customize innate
controls 'en mass". That is, I can't create a class that Form's AND Panel's
can both inherent from as a common basis. For example, if I want to add a
Graphic sub-system ala the above item I need to put the code in both custom
classes and inherit only from the control's. I can't create a
'GraphicHandler ' class and define two new classes, one that derives from
Form and GraphicHandler, and one that derives from Panel and Graphics
handler. I can do this with composition, however, but its not as clean and
requires code to 'bring up' the functionality of the composited sub-class.

I'll try to think of some more...

[==P==]
Feb 6 '06 #1
9 1338
"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:Od******** ******@TK2MSFTN GP14.phx.gbl...
While I really like VS C++.NET 2005, there are a number of tasks which are
harder than they should be. Conversion from old 'char' arrays to new
String entities for instance.
gcnew String(charArra y);
(*) It is tough to insert a single character into a String. As a
corollary, it is tough to convert a single character into a String (Note:
ToString doesn't do this).


String^ text = "";
text->Insert(0, Char::ToString( 'a'));

but not

text->Insert(0, 'a'.ToString()) ;

since 'a' is an SByte.
Feb 7 '06 #2
James Park wrote:
"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:Od******** ******@TK2MSFTN GP14.phx.gbl...
While I really like VS C++.NET 2005, there are a number of tasks
which are harder than they should be. Conversion from old 'char'
arrays to new String entities for instance.


gcnew String(charArra y);
(*) It is tough to insert a single character into a String. As a
corollary, it is tough to convert a single character into a String
(Note: ToString doesn't do this).


String^ text = "";
text->Insert(0, Char::ToString( 'a'));


text = text->Insert(0,Char. ToString('a'));

remember, strings are immutable.

-cd
Feb 7 '06 #3

"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:u2******** *****@TK2MSFTNG P15.phx.gbl...
| James Park wrote:
| > "Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
| > news:Od******** ******@TK2MSFTN GP14.phx.gbl...
| >> While I really like VS C++.NET 2005, there are a number of tasks
| >> which are harder than they should be. Conversion from old 'char'
| >> arrays to new String entities for instance.
| >
| > gcnew String(charArra y);
| >
| >> (*) It is tough to insert a single character into a String. As a
| >> corollary, it is tough to convert a single character into a String
| >> (Note: ToString doesn't do this).
| >
| > String^ text = "";
| > text->Insert(0, Char::ToString( 'a'));
|
| text = text->Insert(0,Char. ToString('a'));
|
| remember, strings are immutable.
|
| -cd
|
|

Or :

text = text->Insert(0, "a");

Willy.
Feb 7 '06 #4
Cool. The code you provided works! But, it is easy to fall into the
following trap. This code doesn't work:

char chr_a = 'a' ;
string text = "" ;
text = text->Insert(0, chr_a.ToString( )) ;

The difference here is that it invokes the 'char' version of ToString. The
result of the above is the following:

text = "97" ;

97? That's weird. Not really. the ASCII value of the char ' a' is 97. But I
definitiely fell into the trap a few weeks back. The reason this works:

text = text->Insert(0, Char::ToString( chr_a)) ;

is because it uses the 'Char' version of ToString instead of the 'char'.
What a difference a capital 'C' makes...

[==P==]

"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:e4******** ******@TK2MSFTN GP10.phx.gbl...

"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:u2******** *****@TK2MSFTNG P15.phx.gbl...
| James Park wrote:
| > "Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
| > news:Od******** ******@TK2MSFTN GP14.phx.gbl...
| >> While I really like VS C++.NET 2005, there are a number of tasks
| >> which are harder than they should be. Conversion from old 'char'
| >> arrays to new String entities for instance.
| >
| > gcnew String(charArra y);
| >
| >> (*) It is tough to insert a single character into a String. As a
| >> corollary, it is tough to convert a single character into a String
| >> (Note: ToString doesn't do this).
| >
| > String^ text = "";
| > text->Insert(0, Char::ToString( 'a'));
|
| text = text->Insert(0,Char. ToString('a'));
|
| remember, strings are immutable.
|
| -cd
|
|

Or :

text = text->Insert(0, "a");

Willy.

Feb 7 '06 #5
"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Cool. The code you provided works! But, it is easy to fall into the
following trap. This code doesn't work:

char chr_a = 'a' ;
string text = "" ;
text = text->Insert(0, chr_a.ToString( )) ;

The difference here is that it invokes the 'char' version of ToString. The
result of the above is the following:

text = "97" ;

97? That's weird. Not really. the ASCII value of the char ' a' is 97. But
I definitiely fell into the trap a few weeks back. The reason this works:

text = text->Insert(0, Char::ToString( chr_a)) ;

is because it uses the 'Char' version of ToString instead of the 'char'.
What a difference a capital 'C' makes...


If you want to use the VC++ type name for Char, it's wchar_t. You can find a
table at
http://msdn.microsoft.com/library/en...eConfusion.asp
Feb 7 '06 #6

"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
| Cool. The code you provided works! But, it is easy to fall into the
| following trap. This code doesn't work:
|
| char chr_a = 'a' ;
| string text = "" ;
| text = text->Insert(0, chr_a.ToString( )) ;
|
| The difference here is that it invokes the 'char' version of ToString. The
| result of the above is the following:
|
| text = "97" ;
|
| 97? That's weird. Not really. the ASCII value of the char ' a' is 97. But
I
| definitiely fell into the trap a few weeks back. The reason this works:
|
| text = text->Insert(0, Char::ToString( chr_a)) ;
|
| is because it uses the 'Char' version of ToString instead of the 'char'.
| What a difference a capital 'C' makes...
|

For the time being, it's fundamental to understand the difference between
managed types and unmanaged types when using C+++CLI in mixed mode. Maybe a
later version of C++/CLI will support seamless integration of both managed
and unmanaged types.

Willy.
| [==P==]
|
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| news:e4******** ******@TK2MSFTN GP10.phx.gbl...
| >
| > "Carl Daniel [VC++ MVP]"
<cp************ *************** **@mvps.org.nos pam>
| > wrote in message news:u2******** *****@TK2MSFTNG P15.phx.gbl...
| > | James Park wrote:
| > | > "Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
| > | > news:Od******** ******@TK2MSFTN GP14.phx.gbl...
| > | >> While I really like VS C++.NET 2005, there are a number of tasks
| > | >> which are harder than they should be. Conversion from old 'char'
| > | >> arrays to new String entities for instance.
| > | >
| > | > gcnew String(charArra y);
| > | >
| > | >> (*) It is tough to insert a single character into a String. As a
| > | >> corollary, it is tough to convert a single character into a String
| > | >> (Note: ToString doesn't do this).
| > | >
| > | > String^ text = "";
| > | > text->Insert(0, Char::ToString( 'a'));
| > |
| > | text = text->Insert(0,Char. ToString('a'));
| > |
| > | remember, strings are immutable.
| > |
| > | -cd
| > |
| > |
| >
| > Or :
| >
| > text = text->Insert(0, "a");
| >
| > Willy.
| >
| >
|
|
Feb 7 '06 #7

"James Park" <so*****@hotmai l.com> wrote in message
news:eN******** ******@TK2MSFTN GP15.phx.gbl...
| "Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
| news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
| > Cool. The code you provided works! But, it is easy to fall into the
| > following trap. This code doesn't work:
| >
| > char chr_a = 'a' ;
| > string text = "" ;
| > text = text->Insert(0, chr_a.ToString( )) ;
| >
| > The difference here is that it invokes the 'char' version of ToString.
The
| > result of the above is the following:
| >
| > text = "97" ;
| >
| > 97? That's weird. Not really. the ASCII value of the char ' a' is 97.
But
| > I definitiely fell into the trap a few weeks back. The reason this
works:
| >
| > text = text->Insert(0, Char::ToString( chr_a)) ;
| >
| > is because it uses the 'Char' version of ToString instead of the 'char'.
| > What a difference a capital 'C' makes...
|
| If you want to use the VC++ type name for Char, it's wchar_t. You can find
a
| table at
|
http://msdn.microsoft.com/library/en...eConfusion.asp
|
|

Which is just another native type, not the managed reference type
(System.Char).

Willy.

Feb 7 '06 #8
"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl...

"James Park" <so*****@hotmai l.com> wrote in message
news:eN******** ******@TK2MSFTN GP15.phx.gbl...
| "Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
| news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
| > Cool. The code you provided works! But, it is easy to fall into the
| > following trap. This code doesn't work:
| >
| > char chr_a = 'a' ;
| > string text = "" ;
| > text = text->Insert(0, chr_a.ToString( )) ;
| >
| > The difference here is that it invokes the 'char' version of ToString.
The
| > result of the above is the following:
| >
| > text = "97" ;
| >
| > 97? That's weird. Not really. the ASCII value of the char ' a' is 97.
But
| > I definitiely fell into the trap a few weeks back. The reason this
works:
| >
| > text = text->Insert(0, Char::ToString( chr_a)) ;
| >
| > is because it uses the 'Char' version of ToString instead of the
'char'.
| > What a difference a capital 'C' makes...
|
| If you want to use the VC++ type name for Char, it's wchar_t. You can
find
a
| table at
|
http://msdn.microsoft.com/library/en...eConfusion.asp
|
|

Which is just another native type, not the managed reference type
(System.Char).


Don't native types just become aliases for managed types when inside managed
code?
Feb 7 '06 #9

"James Park" <so*****@hotmai l.com> wrote in message
news:ue******** *****@TK2MSFTNG P14.phx.gbl...
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| news:OP******** ******@TK2MSFTN GP10.phx.gbl...
| >
| > "James Park" <so*****@hotmai l.com> wrote in message
| > news:eN******** ******@TK2MSFTN GP15.phx.gbl...
| > | "Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
| > | news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
| > | > Cool. The code you provided works! But, it is easy to fall into the
| > | > following trap. This code doesn't work:
| > | >
| > | > char chr_a = 'a' ;
| > | > string text = "" ;
| > | > text = text->Insert(0, chr_a.ToString( )) ;
| > | >
| > | > The difference here is that it invokes the 'char' version of
ToString.
| > The
| > | > result of the above is the following:
| > | >
| > | > text = "97" ;
| > | >
| > | > 97? That's weird. Not really. the ASCII value of the char ' a' is
97.
| > But
| > | > I definitiely fell into the trap a few weeks back. The reason this
| > works:
| > | >
| > | > text = text->Insert(0, Char::ToString( chr_a)) ;
| > | >
| > | > is because it uses the 'Char' version of ToString instead of the
| > 'char'.
| > | > What a difference a capital 'C' makes...
| > |
| > | If you want to use the VC++ type name for Char, it's wchar_t. You can
| > find
| > a
| > | table at
| > |
| >
http://msdn.microsoft.com/library/en...eConfusion.asp
| > |
| > |
| >
| > Which is just another native type, not the managed reference type
| > (System.Char).
|
| Don't native types just become aliases for managed types when inside
managed
| code?
|
|

Sure, my bad I missed your point completely, the native types do map to
their equivalent managed types.
That is:
wchar_t maps to System.Char
while:
char maps to System.SByte

Willy.


Feb 8 '06 #10

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

Similar topics

3
8594
by: Greg Bryant | last post by:
I'm doing some work for a company that has an auction site running in coldfusion. They're not real happy with it, and it needs a major overhaul, so I'm looking at redoing it, and while I'm at it, might as well move to PHP (for a variety of reasons - not trying to reopen the PHP -vs- CFM thing again :). Anyway, so I'm looking at this system, and there are no "scheduled tasks" (it's win2kas). How do you write a server app that needs to...
6
5951
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question is this... is Perl so much better at parsing text files and outputing that we would see a substantial speed increase? We process about 10 million records in flat files a day for reformatting before putting them in a DB. Also, when it comes to...
27
2088
by: John Bailo | last post by:
The recent quarterly earnings report, required by law, issued by the Microsoft Corporation are a harbinger of what is to come. Slowing revenue growth, and declining profits. What we see here is a Chrysler, circa 1973, in the making. A bloated heavy industry giant unable to compete in the 21st century marketplace and using legal tricks, government subsidies and public relations to prop up its decaying position. Bill Gate is a Chairman...
13
2860
by: BK | last post by:
Can someone point me to a code sample that illustrates executing long running tasks (asynchronous) from a web application in ASP.NET? I assume that Web Services might come into play at some point, but I'm not sure how to get started. For example, I have an application that, upon a user initiating through a button or link click, will go out and generate a bunch of files (this could take several minutes). This will happen in batches, so I...
9
3678
by: klh | last post by:
We are running on Win 2003/DB2 V8 FP7a. My question concerns Task Center. I have about 200 tasks created and scheduled in Task Center. We are going to be moving many of the databases from this server to another V8 server and I really, really, really don't want to have to re-key all of these tasks on the new system. The Task Center "export" function seems to only export general task information like the description and type of task,...
5
2196
by: rdemyan via AccessMonster.com | last post by:
I would like to have my application add administrative tasks to an Administrator's Outlook Task Folder. I know how to get the User group of the CurrentUser and think I can even code how to do the actual additions. A couple of questions: 1) How do I code it so that it only occurs once - the first time the administrator opens my app. I think I need code that checks if the tasks are already there in Outlook and then aborts if they are....
10
3115
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005 and .net 2.0. I started 2 threadpool threads. How do I know when they're done with their tasks? Thanks. ThreadPool.QueueUserWorkItem(new WaitCallback(PopulateContextTable)); ThreadPool.QueueUserWorkItem(new WaitCallback(PopulatAdTable)); -- Thanks.
0
1020
by: gojners | last post by:
I need to go through a set of tasks. Each task has a priority (low/medium/high) and a status (Open/In progress/Closed). Each task also has a membership (Internal/External/Other). My problem is that I need to (in pseudocode): 1 Go through all tasks to see if they are "Open" OR "In progress" 2 For all tasks that are "Open" OR "In progress" --> Order the tasks based on priority (High = first row of the column. Low = rows below both High &...
3
2986
by: Steven Blair | last post by:
I have been watching an MSDN video on the PFX Task class and have a question. Here is my scenario: TcpListener waits on incoming connections. Once a new connection is established, a new Task will be created. So, for my example, 8 connections have been established almost all at the same time (8 Tasks object). If my server is a dual core (for arguments sakes, 4 Tasks per CPU) does
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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
10273
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...
1
10250
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
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
9085
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...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4149
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
3
2944
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.