Click here to Skip to main content
15,917,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How do I get font width and height in pixels ? Pin
udiraz18-Jan-06 23:11
udiraz18-Jan-06 23:11 
GeneralRe: How do I get font width and height in pixels ? Pin
Shraddhan22-Jan-06 22:09
Shraddhan22-Jan-06 22:09 
GeneralRe: How do I get font width and height in pixels ? Pin
udiraz22-Jan-06 22:20
udiraz22-Jan-06 22:20 
GeneralRe: How do I get font width and height in pixels ? Pin
Shraddhan22-Jan-06 23:55
Shraddhan22-Jan-06 23:55 
GeneralRe: How do I get font width and height in pixels ? Pin
udiraz23-Jan-06 0:42
udiraz23-Jan-06 0:42 
QuestionSSE/SSE2 optimization with VC 8.0 Pin
pgrohs16-Jan-06 7:11
pgrohs16-Jan-06 7:11 
QuestionBeginner Visual c++ , code for adding two integers Pin
Technobizz16-Jan-06 6:55
Technobizz16-Jan-06 6:55 
AnswerRe: Beginner Visual c++ , code for adding two integers Pin
Bob Flynn16-Jan-06 7:18
Bob Flynn16-Jan-06 7:18 
Take a look at CP, I think you can find some example calculators.

But it is not a trivial problem. You have to keep track of the states that you are in. Look at the book "Practical Statecharts in C/C++" by Miro Samek for a description of how to create a robust solution.

But if all that you are looking for is adding two numbers (i.e. no other functionality for this program) your states can be trivial. If you only have the digits 0-9 and a + and =, I think you can get by doing the following:
For each number pressed: Add that digit to the display field
For +: store the integer in the display and prepare to clear the display when the next number is pressed.
For =: get the number currently displayed and ADD it to the stored number.

Draw a state diagram to make sure you cover various cases, such as pressing 1010 + = : this should have the effect of 1010 + 1010 = 2020.
+ 1010 = : this should have the effect of 0 + 1010 = 1010

And what about 1010 + + = : 1010 + 1010 + 1010 = 3030

The book I mention covers a calculator example and should be very helpful in general for learning how to handle statemachines.
AnswerRe: Beginner Visual c++ , code for adding two integers Pin
toxcct16-Jan-06 7:21
toxcct16-Jan-06 7:21 
General[Message Deleted]...and... Pin
toxcct16-Jan-06 7:46
toxcct16-Jan-06 7:46 
GeneralRe: :mad: :mad: :mad: :mad: :mad: Pin
BlackDice16-Jan-06 8:18
BlackDice16-Jan-06 8:18 
GeneralRe: :mad: :mad: :mad: :mad: :mad: Pin
Nish Nishant16-Jan-06 8:52
sitebuilderNish Nishant16-Jan-06 8:52 
GeneralRe: :mad: :mad: :mad: :mad: :mad: Pin
Bob Flynn16-Jan-06 10:22
Bob Flynn16-Jan-06 10:22 
GeneralRe: :mad: :mad: :mad: :mad: :mad: Pin
ThatsAlok16-Jan-06 17:00
ThatsAlok16-Jan-06 17:00 
GeneralRe: :mad: :mad: :mad: :mad: :mad: Pin
Rajesh R Subramanian16-Jan-06 19:26
professionalRajesh R Subramanian16-Jan-06 19:26 
AnswerRe: Beginner Visual c++ , code for adding two integers Pin
ThatsAlok16-Jan-06 16:58
ThatsAlok16-Jan-06 16:58 
AnswerRe: Beginner Visual c++ , code for adding two integers Pin
vikas amin17-Jan-06 2:36
vikas amin17-Jan-06 2:36 
QuestionNeed different versions for different project configurations Pin
Wheatbread16-Jan-06 6:04
Wheatbread16-Jan-06 6:04 
AnswerRe: Need different versions for different project configurations Pin
Bob Flynn16-Jan-06 7:24
Bob Flynn16-Jan-06 7:24 
GeneralRe: Need different versions for different project configurations Pin
Wheatbread16-Jan-06 8:41
Wheatbread16-Jan-06 8:41 
AnswerRe: Need different versions for different project configurations Pin
Oleg Didenko17-Jan-06 4:52
Oleg Didenko17-Jan-06 4:52 
AnswerRe: Need different versions for different project configurations Pin
Blake Miller17-Jan-06 7:20
Blake Miller17-Jan-06 7:20 
QuestionSetWindowPos Pin
gomez_a16-Jan-06 5:39
gomez_a16-Jan-06 5:39 
AnswerRe: SetWindowPos Pin
Rage16-Jan-06 6:00
professionalRage16-Jan-06 6:00 
GeneralRe: SetWindowPos Pin
gomez_a16-Jan-06 6:26
gomez_a16-Jan-06 6:26 

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.