Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: "game" fast fingers Pin
Aljaz11125-Mar-09 10:25
Aljaz11125-Mar-09 10:25 
GeneralRe: "game" fast fingers Pin
Aljaz11125-Mar-09 11:25
Aljaz11125-Mar-09 11:25 
GeneralRe: "game" fast fingers Pin
CPallini25-Mar-09 11:49
mveCPallini25-Mar-09 11:49 
GeneralRe: "game" fast fingers [modified] Pin
Aljaz11125-Mar-09 13:04
Aljaz11125-Mar-09 13:04 
GeneralRe: "game" fast fingers Pin
CPallini25-Mar-09 22:33
mveCPallini25-Mar-09 22:33 
GeneralRe: "game" fast fingers Pin
Niklas L26-Mar-09 1:33
Niklas L26-Mar-09 1:33 
GeneralRe: "game" fast fingers Pin
Aljaz11126-Mar-09 3:35
Aljaz11126-Mar-09 3:35 
GeneralRe: "game" fast fingers Pin
CPallini26-Mar-09 4:03
mveCPallini26-Mar-09 4:03 
Do you realize that both letters and digits are ASCII characters? You don't need two functions.

Aljaz111 wrote:
int j= (rand()%2)+1;

The 1 is irrilevant for the purpose. Using rand()%2 is poor on statistical grounds, anyway, I suppose this is the least important issue, at the moment.

Aljaz111 wrote:
m_number=getRandomSymbol2();
char c[10];
itoa(m_number,c,10);
CString MFCString;
MFCString = c;
AppendTextToEditCtrl(editbox, MFCString);

What a mess.


Well, that said, let's focus on 'comparing'.
Roughly speaking, when OnChar is called, it receive, as nChar parameter, the ASCII code of the key pressed. You've just to compare it with the symbol currently shown in the edit box. For instance

// when generating random symbol
// m_curSymbol is a char member variable of your CWnd class 
m_curSymbol = getRandomSymbol();  
//...


then
// inside OnChar method
...
if ( nChar == m_curSymbol )
{
// whatever
}
//..


Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: "game" fast fingers [modified] Pin
Aljaz11126-Mar-09 5:31
Aljaz11126-Mar-09 5:31 
GeneralRe: "game" fast fingers Pin
CPallini26-Mar-09 7:20
mveCPallini26-Mar-09 7:20 
GeneralRe: "game" fast fingers Pin
Aljaz11126-Mar-09 7:53
Aljaz11126-Mar-09 7:53 
QuestionRe: "game" fast fingers Pin
CPallini26-Mar-09 8:48
mveCPallini26-Mar-09 8:48 
GeneralRe: "game" fast fingers Pin
David Crow25-Mar-09 9:26
David Crow25-Mar-09 9:26 
AnswerRe: "game" fast fingers Pin
led mike25-Mar-09 9:40
led mike25-Mar-09 9:40 
GeneralRe: "game" fast fingers Pin
Aljaz11125-Mar-09 9:47
Aljaz11125-Mar-09 9:47 
GeneralRe: "game" fast fingers [modified] Pin
CPallini25-Mar-09 10:11
mveCPallini25-Mar-09 10:11 
GeneralRe: "game" fast fingers Pin
led mike26-Mar-09 5:37
led mike26-Mar-09 5:37 
QuestionSerial Mouse data to Mouse driver [modified] Pin
THAQCD25-Mar-09 7:42
THAQCD25-Mar-09 7:42 
QuestionGetting notification from CRichEditView Pin
rp_suman25-Mar-09 6:20
rp_suman25-Mar-09 6:20 
AnswerRe: Getting notification from CRichEditView Pin
Iain Clarke, Warrior Programmer25-Mar-09 6:50
Iain Clarke, Warrior Programmer25-Mar-09 6:50 
Questionwinamp c++ class Pin
Jacavienna25-Mar-09 5:47
Jacavienna25-Mar-09 5:47 
QuestionDevPartner problem Pin
RedSonja25-Mar-09 5:11
RedSonja25-Mar-09 5:11 
AnswerRe: DevPartner problem Pin
Eytukan25-Mar-09 5:32
Eytukan25-Mar-09 5:32 
GeneralRe: DevPartner problem [modified] Pin
RedSonja25-Mar-09 20:57
RedSonja25-Mar-09 20:57 
QuestionBest way to measure time interval of external events Pin
Member 23626225-Mar-09 4:36
Member 23626225-Mar-09 4:36 

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.