473,508 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CMapStringToString class

79 New Member
I'm trying to use this calss to create a sort of data lookup program, where you type in some text, and the program returns the appropriate description.

I searched all over the net and there isn't a lot of documentation about this. I tried implementing the stuff written on the Microsoft website, but I can't seem to get the very first part to work:

Expand|Select|Wrap|Line Numbers
  1. #include <afxcoll.h>
The above gives me this error:

Expand|Select|Wrap|Line Numbers
  1. fatal error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
Honestly, this is the very first time I work with MFC and this function. I understand the theory behind the CMapStringToString function, but I have never implemented it. Also, I've been working with Visual Studio 2005 for a very short time (I switched from Visual Studio 6 last week).

Also if it is possible to show me an example of how to use CMapStringToString...I can probably figure it out on my own, but not before I get this #include problem out of the way.

Thank you very much.
May 22 '07 #1
8 6980
weaknessforcats
9,208 Recognized Expert Moderator Expert
Be sure WIN32 is defined in your project properties for the preprocessor.
May 22 '07 #2
ahammad
79 New Member
When I defined the project, I selected the Win32 Console Application, if that's what you're referring to.
May 22 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
No.

You should create a Win32 Project.

When the wizard appears, DO NOT CLICK FINISH. Instead, click Application Settings. Select Console Application and MFC.

Now click finish.

Add your files and try a build.
May 22 '07 #4
ahammad
79 New Member
Okay, I tried what you said and now the program compiles...thanks!

The other thing is using that class. Like I said earlier, I've never worked with it before. In any case, here is what I did:

Expand|Select|Wrap|Line Numbers
  1. CMapStringToString database();
This compiles fine as well. I still don't know how to use it properly though.

What I have so far:

Expand|Select|Wrap|Line Numbers
  1. database.SetAt(code, command)
Which is wrong, because code and command are arrays of strings, but the function SetAt takes in LPCTSTR, which, to be honest, I've never heard of. How do I go about doing this?
May 22 '07 #5
ahammad
79 New Member
Sorry about the double post, but for some reason I can't edit my post anymore :/

Anyway, with regards to the previous post, I forgot to mention that when I try to change code and command from type string to type CString, The other part of my code, the one that reads in values from a file, stops working and starts reading in garbage numbers/letters:

Expand|Select|Wrap|Line Numbers
  1. Please enter the filename: test.cpf
  2. 00359900=00359960
  3. 0035AE18=0035AE98
  4. 00359900=0035E048
  5. 00359900=0035E048
  6. 00359900=0035E048
  7. 0035E188=0035E048
  8. 0035E188=0035E048
  9. 0035E188=0035E048
  10. Data parsing has been completed
  11. Press any key to continue . . .
I should be getting this instead:

Expand|Select|Wrap|Line Numbers
  1. Please enter the filename: test.cpf
  2. <testcode1> = test command 1
  3. <testcode2> = test command 2
  4. <testcode3> = test command 3
  5. <testcode4> = test command 4
  6. <testcode5> = test command 5
  7. <testcode6> = test command 6
  8. <testcode7> = test command 7
  9. <testcode8> = test command 8 
  10. Data parsing has been completed
  11. Press any key to continue . . .
Thanks in advance
May 22 '07 #6
weaknessforcats
9,208 Recognized Expert Moderator Expert
I believe a LPCTSTR is a long-pointer-to-a-constant-TCHAR-string. Better to just call it a LPCTSTR.

From here on you need info on how to use MFC classes. I would start with Programming Windows with MFC by Jeff Prosise and go from there. You might find something by Googling CMapStringToString.

I don't have time to write a tutorial oin this class.
May 23 '07 #7
ahammad
79 New Member
I believe a LPCTSTR is a long-pointer-to-a-constant-TCHAR-string. Better to just call it a LPCTSTR.

From here on you need info on how to use MFC classes. I would start with Programming Windows with MFC by Jeff Prosise and go from there. You might find something by Googling CMapStringToString.

I don't have time to write a tutorial oin this class.
Thanks for the title of the book. I was looking for one yesterday but didn't find much. I'll go to the library later today and maybe I can find it.

Thanks again for your help, I appreciate it :)
May 23 '07 #8
weaknessforcats
9,208 Recognized Expert Moderator Expert
I checked and it's available on Amazon.com.
May 23 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
10938
by: Murat Tasan | last post by:
hi, i am having a small problem with constructing an inner class. i am using an inner class (and not a static nested class) because the methods of the inner class need access to the enclosing...
2
9577
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
2
2022
by: Gabriel Genellina | last post by:
Hi In the following code sample, I have: - a Worker class, which could have a lot of methods and attributes. In particular, it has a 'bar' attribute. This class can be modified as needed. - a...
3
3028
by: Robert | last post by:
Python doesn't know the class of a method when container not direct class attribute: >>> class X: .... def f():pass .... g=f .... l= .... >>> X.g <unbound method X.f>
1
3320
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
9
4967
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
5
3140
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
3
3739
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
0
2812
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
0
7225
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
7326
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
7385
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...
1
7046
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
5629
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,...
0
4707
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...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1558
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 ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.