Why can't I create my dialog box? Rookie mistake #2

Raymond Chen

Raymond

Another class of rookie mistake is less obvious from looking at the code.

#define DLG_SAMPLE 1
DLG_SAMPLE DIALOGEX 32, 32, 210, 200
...
BEGIN
 ...
 CONTROL "",IDC_LISTVIEW,WC_LISTVIEW,LVS_REPORT |
         WS_TABSTOP | WS_BORDER,
         14,92,182, 80
 ...
END
DialogBox(hinst, MAKEINTRESOURCE(DLG_SAMPLE),
          hwnd, SampleDlgProc);

The problem with this code is that we forgot to call InitCommonControlsEx to register the listview class. More generally, the problem is that one of the controls on the dialog uses a window class that was not registered. (For example, maybe there’s a rich edit control on the dialog, but nobody remembered to load the rich edit library.)

Next time, a sophomore version of this mistake.

0 comments

Comments are closed. Login to edit/delete your existing comments