It looks like your main problem is this line of code:
Test_FORM_WndProc(Test_FORM,WM_CREATE,NULL,NULL);
This should simply not be there. When you call the window proc with WM_CREATE
, a second list view is created. Simply remove this line of code from your program.
Some other comments:
Your handling of WM_CLOSE
is odd. You don't need to handle that message since the default handler will call DestroyWindow
. And you should not call PostQuitMessage
from there. Instead call it from WM_DESTROY
. So, replace the WM_CLOSE
clause with this:
case WM_DESTROY:
PostQuitMessage(0);
return 0;
It's probably cleaner to zero-initialize a struct before populating the handful of members that need values. For example:
WNDCLASS ResClass = {0};
ResClass.hbrBackground = CreateSolidBrush(RGB(45,45,45));
ResClass.hCursor = LoadCursor(NULL,IDC_ARROW);
ResClass.lpfnWndProc = Test_FORM_WndProc;
ResClass.lpszClassName = "RES_CL";
You use this approach in the WM_CREATE
handler too, but the syntax above is perhaps a little more idiomatic than memset
.
Finally, I'd prefer to see your WM_CREATE
and WM_COMMAND
handlers use return
rather than letting DefWindowProc
be called.