How can get value of keyboard pressed key?
-
change the initial if condition to something like this:
//IDC_EDIT1 is ID of the edit control of your interest
if(pMsg->message == WM_KEYDOWN && GetFocus()==GetDlgItem(IDC_EDIT1))
{
...
}Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd) ;P ptimization!
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
Do you mean to say that it isn't optimized? Have you examined the generated assembly? It would be essentially the same. Or, is that you're just kidding? :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Do you mean to say that it isn't optimized? Have you examined the generated assembly? It would be essentially the same. Or, is that you're just kidding? :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
I was kidding but it has to be true too. See, How come a getfocus() "call" be equivalent to a structure that's already coming in? Why do want to make an extra call to get the hwnd? Moreover getFocus() deals with CWnd* And how would the assemblies just match in parallel?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
I was kidding but it has to be true too. See, How come a getfocus() "call" be equivalent to a structure that's already coming in? Why do want to make an extra call to get the hwnd? Moreover getFocus() deals with CWnd* And how would the assemblies just match in parallel?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
It is not the assemblies being a "match". The essence of my statement is that the compiler will optimize it to a very reasonable extent, thereby making it the same. Simply because it "knows" what I'm trying to do. Everything becomes assembler instructions there. There's no API call or CWnd pointer to deal with. Do you agree that the following two snippets are essentially equally optimized? (not by way of code, but by way of the assembly the compiler generates)
while(condition)
{
CStringArray str;
__int64 nBigAss[10];
//use str and nBigAss
}CStringArray str;
__int64 nBigAss[10];
while(condition)
{
//use str and nBigAss
}One may argue "There is an allocation every time the loop runs". Well, I don't think so. (No, I ain't going to kill time generating and rearranging assembly with the PreTranslateMessage() stuff, but I can almost say it for sure) :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
It is not the assemblies being a "match". The essence of my statement is that the compiler will optimize it to a very reasonable extent, thereby making it the same. Simply because it "knows" what I'm trying to do. Everything becomes assembler instructions there. There's no API call or CWnd pointer to deal with. Do you agree that the following two snippets are essentially equally optimized? (not by way of code, but by way of the assembly the compiler generates)
while(condition)
{
CStringArray str;
__int64 nBigAss[10];
//use str and nBigAss
}CStringArray str;
__int64 nBigAss[10];
while(condition)
{
//use str and nBigAss
}One may argue "There is an allocation every time the loop runs". Well, I don't think so. (No, I ain't going to kill time generating and rearranging assembly with the PreTranslateMessage() stuff, but I can almost say it for sure) :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Yes modern compiler does these. But it will never optimize the way you say about "getfocus()". When you ask a compiler to make a call, it has to call. It doesn't know what you are going to do with the CWnd*. Not that intelligent dude ;p. So I still can't agree. :cool:
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
Yes modern compiler does these. But it will never optimize the way you say about "getfocus()". When you ask a compiler to make a call, it has to call. It doesn't know what you are going to do with the CWnd*. Not that intelligent dude ;p. So I still can't agree. :cool:
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
Actually, you were right the first time. I was just farting making up things, only because I said it. Probably you knew it too. And yes, I could have avoided a function call. You caught me there. :sigh: But ya know? I typed an answer on reading the query immediately. No opening of visual studio, no cheating. It couldn't be the most optimized answer and optimization can be left to the OP, right? You can understand, can't you? :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Actually, you were right the first time. I was just farting making up things, only because I said it. Probably you knew it too. And yes, I could have avoided a function call. You caught me there. :sigh: But ya know? I typed an answer on reading the query immediately. No opening of visual studio, no cheating. It couldn't be the most optimized answer and optimization can be left to the OP, right? You can understand, can't you? :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Rajesh R Subramanian wrote:
Actually, you were right the first time. I was just farting making up things, only because I said it. Probably you knew it too. And yes, I could have avoided a function call. You caught me there
I was actually kidding + tried to provoke you :D
Rajesh R Subramanian wrote:
But ya know? I typed an answer on reading the query immediately. No opening of visual studio, no cheating. It couldn't be the most optimized answer and optimization can be left to the OP, right? You can understand, can't you?
lol :) . Now I'm free to agre that you know more MFC than me. That's true.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
Actually, you were right the first time. I was just farting making up things, only because I said it. Probably you knew it too. And yes, I could have avoided a function call. You caught me there. :sigh: But ya know? I typed an answer on reading the query immediately. No opening of visual studio, no cheating. It couldn't be the most optimized answer and optimization can be left to the OP, right? You can understand, can't you? :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Rajesh R Subramanian wrote:
It couldn't be the most optimized answer and optimization can be left to the OP, right?
I think it's not just about optimization here. GetFocus and GetDlgItem can potentially return temporary CWnd objects - so comparing them won't always be the right thing to do. So Vunic's code seems to be the right way here.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
My latest book : C++/CLI in Action / Amazon.com link -
Actually, you were right the first time. I was just farting making up things, only because I said it. Probably you knew it too. And yes, I could have avoided a function call. You caught me there. :sigh: But ya know? I typed an answer on reading the query immediately. No opening of visual studio, no cheating. It couldn't be the most optimized answer and optimization can be left to the OP, right? You can understand, can't you? :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Rajesh R Subramanian wrote:
It couldn't be the most optimized answer and optimization can be left to the OP, right?
I think it's not just about optimization here. GetFocus and GetDlgItem can potentially return temporary CWnd objects - so comparing them won't always be the right thing to do. So Vunic's code seems to be the right way here.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
My latest book : C++/CLI in Action / Amazon.com linkIndeed, look at my previous reply (and vote) to him. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
We have made enough noise to wake up the gaint! :omg: See who has replied :D
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
You mean he was sleeping? :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
You mean he was sleeping? :-D
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Yes - w.r.t this forum. But I think for most of the question posted here, he would definitely find em boring :)
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
Rajesh R Subramanian wrote:
It couldn't be the most optimized answer and optimization can be left to the OP, right?
I think it's not just about optimization here. GetFocus and GetDlgItem can potentially return temporary CWnd objects - so comparing them won't always be the right thing to do. So Vunic's code seems to be the right way here.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
My latest book : C++/CLI in Action / Amazon.com linkHey man! I hope that you don't take this too seriously. Actually, I knew Vivek was right right at his first message, but it was the eight year kid within me that was arguing for fun. But however, when I look at it all again, I feel bad because my contributions are recognized here and I've been awarded, which means people would expect a lot more from me than having funny chats. I realised it and felt bad. I am also feeling that I am a lot matured than what I was earlier, but then I know it that I still need to work even more on this. There's a very long way for me. I hope you'd wish me good luck. Because if I didn't know it, that was a different thing. But knowing it and doing funny things on a public forum is unacceptable. I'm sorry about it (to everyone). I'll try to keep my message standards higher. I feel a lot relieved after posting this message. See ya. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Yes - w.r.t this forum. But I think for most of the question posted here, he would definitely find em boring :)
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
I myself find most questions boring. There's no doubt it should be boring for him. :) BTW, please read this[^].
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Hey man! I hope that you don't take this too seriously. Actually, I knew Vivek was right right at his first message, but it was the eight year kid within me that was arguing for fun. But however, when I look at it all again, I feel bad because my contributions are recognized here and I've been awarded, which means people would expect a lot more from me than having funny chats. I realised it and felt bad. I am also feeling that I am a lot matured than what I was earlier, but then I know it that I still need to work even more on this. There's a very long way for me. I hope you'd wish me good luck. Because if I didn't know it, that was a different thing. But knowing it and doing funny things on a public forum is unacceptable. I'm sorry about it (to everyone). I'll try to keep my message standards higher. I feel a lot relieved after posting this message. See ya. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Hey Rajesh I respect your contributions here and I am truly glad there are guys like you who prove repeatedly that not all Indian devs are like the low-lives who post their work assignments here using sms-slang and expect people to write the entire code for them for free. I did think your sub-thread with Vunic may have been distracting to the O.P. since he's a newbie, so perhaps it's best to avoid such humorous off-shoots in the technical forums. Have a great weekend. Maybe you could go see Dashavatharam. :-)
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
My latest book : C++/CLI in Action / Amazon.com link -
I myself find most questions boring. There's no doubt it should be boring for him. :) BTW, please read this[^].
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Hmm me too, to some extent when I look at the everyday breakfast questions. Like the Undeclared variable USES_CONVERSION ;p. lol. I'm not even getting enough time to peak into CP these days. That's really sad. If I come, and before I could understand the question, someone would have already replied to it, so I just cancel my effort. I grasp things a little slower lol :D.
Rajesh R Subramanian wrote:
BTW, please read this[^].
Huff, I'm really sad it's affected you in some way. That certainly would, when a senior like Nish point us to something that too when you have already given up the argument. After all Nish is like our elder Brother :). And you are like my younger brother :laugh: . Actually that's the best part you when agree/acknowledge to a conversation/argument's conclusion. [Though made a rough effort even after knowing what's what]. People usually vanish after coming to a point where they find they can argue no more. I don't have respect for them. You know a lot of stuff and I know you "just" argued. lol And you know I specifically target people who know better and that there's a lot option to learn things. I'd again agree YOU SPEAK A BETTER MFC THAN ME. lol :). And some day when I work in MFC you will get a lot of URGNTZ from me. :-D Good night :beer:
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]