Page 207 - DCAP408_WEB_PROGRAMMING
P. 207

Unit 12: Dialog Boxes (II)




          The Data Exchange and Validation Mechanism                                            Notes

          The DoDataExchange() function is called several times during the lifetime of a dialog box and
          performs a variety of tasks. When the dialog box is  initialized, this function subclasses any
          mapped controls through the DDX_Control routine (discussed in more detail later in the section,
          "Initializing the Dialog Box Controls"). Then it transfers the data held in the member variables
          to the controls using the DDX_ routines. Finally, after the user clicks OK, the  data from the
          controls is validated using DDV_ routines and then transferred back into the member variables
          using the DDX_ routines again.
          You'll notice that the DoDataExchange() function is passed a pointer to a CDataExchange object.
          This object holds the details that let the DDX routines know whether they should be transferring
          data to or from the controls. The DDX_ routines then implement the Windows message required
          to set or retrieve data from the control associated with the given control ID.

          When the m_bSaveAndValidate member is set to TRUE, the data exchange should transfer data
          from the controls to the member variables and perform validation. It is set to FALSE when data
          from the member variables should be loaded into the controls. You can add your own custom
          code  to  DoDataExchange()  to  transfer  data  to  or  from  the  controls  and  check  the
          m_bSaveAndValidatemember  of  the CDataExchange object to see whether  you should  be
          transferring the data to or from the control.

          12.4 Modal, Modeless and System Modal Dialog boxes

          Dialog boxes are specifically used for accepting input from the user or displaying a message to
          the user. Windows operating system comes with default dialog boxes like Font dialog box,
          Printer  dialog box, Color dialog box etc. Most of the applications specially those vendored by
          Microsoft borrow these dialog boxes from Windows whenever they need. There are three kinds
          of dialog boxes.

          1.   Modal Dialog Box (Application Modal Dialog Box)
          2.   Modeless Dialog Box
          3.   System Modal Dialog Box

          12.4.1 Modal Dialog Box

          Modal dialog boxes can  be also called as  Application Modal dialog box. These dialog boxes
          insist you to respond to them before continuing in the same application. A Modal dialog box
          while in action, stops running your code until it is closed or hidden. Although, you can call
          default Dialog box as a Modal dialog box, but you can also create of your own. The Show method
          of form uses VbModal style to load the form as a Modal dialog box. The general syntax you
          follow will be :FormName.Show VbModal

          12.4.2 Modeless Dialog Box

          Modeless dialog boxes do not need to be closed to loose their focus. They are just like any other
          form in your application and loose their focus as soon as you click some other Window outside
          the application.


                 Example: A Find and Replace dialog box, Document Windows in Word application are
          few examples of Modeless dialog boxes.





                                           LOVELY PROFESSIONAL UNIVERSITY                                   201
   202   203   204   205   206   207   208   209   210   211   212