|
You call the getRandowSymbol function whenever you need a new random chosen letter.
For instance, suppose you want show one random letter in the edit box, then (supposing the member variable associated to the edit is a CString and it is called m_sEdit ) you may do
m_sEdit = getRandomSymbol();
eventually calling UpdataData(FALSE) method of the dialog.
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]
|
|
|
|
|
Next is how to read from keyboard in mfc?? I looked internet but two many confused explanations..plz help!
modified on Wednesday, March 25, 2009 7:25 PM
|
|
|
|
|
For instance, you may override the CWnd::OnChar [^] method.
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]
|
|
|
|
|
I truly admire you patience!
|
|
|
|
|
I have two functions for randomsymbol..first for char second for number from 1-10.. Here i am adding it to edit box..
for(int i=0; i<10; i++)
{
int j= (rand()%2)+1;
if(j==1)
{
m_sEdit=getRandomSymbol1();
AppendTextToEditCtrl(editbox, m_sEdit);
}
else
{
m_number=getRandomSymbol2();
char c[10];
itoa(m_number,c,10);
CString MFCString;
MFCString = c;
AppendTextToEditCtrl(editbox, MFCString);
}
CString dod;
dod=" ";
AppendTextToEditCtrl(editbox, dod);
}
1. How now to use onchar to compare each element in editbox and one pressed on keyboard... Later i will deal with timing...but for now..how to compare those two?
|
|
|
|
|
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
m_curSymbol = getRandomSymbol();
then
...
if ( nChar == m_curSymbol )
{
}
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]
|
|
|
|
|
I found other way for this.. i made hidden editbox with focuson(when pushes button start)...then user types in the box chars from keyboard.. now which method to use to get text from editbox and after comparison delete char that was in?? I tryed to use:
CString get;
CString strHidden;
get=hiddenEdit.GetWindowText(strHidden)
That doesn't work.
modified on Thursday, March 26, 2009 11:39 AM
|
|
|
|
|
Aljaz111 wrote: I tryed to use:
CString get;CString strHidden;get=hiddenEdit.GetWindowText(strHidden)
Why the hell you tryed the above. Didn't you see the GetWindowText signature in the documentation before calling it (what about the Intellisense?)?
GetWindowText has two overloads none of them returning a CString .
As Mike gently suggested ( ), documentation is your best best friend.
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]
|
|
|
|
|
I made code like this now... in ontimer..
void CtimerDlg::OnTimer(UINT_PTR nIDEvent)
{
int j= (rand()%2)+1;
if(j==1)
{
m_sEdit=getRandomSymbol1();
AppendTextToEditCtrl(m_edit, m_sEdit);
skritEdit.GetWindowText(strGet);
strGet.MakeUpper();
if(m_sEdit==strGet) stevec1++;
}
....
UpdateData(TRUE);
CDialog::OnTimer(nIDEvent);
}
On pushed button1 1 timesets...on pushed button2 timekills and shows stevec1..now i dont know why stevec1 isn't raising when i hit specific char in hidden box..i have it visible for now and chars are normally showing in other edit box.. but when i killtime stevec is not correct.. Any solutions?
|
|
|
|
|
Why don't you use the debugger (possibly increasing the timer period)?
BTW Why don't you make your project open source so that we can contribute more actively...
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]
|
|
|
|
|
Aljaz111 wrote: Still anyone can help me...
Sure, and there are plenty here that can and will. Instead of trying to tackle one large problem, break it down into several smaller problems. You'll improve your odds of receiving help that way.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Aljaz111 wrote: and must be made fast.
If "made fast" is in reference to some due date for the project, then you are off to a monumentally horrific start. Asking for help in internet forums when you have no experience might just be the slowest way in the universe to develop a software project.
Good luck, you're going to need it.
|
|
|
|
|
I know MFC basics and i know quite much of c++...
|
|
|
|
|
Aljaz111 wrote: i know quite much of c++...
Please don't be hurted, but in your previous posts, such a knowledge was well hidden.
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]
modified on Wednesday, March 25, 2009 4:19 PM
|
|
|
|
|
CPallini wrote: but in your previous posts, such a knowledge was well hidden.
And now it's bullshit.
|
|
|
|
|
I have a COM port open as a host (ie: COM3, 9600 baud, 8 bit, 1 stop) & receive stream data continously from another PC Serial interface (as client), the data represent as a standard Mouse protocol including 3 bytes:
1st byte 2nd byte 3rd byte
----------------- ----------------- -----------------
|-|1|?|?|X|X|Y|Y| |-|0|X|X|X|X|X|X| |-|0|Y|Y|Y|Y|Y|Y|
----------------- ----------------- -----------------
| | \ / \ / | |
| | | | | |
| | | ------------- ---------- |
| | ---------- | \ \ |
| | \_\_ _ _ _ _ _ _ \_\_ _ _ _ _ _ _
| | |_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|
| | X increment Y increment
Left Button -- |
Right Button ----
I would like to build a driver for this so that I can use these data as a Mouse device on my PC. I am am able to retrive data through COM port with VC++ 6.0, but I have never done this for creating as a driver before, can someone help me?
Thanks in-advanced for any help
modified on Wednesday, March 25, 2009 1:59 PM
|
|
|
|
|
I am writing some (rtf format)text in CRichEditView by using GetRichEditCtrl().
When clicking on the text I want to get the notification.
Where I can get WM_LBUTTONDOWN message, the notification function is not called when clicking the text.
How to get the notification?
Any suggestion would be greatly appreciable..
--
"Programming is an art that fights back!"
|
|
|
|
|
Look for the documentation for EN_SELCHANGE. That is sent if you ask for it (read the page for details), and then you get notified when the selection changes.
That was you handle the user clicking in different places, and update external stuff if you so wish.
If you just want to know when your view is clicked on to wake it up, you can make a new view vlass inheriting from CRichEditView and handle override CView::OnActivateView.
Good luck,
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Hi anybody any experience with writing plug-ins for winamp?? i have downloaded winamp.h and winamp.cpp but i'm at a loss at how to use them, the install instructions are very brief, can't seem to figure out what to do??
It comes with an example but when i try to compile it, it gives warnings in the winamp.cpp file? ....can anybody help share light on this as i'm really stuck
|
|
|
|
|
The Compuware website isn't helping me so I'll try here before I go home.
I have a lot of C++, and I prove how nicely I have tested it by running DevPartner Coverage. Easy.
Now it has decided to analyse the Microsoft standard libs too. I turned off all the other Microsoft stuff, in fact in was turned off by default anyway. I tried all the obvious things in Help.
And still I get hundreds of lines of this (as code not tested; of course I didn't test it!):
std::<debugheapallocator><char>::allocate...
std::<debugheapdelete><class>...
Looks like the standard lib to me.
Has anybody here had this problem? Has anyone a suggestion not mentioned in Help?
-------------
Bibo ergo sum
|
|
|
|
|
It took 10 minutes for me to understand your problem partially. There should be a way to ignore them. I've used Rational Coverage. We remove these libs from the result. Is there anyway in your tool? Did you search for it?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Ah, the helpful website cut out most of the messages because of strange characters.
There are several ways to remove things from the list, and I have tried all of them, quite successfully, with all my included dlls and exes, with the exception of these std libs.
Maybe there is a way to remove these results from the end result. It is very irritating, because my code is safety critical and I am supposed to be over 95% coverage, and this glitch pushes me down to 60% of code and 40% of methods.
Here is just one of those messages:
std:: (underline) DebugHeapAllocator (pointed bracket open) char (pointed bracket close) deallocate::deallocate(unsigned int)
-------------
Bibo ergo sum
modified on Thursday, March 26, 2009 3:26 AM
|
|
|
|
|
I would like to measure the start and stop time of an external event. I would like to get the best time resolution I can using a laptop computer. What is the best time resolutions available using Windows and C/C++. Is the resolution in milliseconds, microseconds, or nanoseconds? What would be a good way to get a signal into the laptop. We are thinking about having an external signal that could either be on or off like a switch, and we would like to make a precise measure how long that signal is turned on.
Thanks, any help would be greatly appreciated.
|
|
|
|
|
Member 236262 wrote: Is the resolution in milliseconds, microseconds, or nanoseconds?
The best you will be able to get on a Windows PC is around 15 msec, because Windows is not a real-time operating system. So, if you need resolution lower than 15 msec, you should use a real-time operating system.
|
|
|
|
|
I think this[^] can give better results than 15 msecs.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|