|
Static control is good for show picture but why you want to use Edit Ctrl
|
|
|
|
|
Hi,
I have written a piece of code in WM_KEYDOWN for the tab key when the tab key is pressed in the edit box.It does what it is supposed to do but before that the tab key shifts the data in the edit box 4 spaces ahead usually what a tab key does.
To stop the tab key from its natural behaviour what should be overridden?
Thanks a ton.
Prithaa
|
|
|
|
|
Did you try overriding the PreTranslateMessage
|
|
|
|
|
Hi,
No I have not tried PreTranslateMessage.
So,What Should I do in PreTranslateMessage()
Prithaa
|
|
|
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_TAB)
pMsg->wParam=NULL;
This way we are handling the message before it is dispatched to the TranslateMessage and DispatchMessage Windows functions. In short, this will completely nullify the effect of tab key within your dialog.
|
|
|
|
|
Hello,
Thanks
It worked.
Prithaa
|
|
|
|
|
prithaa wrote: Thanks
You're welcome.
The nail that stands out will be hammered down
|
|
|
|
|
prithaa wrote: Thanks
It worked.
Prithaa
IMHO.. I never liked Switch case and If statement in PretranslateMessage.. i believe you should create handller for Wm_KEYDOWN!
"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
Support CRY- Child Relief And You
|
|
|
|
|
Can someone explain this to me please? I'm trying to understnad the code snippet below. This function is actually used to form a complete message that you can send on the serial com port using the win32 file function WriteFile.
However I'm getting a bit confused trying to work out what the final string would be if the initial value of DWord is 256. I've attached my current working below the code. Any help would be greatly appreciated.
Code Snippet
typedef unsigned int DWORD;
typedef unsigned short WORD;
// Convert DWORD to a 4 characters long string, not null terminated.
// Little-endian is used.
string
DWORDToString(DWORD dword)
{
string str = "1234";
str[0] = (char)((dword >> 0) & 0x000000ff);
str[1] = (char)((dword >> 8) & 0x000000ff);
str[2] = (char)((dword >> 16) & 0x000000ff);
str[3] = (char)((dword >> 24) & 0x000000ff);
return str;
}
My Working.....
Initial value of DWord = 256
Binary equivalent = 1 0000 0000
Hex equivalent = 100
str[0] = (char)((dword >> 0) & 0x000000ff);
1 0000 0000 Right shift >> 0 gives 1 0000 0000
Hex = 0x000000ff
Binary = 1111 1111
1 0000 0000
1111 1111
----------------
0 0000 0000
Str[0] = 0 == 0x00
str[1] = (char)((dword >> 8) & 0x000000ff);
1 0000 0000 Right shift >> 8 gives 0000 0001
Hex = 0x000000ff
Binary = 1111 1111
0000 0001
1111 1111
----------------
0 0000 0001
Str[1] = 1 == 0x01
str[2] = (char)((dword >> 16) & 0x000000ff);
1 0000 0000 Right shift >> 16 gives 0000 0000 0000 0001
Hex = 0x000000ff
Binary = 1111 1111
0000 0000
1111 1111
----------------
0000 0000
Str[2] = 0 == 0x00
str[3] = (char)((dword >> 24) & 0x000000ff);
1 0000 0000 Right shift >> 16 gives 0000 0000 0000 0000 0000 0001
Hex = 0x000000ff
Binary = 1111 1111
0000 0000
1111 1111
----------------
0000 0000
Str[3] = 0 == 0x00
|
|
|
|
|
What output were you expecting from your function? Compare that output to the actual output, how do they differ?
|
|
|
|
|
The function is just ensuring that the bytes are in little-endian order no matter what processor
it's running on.
On an x86 machine you could just do this
string
DWORDToString(DWORD dword)
{
string str = "1234";
*((DWORD*)(&str[0])) = dword;
return str;
}
but it wouldn't be the same on a processor that stores 32-bit integers in big-endian order.
The function
Takes the low-order 8 bits and puts it at index 0 position in the array
Takes the next highest order 8 bits and puts it at index 1 position in the array
Takes the next highest order 8 bits and puts it at index 2 position in the array
Takes the highest order 8 bits and puts it at index 3 position in the array
I don't know if this was a typo but
1 0000 0000 Right shift >> 16 gives 0000 0000 0000 0001
is wrong. Should be
1 0000 0000 Right shift >> 16 gives 0000 0000 0000 0000
1 0000 0000 Right shift >> 24 gives 0000 0000 0000 0000
|
|
|
|
|
I don't know if this was a typo but
1 0000 0000 Right shift >> 16 gives 0000 0000 0000 0001
is wrong. Should be
1 0000 0000 Right shift >> 16 gives 0000 0000 0000 0000
1 0000 0000 Right shift >> 24 gives 0000 0000 0000 0000
I think I may have confused you with the way I have written it. I haven't shown them as falling off the end. If you look at where I use the AND function they are represented exactly as you have stated above. Sorry about the confusion. I've tried to clear it up in the original post.
So can someone tell me what the final str would output would be? I'm unable to run the whole program due to certain hardware restrictions so I've created a little test piece of code to view the final result. I get the following
Output str[0]=
Output str[1]=☺
Output str[2]=
Output str[3]=
Str =
The trouble is I then want to concatenate this final str to another string later on but I don't know what str actually is. Is it 0x00010000? But this is in hex should it not be as a char?
|
|
|
|
|
Monk111 wrote: I haven't shown them as falling off the end
Why? They are gone. Why would you leave the 1 on the end and then say ANDing it with 0xFF will
give a result of 0x00?
Anyway...
The final string -
You call the function with dword == 256 (0x00000100)
The resulting str would be str[0] == 0x00, str[1] == 0x01, str[2] == 0x00, str[3] == 0x00
Say you called the function with dword == 0x01020304
The resulting str would be str[0] == 0x04, str[1] == 0x03, str[2] == 0x02, str[3] == 0x01
These aren't ASCII characters so you can't assume you can safely concatenate using a regular
string function. The resulting "string" is just an array of binary bytes (octets) representing
the dword in "little-endian" order. This would be useful if you are writing the bytes in order
across a network so the other end can reassemble them back in to a DWORD regardless of what type
processor is running.
Are you trying to convert a DWORD to a readable ASCII string?
Mark
|
|
|
|
|
Contact me if you can help in making this project come to reality. I would like to get it done as soon as possible but also hope not to pay more than $8K for some top programming for IP Camera software. Is this possible? Am I crazy? I may even entertain a share for the programmer in the Business I am starting.:->
|
|
|
|
|
|
Delicously evil
|
|
|
|
|
You are SO mean, dude...
Windows Calculator told me I will die at 28.
|
|
|
|
|
toxcct wrote: XML pretty Print
toxcct wrote: This[^] is not a regular way to ask for something.
he he he
"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
Support CRY- Child Relief And You
|
|
|
|
|
Dear All,
I am not sure whether I should post this question in this forum.
If not please let me know the correct forum to post the question.
I am using CPPUnit::XmlOutputter to write the unit test results to an XML file.
The program works as expected and I can see the test results in the xml file.
But I also want to add intermediate results and user defined messages in the same xml result file.
How do I do that?
Thanks a ton,
Arti gujare
|
|
|
|
|
Well I won't say that it's the wrong forum but you might have better luck asking in the CPPUnit forums on sourceforge. Not that you won't get an answer here but you are more likely to get a correct answer there.
|
|
|
|
|
Thank you Wes Aday. I will post it there too.
|
|
|
|
|
Can someone give me a simple example of accessing and sending a image to a picture box control at run time??
Jerry
|
|
|
|
|
Try the .Net Framework[^] board.
There's an example in the PictureBox class overview in the docs.
Mark
|
|
|
|
|
Actually I want to use a Picture Control.
Jerry
|
|
|
|
|
Picture Box? what do you need?
|
|
|
|