Page 76 - DCAP408_WEB_PROGRAMMING
P. 76

Windows Programming




                    Notes                  switch(Msg)
                                           {
                                           case WM_CREATE:
                                              // There is nothing significant to do at this time
                                               return 0;


                                           case WM_DESTROY:
                                               // If the user has finished, then close the window
                                               PostQuitMessage(WM_QUIT);

                                               break;
                                           default:
                                               // Process the left-over messages
                                               return DefWindowProc(hWnd, Msg, wParam, lParam);
                                           }
                                           // If something was not done, let it go
                                           return 0;
                                       }
                                   11.  Press F9 to test the application





                                      Task  Make distinction between vertical scroll bar and horizontal scroll bar.

                                   4.8.2 Automatic Scroll Bars

                                   Some controls require a scroll bar  to competently  implement their  functionality. The  main
                                   example is the edit control, which is used to exhibit text. On that control, when the text is too
                                   long, the user is required to be able to scroll down and up to access the document fully. In the
                                   similar manner, if the text is too wide, the user is required to be able to scroll left and right to
                                   view the whole document.
                                   When creating a text-based document or window, you can simply ask that one or both scroll
                                   bars be added. Certainly, an edit control must be able to handle multiple lines of text. This is
                                   taken care of by adding the ES_MULTILINE flag to its styles. Then:

                                      To add a vertical scroll bar to the window, add the WS_VSCROLL flag to the Style argument
                                       of the CreateWindow() or the CreateWindowEx() function.

                                      To add a horizontal scroll bar to the window, add the  WS_HSCROLL flag to the Style
                                       argument of the CreateWindow() or the CreateWindowEx() function.
                                      To make the vertical scroll bar appear when necessary, that is, when the document is too
                                       long, add the ES_AUTOVSCROLL style.

                                      To make the horizontal scroll bar appear as soon as at least one line of the document is too
                                       wide, add the ES_AUTOVSCROLL style.
                                   Obviously, you can use only one, two, three or all four styles.




          70                                LOVELY PROFESSIONAL UNIVERSITY
   71   72   73   74   75   76   77   78   79   80   81