Previous: 6.2. Structure of Window Procedure To the Table of Contents Next: 6.4. Associating a Window Procedure with a Window Class
6.2. Structure of Window Procedure Table of Contents 6.4. Associating a Window Procedure with a Window Class

- 6.3. -
Table of Contents
6. Win32 Programming
6.3. Designing a Window Procedure


6.3. Designing a Window Procedure


The following example shows the structure of a typical window procedure. The window procedure uses the message argument in a Case statement to process. For messages that it does not process, the window procedure calls the DefWindowProc function in WIN32.HLP.
function MainWndProc conv arg_stdcall (
     _hwnd: HWND,        // handle of window
     _uMsg: UINT,        // message identifier
     _wParam: WPARAM,    // first message parameter
     _lParam: LPARAM     // second message parameter
     ): LRESULT;
begin
  case _uMsg of
     WM_CREATE:
       begin  // Initialize the window.
         Result := 0;
       end; 
 
     WM_PAINT: 
       begin  // Paint the window's client area.
         Result := 0;
       end; 
 
     WM_SIZE:
       begin  // Set the size and position of the window.
         Result := 0;
       end;
 
     WM_DESTROY:
       begin  // Clean up window-specific data objects.
         Result := 0;
       end;
     // Process other messages.
     else   
       Result := DefWindowProc(_hwnd, _uMsg, _wParam, _lParam);
     end;
end;



Previous: 6.2. Structure of Window Procedure To the Table of Contents Next: 6.4. Associating a Window Procedure with a Window Class
6.2. Structure of Window Procedure Table of Contents 6.4. Associating a Window Procedure with a Window Class

- 6.3. -