Click here to Skip to main content
16,006,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: please Help me with this program Pin
juntupally17-Mar-04 8:53
juntupally17-Mar-04 8:53 
GeneralRe: please Help me with this program Pin
MeterMan17-Mar-04 10:44
MeterMan17-Mar-04 10:44 
GeneralRe: please Help me with this program Pin
David Crow18-Mar-04 2:33
David Crow18-Mar-04 2:33 
GeneralRe: please Help me with this program Pin
Ravi Bhavnani20-Mar-04 6:22
professionalRavi Bhavnani20-Mar-04 6:22 
GeneralHelp needed on ATL control Pin
ben217-Mar-04 6:18
ben217-Mar-04 6:18 
GeneralConverting a CString to CInt Pin
Blue Pyre17-Mar-04 6:15
Blue Pyre17-Mar-04 6:15 
GeneralRe: Converting a CString to CInt Pin
Joe Woodbury17-Mar-04 6:30
professionalJoe Woodbury17-Mar-04 6:30 
GeneralRe: Converting a CString to CInt Pin
Antti Keskinen17-Mar-04 6:37
Antti Keskinen17-Mar-04 6:37 
Pardon me, but what is a CInt ?
At least my MFC/MSDN/ATL reference does not know any such thing. Did you mean a normal integer ?

You should draw a quick schema of how a basic calculator works. Sketch an outline of the possible states your calculator can have, and all the possible ways to move from one state to another. For example, there is a 'neutral' state, from which you can press a button to move into 'entering a number' state. Take all possible ways into account, how a person could use a calculator, what buttons he/she might press. If you have a real calculator at hand, you can easily determine the possible routes.

But, this is all about designing your software. For the actual conversion, which you asked, you need to use the LPCTSTR-operator implemented in CString class. This gives you a pointer to a constant character buffer that efficiently represents the C-language version of the string. Then, depending if you have Unicode enabled, you can use the wide- or normal-versions of _atoi and _itoa routines that can convert a string representation of a number, e.g. "42341", into a number 42341, and vice versa.

As for the calculator itself, you need several CString objects and a few integers. The first one is bound to the actual text output (an edit box), and displays a formatted string looking like a calculator's output.

Then, the user interface of your calculator has buttons. Each of these buttons has a click handler. Basically, you need to implement each click handler (or a range handler) so, that it determines what button was pressed, and adds a raw number into a background number buffer accordingly.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Converting a CString to CInt Pin
HAHAHA_NEXT17-Mar-04 6:52
HAHAHA_NEXT17-Mar-04 6:52 
GeneralRe: Converting a CString to CInt Pin
Blue Pyre17-Mar-04 10:52
Blue Pyre17-Mar-04 10:52 
GeneralRe: Converting a CString to CInt Pin
MeterMan17-Mar-04 10:58
MeterMan17-Mar-04 10:58 
GeneralRe: Converting a CString to CInt Pin
Blue Pyre17-Mar-04 11:38
Blue Pyre17-Mar-04 11:38 
GeneralRe: Converting a CString to CInt Pin
Prakash Nadar17-Mar-04 14:55
Prakash Nadar17-Mar-04 14:55 
GeneralRe: Converting a CString to CInt Pin
MeterMan17-Mar-04 14:57
MeterMan17-Mar-04 14:57 
GeneralC++ .NET Forms Shutdown application Pin
Neoankt17-Mar-04 6:09
Neoankt17-Mar-04 6:09 
GeneralRe: C++ .NET Forms Shutdown application Pin
Antti Keskinen17-Mar-04 7:05
Antti Keskinen17-Mar-04 7:05 
GeneralNeed a Good COM Tutorial !!! Pin
HAHAHA_NEXT17-Mar-04 6:06
HAHAHA_NEXT17-Mar-04 6:06 
GeneralSecondary display dimension winxp Pin
Bernardo Faria17-Mar-04 6:04
sussBernardo Faria17-Mar-04 6:04 
GeneralSend F5 or left arrow message Pin
Tomaz Rotovnik17-Mar-04 5:33
Tomaz Rotovnik17-Mar-04 5:33 
GeneralRe: Send F5 or left arrow message Pin
gUrM33T17-Mar-04 14:50
gUrM33T17-Mar-04 14:50 
GeneralRe: Send F5 or left arrow message Pin
Tomaz Rotovnik18-Mar-04 7:25
Tomaz Rotovnik18-Mar-04 7:25 
GeneralHelp With Control Focus Pin
Jack Reed17-Mar-04 4:44
Jack Reed17-Mar-04 4:44 
GeneralRe: Help With Control Focus Pin
David Crow17-Mar-04 4:53
David Crow17-Mar-04 4:53 
GeneralRe: Help With Control Focus Pin
Jack Reed19-Mar-04 9:38
Jack Reed19-Mar-04 9:38 
Questionwhat does "rhs" mean? Pin
Bash17-Mar-04 4:23
Bash17-Mar-04 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.