473,569 Members | 3,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CMapStringToStr ing 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 CMapStringToStr ing 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 CMapStringToStr ing...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 6985
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...than ks!

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 CMapStringToStr ing.

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 CMapStringToStr ing.

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
10942
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 object's members. now, i have an enclosing class, which has a static factory method (loads an instance of the enclosing class from a serialized file,...
2
9586
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, while an instance of class C should be able to check all methods #defined in C, B and A. #------------------------------------------------
2
2025
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 Base class (old-style) which defines a default class attribute 'bar' too. I can't modify the source code of this class. Note that Workes does not...
3
3039
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
3327
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 to turn a previously made String class that deals with char's into a templated String class that uses the template parameter C instead of char. I...
9
4977
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 pointer which points to an instance of a derived class, but when I pass that base class pointer into a function, it can't access the derived...
5
3148
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 CommonPageBase - Contains myPage which inherits PageBase Each of these classes overrides OnInit and ties an event handler
3
3745
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 thawed it out. I built a console app using Microsoft Visual C++ 6 (VC++) and it worked great. Only one line in the header file had to be commented out....
0
2816
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 magic, I wrote the following module. It is mainly useful as a light weight tool to help programmers catch mistakes at definition time (e.g.,...
0
7703
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...
0
8138
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...
1
7681
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...
0
7983
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...
0
6290
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...
0
3662
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
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
1
1229
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.