Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Fri, 5 Sep 2008 18:06:51 -0400,    group: microsoft.public.win32.programmer.ui        back       


ShowWindow sends EM_SETSEL   
I have a dialog that contains a multiline edit control.  The dialog is 
initially invisible.  After the edit control is populated with some text, I 
call ShowWindow(Dialog,SW_SHOW) to show the dialog.

If the dialog has an owner, the edit control receives an EM_SETSEL message 
during the call to ShowWindow.

Does anyone know why the edit control receives an EM_SETSEL?  Is there any 
way to stop it?

Thanks a lot.

David Liebtag

PS Here is the sequence of messages that the dialog and edit control receive 
during the call to ShowWindow:

Dialog WM_SHOWWINDOW
Dialog WM_NCACTIVATE
Dialog WM_ACTIVATE
Dialog WM_WINDOWPOSCHANGING
Dialog WM_NCACTIVATE
Dialog WM_ACTIVATE
Dialog WM_IME_SETCONTEXT
Dialog WM_IME_NOTIFY
Dialog WM_SETFOCUS
Edit   WM_GETDLGCODE
Edit   EM_SETSEL wParam: 0 lParam: 2147483647
Dialog WM_KILLFOCUS
Dialog WM_IME_SETCONTEXT
Edit   WM_IME_SETCONTEXT
Edit   WM_SETFOCUS
Dialog DM_GETDEFID
Dialog WM_COMMAND
Dialog WM_WINDOWPOSCHANGING
Dialog WM_NCPAINT
Dialog WM_ERASEBKGND
Dialog WM_WINDOWPOSCHANGED
Dialog WM_NCCALCSIZE
Dialog WM_NCPAINT
Dialog WM_ERASEBKGND
Dialog WM_NCPAINT
Dialog WM_ERASEBKGND

Note: 2147483647 is 0x7FFFFFFF.  This causes the edit control's entire text 
to be selected.
date: Fri, 5 Sep 2008 18:06:51 -0400   author:   David Liebtag

Re: ShowWindow sends EM_SETSEL   
>If the dialog has an owner, the edit control receives an EM_SETSEL message 
>during the call to ShowWindow.

... and if it doesn't have an owner?

>Does anyone know why the edit control receives an EM_SETSEL?

Is the edit control the first (tab order) control on the dialog? i.e.
is it the expected normal behaviour that you'd get for any edit
control that's on a dialog box and is getting the focus?

Dave
date: Sat, 06 Sep 2008 00:47:37 +0100   author:   David Lowndes lid

Re: ShowWindow sends EM_SETSEL   
If it doesn't have an owner, it does not receive an EM_SETSEL.

It does not happen if the edit control is not the first visible enabled 
control that accepts input.

But, default behavior is for the first control get get focus.  Does the 
first control's selection gets changed too?  Is that behavior documented 
somewhere?

Why would the behavior depend on whether the dialog has an owner?

David
date: Fri, 5 Sep 2008 20:51:30 -0400   author:   David Liebtag

Re: ShowWindow sends EM_SETSEL   
>But, default behavior is for the first control get get focus.  Does the 
>first control's selection gets changed too?

Yes, default behaviour for Windows SDK applications is to select the
whole contents. VB(6) applications have always differed from the norm.

>Is that behavior documented somewhere?

It's mentioned in the WM_NEXTDLGCTL message documentation:

"This message performs additional dialog box management operations
beyond those performed by the SetFocus function WM_NEXTDLGCTL updates
the default pushbutton border, sets the default control identifier,
and automatically selects the text of an edit control (if the target
window is an edit control)."

>Why would the behavior depend on whether the dialog has an owner?

I don't know, that's what surprised me when you mentioned it, which is
why I asked to check it was relevant.

Dave
date: Sat, 06 Sep 2008 08:44:44 +0100   author:   David Lowndes lid

Re: ShowWindow sends EM_SETSEL   
Huh.

I knew that WM_NEXTDLGCTL updates button borders, but I never noticed that 
it also selects the text of edit controls.

Thanks.

David Liebtag
date: Sat, 6 Sep 2008 09:01:25 -0400   author:   David Liebtag

Re: ShowWindow sends EM_SETSEL   
I just realized,,, the dialog does not receive WM_NEXTDLGCTL.

David Liebtag
date: Sat, 6 Sep 2008 09:45:46 -0400   author:   David Liebtag

Re: ShowWindow sends EM_SETSEL   
You can make it so the edit box doesn't get selected when it gets focus 
if you subclass it and make it to not return DLGC_HASSETSEL on 
WM_GETDLGCODE.

Ivo

David Liebtag wrote:
> I just realized,,, the dialog does not receive WM_NEXTDLGCTL.
> 
> David Liebtag 
> 
>
date: Sat, 06 Sep 2008 08:20:02 -0700   author:   Ivo Beltchev

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us