Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
I feel like an idiot asking this... Posted by GreasyP on 6 Apr 2001 at 10:50 PM
Ok. This should be really simple, but I'm going crazy figuring it out so please help.
You know how if you press enter in an edit box (single line) sometimes it will cause a "default" button to be pressed? I know how to do this in a dialog box, it's easy, but this happens even outside of dialog boxes - I see it all the time in different applications, even right here in Internet Explorer, on Altavista I can type my search and then just hit enter and it automatically selects the "search" button.
Well... how the heck is this done?!? I've been searching through the MSDN for the last hour and I've tried everything I can think of, but I can't get it to work - edit boxes send keyboard presses that they don't process to DefWindowProc, so my parent window that the edit box is in never even sees the keypress. What can I do to fix this, I'm going nuts?
Note - key point, I am not using a dialog box, but a regular WS_OVERLAPPED window. I have to for design reasons.

Report
Re: I feel like an idiot asking this... Posted by Sephiroth2 on 7 Apr 2001 at 2:49 AM
: Ok. This should be really simple, but I'm going crazy figuring it out so please help.
: You know how if you press enter in an edit box (single line) sometimes it will cause a "default" button to be pressed? I know how to do this in a dialog box, it's easy, but this happens even outside of dialog boxes - I see it all the time in different applications, even right here in Internet Explorer, on Altavista I can type my search and then just hit enter and it automatically selects the "search" button.
: Well... how the heck is this done?!? I've been searching through the MSDN for the last hour and I've tried everything I can think of, but I can't get it to work - edit boxes send keyboard presses that they don't process to DefWindowProc, so my parent window that the edit box is in never even sees the keypress. What can I do to fix this, I'm going nuts?
: Note - key point, I am not using a dialog box, but a regular WS_OVERLAPPED window. I have to for design reasons.
:
There are at least two ways to do this.
1. change the edit box routine to point to your own
OR
2. trap the message in your main message loop

Report
Re: I feel like an idiot asking this... Posted by Hasan on 7 Apr 2001 at 6:35 AM
Hello there.

If I have understood your question correctly then you can do the following:

When the user hits the enter/return key you can pass on the focus to the next control, which will be a button in this case and then press the button using the code.

Use the following code in Delphi

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
IF Key = #13 THEN
begin
button1.SetFocus;
button1.Click;
end;
end;


I really hope that helps.



"The biggest fool of all the foolish fools is BettyBoy. You know who you are!"


Report
Re: I feel like an idiot asking this... Posted by Sephiroth2 on 10 Apr 2001 at 3:17 PM
: Hello there.
:
: If I have understood your question correctly then you can do the following:
:
: When the user hits the enter/return key you can pass on the focus to the next control, which will be a button in this case and then press the button using the code.
:
: Use the following code in Delphi
:
: procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
: begin
: IF Key = #13 THEN
: begin
: button1.SetFocus;
: button1.Click;
: end;
: end;
:
:
: I really hope that helps.
:
:
:
: "The biggest fool of all the foolish fools is BettyBoy. You know who you are!"
:
:

Obviously he can't use the code in Delphi because he doesn't program in Delphi.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.