|
According to MSN[^], that's all that's in there. So I expect you just need to cast the value to throw off the extra bits you don't need.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian,
thanks for your instant feedback.
I've already tried to copy the bits according to this article, but unfortunately it doesn't work.
For example:
- the the Num-Pad keys returns lowercase characters
- the '+' and '-' keys haven't the normal ascii code
- all alphabetical keys from the keyboard are uppercase characters
It's a bit confusing...
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
Have you tried WM_CHAR ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
It's a dialog based application.
I've set a breakpoint in the WM_CHAR handler but it seems that the handler never gets called.
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
I created a VC6 dialog project and put this in PreTranslateMessage:
if (pMsg->message == WM_KEYDOWN)
{
CString s;
s.Format("%d %c", pMsg->wParam, pMsg->wParam);
AfxMessageBox(s);
}
I got the same result as you. I replaced WM_KEYDOWN with WM_CHAR and got upper and lowercase and correct values for the keypad.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yeah it works !
Thanks a bomb !
It's 3:23 a.m here in germany, and now that it works I can finally go to bed.
Thanks a lot !
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
No worries - glad to help
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
I check the WM_KEYDOWN message in the PreTranslateMessage() handler...
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
|
WM_KEYDOWN does NOT return ASCII characters. It returns virtual-key codes for the keys which happen to be ASCII characters for some of the keys.
The TranslateMessage function looks for WM_KEYDOWN messages and if it can convert the data in that message to a character-code (ASCII codefor ASCII keyboards???) then it generates a WM_CHAR message.
http://blog.ngedit.com/2005/06/13/whats-broken-in-the-wm_keydownwm_char-input-model/[^]
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
i really need help writing this program:
In this assignment, you will creating a simple interactive guessing game, which is based on random numbers. The game is simple: two dice are rolled; you need to predict whether the sum of the next roll will be higher or lower than the previous roll. For example, you may have the first die roll a 2 and the second die roll a 3. The sum of this roll is 5. Statistically speaking, you should "predict" higher because the average roll results in 6. If the roll is higher than or equal to 5 and you predicted it to be higher, then you get to continue. If the roll is lower (or equal to) and you predicted lower, you get to continue. Basically a wrong prediction will end the game.
Background: This program could potentially play forever (though it's doubtful), so obviously you need a loop of some kind - but choose carefully.
Requirements: Basically the program should behave as closely to the example below as possible; the grade breakdown is roughly as follows:
For a 'C': Get the program to roll the dice once, ask if the next roll will be higher or lower, roll the dice again and say if it was correct or not.
For a 'B': Get the program to repeatedly do this until they guess wrong
For an 'A': Get the program to track the number of times the user guessed correctly
can some1 plz plz help me
|
|
|
|
|
Shantise2003 wrote:
In this assignment, you will creating a simple interactive guessing game, which is based on random numbers.
I'm happy to do this for you, I'll have it done in about half an hour. I'll charge $20. When you get your next assignment, you'll have no idea how to do it, because it will build on the knowledge you should have build with this program. So, my price will double. By the time you graduate, you'll know nothing, and I'll have bought a house.
OR, you could start on this project yourself, with reference to your course notes and whatever books you have. Then, if you get stuck and ask specific questions here, I'll help you gladly, for free.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Hi again. YOu emailed me as follows:
ok i have started the project on my own so after i put the basic skeleton i put (int userchoice = ??) i dont know what to put there so can you help me?
erm... I meant to do more than get the wizard to generate a skeleton. Why not post your code ? If you're yet to write any, look into cout and cin.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
let me throw the die
V
|
|
|
|
|
hi, all
the program I am working on returns a 7 digits value for cycle number, it should be 1-99, i am trying to find out where it gets this value, i set some breakpoints, it has the right value 02 at the beginning, at the end of the onPaint() function of dlgMain.cpp, it will go to next function void CMainWnd::OnOK(), the 1243994 as value show up, it looks like some sort of memory location to me, but seems like between these two function are all disassembly stuff, i couldn't really read them.....looking at call stack, still can't find it stop at which file to get this value either...
anybody has any idea? thanks for your time.
|
|
|
|
|
valerie99 wrote:
.looking at call stack, still can't find it stop at which file to get this value either...
Simplest way debugging is to show messagebox containg the values at the point you think there is problem.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
how can i get the md5 hash of something in mfc
|
|
|
|
|
google - there are plenty of MD5 examples available online.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thats what i am doing write now... but all i am finding is forums about ppl asking what php's md5() function is for...
|
|
|
|
|
First hit[^]
You need to think about what you type into google. I typed md5 C++ source code. md5 by itself would obviously get a lot of other hits.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Any set of C functions would integrate nicely with MFC. Here's[^] one C-implementation. All you have to do is to copy'n'paste, and you're set.
char text[] = "your text here";
md5_context ctx;
md5_starts(&ctx);
md5_update(&ctx, (unsigned char*)text, sizeof(text));
unsigned char md5hash[16];
md5_finish(&ctx, md5hash); There you go! Please note that the contents of md5hash will be in binary format. It's not a string, it's an array of exactly 16 bytes. If you need to convert it into a string, then you'll have to do something like this:
char hashtext[33];
for(int i = 0; i < 16; ++i) {
unsigned char hinibble = ((md5hash[i] & 0xF0) >> 4);
unsigned char lonibble = md5hash[i] & 0xF;
hashtext[i * 2] = hinibble >= ? (hinibble - 10) + 'A' : hinibble + '0';
hashtext[i * 2 + 1] = lonibble >= ? (lonibble - 10) + 'A' : lonibble + '0';
}
hashtext[32] = 0; hashtext will now contain the hash on a hexadecimal form.
Also note that the input can be any kind of data, it doesn't have to be text! Any byte chunk would do.
Good music: In my rosary[^]
|
|
|
|
|
I've had an md5 implementation here on Codeproject for years and years. It works fine, although its pretty old fashioned code. There are several other MD5 examples here.
You can also use the MS Crypto API, look up the documentation for CryptCreateHash in Platform SDK.
|
|
|
|