Microsoft KB Archive/66995

PRWIN9012014: No Focus Rect on List Box at Dialog Creation ID Number: Q66995

3.00 WINDOWS buglist3.00 fixlist3.10

Summary:

PROBLEM ID: WIN9012014

SYMPTOMS Under Windows version 3.0, when a modal dialog box is created, if the initial focus is set to a list box, no focus rectangle is drawn.

RESOLUTION Microsoft has confirmed this to be a problem in Windows version 3.0. The steps below detail a method to avoid this problem. When the dialog box is created, the dialog box posts a user-defined message to itself. Processing this message sets the focus to the list box. The following code fragment from a dialog function demonstrates this procedure:

case WM_INITDIALOG: SendDlgItemMessage(hDlg, ID_LISTBOX, LB_ADDSTRING, 0, (LONG)(LPSTR)“Item 1”); SendDlgItemMessage(hDlg, ID_LISTBOX, LB_ADDSTRING, 0, (LONG)(LPSTR)“Item 2”); PostMessage(hDlg, WM_USER+1000, 0, 0L); return (FALSE);

case WM_USER+1000: SetFocus(GetDlgItem(hDlg, ID_LISTBOX)); break;

This problem was corrected in Windows version 3.1.

Additional reference words: 3.00 listbox