Article View: borland.public.cppbuilder.nativeapi
Article #14478Re: Disabling a dialog button results in lost characters.
From: Bob Gonder
Date: Tue, 12 Aug 2003 00:35
Date: Tue, 12 Aug 2003 00:35
30 lines
2168 bytes
2168 bytes
Gary Setter wrote:
>> So, when you Disable a window(button), No Other Window Gets the Focus!
>> You Must SetFocus to another window(button) if you want to continue
>> getting keyboard input.
>
>BOOL DialogCls::EnableWindow(HWND hWnd, bool enable)
>{
> BOOL disabled = ::EnableWindow(hWnd, enable);
> if (!disabled && !enable && hWnd )
> SetFocus(GetParent(hWnd));
> return disabled;
>}
>
>Does it look sane to you? Is there a better way?
Just thinking out load here...
BOOL ret;
if( hWnd == GetFocus() ) /* if this has focus */
{ if( enable == (ret=EnableWindow( hWnd, enable )) )
SetFocus(.)
}else{ ret=EnableWindow( hWnd, enable );
};
return ret;
That assumes that the button can't have focus if it is diabled and you
are trying to enable it (I'm not sure on that, and MS has fooled me
more than once on what seems reasonable.)
Also, rather than GetParent() I would prefer to have another button
focused (unless there is only one button on the form).
Technical Details
Message-ID:
<ukcgjvkknj269lv5hl3j6rme0va3nhcsee@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f34ee12$1@newsgroups.borland.com> <3F370EB6.3DB6@uniserve.com> <3f37be6f@newsgroups.borland.com> <hahfjvojar7ujop8mujmipmqdae7n6326l@4ax.com> <3f37eacf$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f7216d587ba9f99f X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-11 17:39:37 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Disabling a dialog button results in lost characters. Date: Mon, 11 Aug 2003 17:35:48 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <ukcgjvkknj269lv5hl3j6rme0va3nhcsee@4ax.com> References: <3f34ee12$1@newsgroups.borland.com> <3F370EB6.3DB6@uniserve.com> <3f37be6f@newsgroups.borland.com> <hahfjvojar7ujop8mujmipmqdae7n6326l@4ax.com> <3f37eacf$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 64.158.107.105 X-Trace: newsgroups.borland.com 1060648547 64.158.107.105 (11 Aug 2003 17:35:47 -0700) Lines: 33 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail