Release 0.2.0
[wine/multimedia.git] / widgets.c
blobf80a23ea12c6e7346663da8dadbb87a0341dbb9e
1 /*
2 * Windows widgets (built-in window classes)
4 * Copyright 1993 Alexandre Julliard
5 */
7 static char Copyright[] = "Copyright Alexandre Julliard, 1993";
9 #include "windows.h"
12 static LONG WIDGETS_ButtonWndProc( HWND hwnd, WORD message,
13 WORD wParam, LONG lParam );
14 static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message,
15 WORD wParam, LONG lParam );
17 #define NB_BUILTIN_CLASSES 2
19 static WNDCLASS WIDGETS_BuiltinClasses[NB_BUILTIN_CLASSES] =
21 { 0, WIDGETS_ButtonWndProc, 0, 0, 0, 0, 0, 0, NULL, "BUTTON" },
22 { 0, WIDGETS_StaticWndProc, 0, 0, 0, 0, 0, 0, NULL, "STATIC" }
25 static FARPROC WndProc32[NB_BUILTIN_CLASSES];
28 /***********************************************************************
29 * WIDGETS_Init
31 * Initialize the built-in window classes.
33 BOOL WIDGETS_Init()
35 int i;
36 WNDCLASS * pClass = WIDGETS_BuiltinClasses;
38 for (i = 0; i < NB_BUILTIN_CLASSES; i++, pClass++)
40 WndProc32[i] = pClass->lpfnWndProc;
41 pClass->lpfnWndProc = (FARPROC) i+1;
42 if (!RegisterClass(pClass)) return FALSE;
44 return TRUE;
48 /**********************************************************************
49 * WIDGETS_Call32WndProc
51 * Call the window procedure of a built-in class.
53 LONG WIDGETS_Call32WndProc( FARPROC func, HWND hwnd, WORD message,
54 WORD wParam, LONG lParam )
56 unsigned int i = (unsigned int) func;
57 if (!i || (i > NB_BUILTIN_CLASSES)) return 0;
58 return (*WndProc32[i-1])( hwnd, message, wParam, lParam );
62 /***********************************************************************
63 * WIDGETS_ButtonWndProc
65 static LONG WIDGETS_ButtonWndProc( HWND hwnd, WORD message,
66 WORD wParam, LONG lParam )
68 switch(message)
70 case WM_CREATE:
71 return 0;
73 case WM_PAINT:
75 HDC hdc;
76 PAINTSTRUCT ps;
77 RECT rect;
79 hdc = BeginPaint( hwnd, &ps );
80 GetClientRect( hwnd, &rect );
81 DrawText(hdc, "Button", -1, &rect,
82 DT_SINGLELINE | DT_CENTER | DT_VCENTER );
83 EndPaint( hwnd, &ps );
84 return 0;
87 default:
88 return DefWindowProc( hwnd, message, wParam, lParam );
93 /***********************************************************************
94 * WIDGETS_StaticWndProc
96 static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message,
97 WORD wParam, LONG lParam )
99 switch(message)
101 case WM_CREATE:
102 return 0;
104 case WM_PAINT:
106 HDC hdc;
107 PAINTSTRUCT ps;
108 RECT rect;
110 hdc = BeginPaint( hwnd, &ps );
111 GetClientRect( hwnd, &rect );
112 DrawText(hdc, "Static", -1, &rect,
113 DT_SINGLELINE | DT_CENTER | DT_VCENTER );
114 EndPaint( hwnd, &ps );
115 return 0;
118 default:
119 return DefWindowProc( hwnd, message, wParam, lParam );