[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

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)
0
redhat092798
Asked:
redhat092798
  • 2
1 Solution
 
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
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now