Page 68 - DCAP408_WEB_PROGRAMMING
P. 68

Windows Programming




                    Notes          The simplest manner to create a combo box is via a resource script. The syntax utilized to create
                                   the control in a script is:
                                   COMBOBOX id, x, y, width, height [, style [, extended-style]]


                                       !
                                     Caution  You must state COMBOBOX as the class of this control.
                                   The id is the number used to recognize the control in a resource header file

                                   The x measure is its horizontal location with respect to the control’s origin, which is located in
                                   the top left corner of the window that is hosting the combo box
                                   The y factor is the distance from control’s origin, which is located in the top left corner of the
                                   window that is hosting the combo box, to the top-left side of the combo box
                                   The width and the height specify the dimensions of the combo box
                                   The optional style and the extended-style factors are used to configure and organize the behavior
                                   of the combo box.
                                   To create a combo box follow the steps as below:
                                   1.  To create an identifier for the combo box, open the resource header file and modify it as
                                       follows:
                                       #define IDD_CONTROLSDLG 101
                                       #define IDD_SIZE_CBO    102
                                   2.  To create the combo box, open the resource script and modify it as follows:

                                       #include “resource.h”


                                       IDD_CONTROLSDLG DIALOG 260, 200, 180, 120
                                       STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
                                       CAPTION “Windows Controls”
                                       FONT 8, “MS Shell Dlg”
                                       BEGIN
                                          DEFPUSHBUTTON   “Close”, IDCANCEL, 120, 100, 50, 14
                                          COMBOBOX        IDD_SIZE_CBO, 40, 8, 90, 80
                                           END
                                   3.  Test the application















                                   4.  Click Close to dismiss the dialog box.



          62                                LOVELY PROFESSIONAL UNIVERSITY
   63   64   65   66   67   68   69   70   71   72   73