Page 77 - DCAP408_WEB_PROGRAMMING
P. 77

Unit 4: Windows Controls




          Automatically Handling Scroll Bars                                                    Notes

          1.   To create a small editor with its scroll bars, modify the procedure as follows:
               LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
                                          WPARAM wParam, LPARAM lParam)
               {
                   static HWND hWndEdit;


                   switch(Msg)

                   {
                   case WM_CREATE:


                       hWndEdit = CreateWindow(“EDIT”, // We are creating an Edit
                    control
                                               NULL,   // Leave the control empty
                                               WS_CHILD | WS_VISIBLE | WS_HSCROLL |

                                                   WS_VSCROLL | ES_LEFT |
                    ES_MULTILINE |
                                                   ES_AUTOHSCROLL | ES_AUTOVSCROLL,
                                               0, 0, 0, 0, // Let the WM_SIZE
                    message below take care of the size
                                               hWnd,

                                              0,
                                               hInst,
                                               NULL);


                       return 0;


                   case WM_SETFOCUS:
                       SetFocus(hWndEdit);
                       return 0;



                   case WM_SIZE:
                       MoveWindow(hWndEdit, 0, 0, LOWORD(lParam), HIWORD(lParam),
                    TRUE);
                       return 0;


                   case WM_DESTROY:
                       // If the user has finished, then close the window





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