News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

edit control displays "selected"

Started by Mr Earl, March 09, 2005, 12:17:36 PM

Previous topic - Next topic

Mr Earl

What causes a multiline edit control to display as "selected" on it's initial display?
I fill the control with "SetWindowText" in the WM_INITDIALOG process.
Issuing a "EM_SETSEL" to de-select it does not work.  Only a click on the screen de-selects it.
I have used exactly the same style dialog in another application and the data did not display "selected"?


InvDisplayDialog DIALOG 0, 0, 329, 280
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_SETFONT
FONT  9, "Tahoma"
CAPTION "Details"

BEGIN
  GROUPBOX "",1000,                   4,  0, 320,259
  EDITTEXT IDC_DETAILS,              12, 10, 305,243, ES_WANTRETURN|ES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL
  PUSHBUTTON "Write Tag",IDC_WRITE,  99,262,  55, 14
  PUSHBUTTON "Exit",     IDC_EXIT,  174,262,  55, 14
  END


Tedd

Usually, you have to set the selection on WM_SETFOCUS to get that effect.
I don't know how it is done by default :eek
No snowflake in an avalanche feels responsible.

Mr Earl

I still don't know why the control displays "selected", but the only way I could get it to display normal was to add a DUMMY control


BEGIN
  GROUPBOX "",1000,                   4,  0, 320,259
  EDITTEXT IDC_DUMMY,                12, 10,   0,  0, ES_READONLY
  EDITTEXT IDC_DETAILS,              12, 10, 305,243, ES_WANTRETURN|ES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL
  PUSHBUTTON "Write Tag",IDC_WRITE,  99,262,  55, 14
  PUSHBUTTON "Exit",     IDC_EXIT,  174,262,  55, 14
END

Relvinian

Mr. Earl

If you have a single control on your dialog, by default it'll have the "focus" so you'll see the selected state when the dialog shows. If you don't want this to happen, what needs to happen is the follow:

1) On your WM_INITDIALOG handler, set the focus to the dialog if only a single control -- or another control you want.
2) return TRUE from this handler as to instruct Windows that you have set the focus to something else.

Hope this helps

Relvinian

Mr Earl

Thanks Relvinian, your suggestion worked.  I still wonder why my de-select didn't work.
Anything wrong with this:    INVOKE SendMessage,hDetails,EM_SETSEL,-1,0

Relvinian

Where were you doing the call at?  If it was in WM_INITDIALOG, I am assuming the DefWinProc was doing something to reset focus back to the control.

Relvinian

mariø

Changing the order (first the pushbutton, for example), should work I think 

BEGIN
  GROUPBOX "",1000,                   4,  0, 320,259
  PUSHBUTTON "Write Tag",IDC_WRITE,  99,262,  55, 14
  EDITTEXT IDC_DETAILS,              12, 10, 305,243, ES_WANTRETURN|ES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL
  PUSHBUTTON "Exit",     IDC_EXIT,  174,262,  55, 14
END