Creating a list view in a dialog

I have tab controls on my window. The 3 tabs corresponnd to three dialog boxes  that I created with CreateDialog(). Up to this point is alright.
I want to create a list view control on my first dialog. The problem is that dialog box does not accept CreateWindow() I think. I can't even create a button on the dialog using CreateWindow(). Of course I can create a button on the .rc file. Anyway, I hope someone has a solution. Basically , this is what I did :-
//procedure for my first dialog
case WM_INITDIALOG:
              // create the list view child window
                hwndList = CreateWindowEx ( 0, WC_LISTVIEW, "listview"
                            , WS_VISIBLE | WS_CHILD | LVS_REPORT
                            , 0, 0, 0, 0
                            , hwnd
                            , (HMENU)IDW_LISTVIEW
                            , hInst
                            , NULL );
//I know how to create a list view but the problem here is I'm making it on a //dialog
//or  show me to create a button using CreateWindow()  would be good //enough ( on a dialog)
redhat092798Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
A dialog box is a window and the controls are created with CreateWindowEx internally.

You need to specify the width and height.

hwndList = CreateWindowEx ( 0, WC_LISTVIEW, "listview"
                            , WS_VISIBLE | WS_CHILD | LVS_REPORT
                            , 0, 0, 0, 0   // !!!
                            , hwnd
                            , (HMENU)IDW_LISTVIEW
                            , hInst
                            , NULL );
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
redhat092798Author Commented:
I did . Its not actually 0, 0 ,0 ,0. Anyway, to make simpler, lets us just create a button using CreateWindow() on a dialog that was created with CreateDialog .
0
chensuCommented:
What is the return value of CreateWindowEx? If it is NULL, call GetLastError. And try it with WM_CREATE instead of WM_INITDIALOG.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.