| 1 | /* $Id: static.cpp,v 1.25 2001-11-07 19:19:09 sandervl Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Static control | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 1999 Christoph Bratschi | 
|---|
| 6 | * | 
|---|
| 7 | * Copyright  David W. Metcalfe, 1993 | 
|---|
| 8 | * | 
|---|
| 9 | * Corel version: 20000317 | 
|---|
| 10 | * (WINE version: 990923) | 
|---|
| 11 | * | 
|---|
| 12 | * SvL: | 
|---|
| 13 | * SS_REALSIZEIMAGE is supposed to prevent control resizing, but that doesn't | 
|---|
| 14 | * appear to happen in NT (although the SDK docs are very clear about this) | 
|---|
| 15 | * Need to figure out why. (not resizing messes up the bitmap control in | 
|---|
| 16 | * the Microsoft Visual C++ 4.2 install program) | 
|---|
| 17 | * Same thing happens with a very simply test app, so the installer | 
|---|
| 18 | * does nothing special. | 
|---|
| 19 | * | 
|---|
| 20 | * | 
|---|
| 21 | * Status:  complete | 
|---|
| 22 | * Version: 5.00 | 
|---|
| 23 | */ | 
|---|
| 24 |  | 
|---|
| 25 | #include <stdlib.h> | 
|---|
| 26 | #include <string.h> | 
|---|
| 27 | #include <os2win.h> | 
|---|
| 28 | #include "controls.h" | 
|---|
| 29 | #include "static.h" | 
|---|
| 30 |  | 
|---|
| 31 | #define DBG_LOCALLOG    DBG_static | 
|---|
| 32 | #include "dbglocal.h" | 
|---|
| 33 |  | 
|---|
| 34 | //Prototypes | 
|---|
| 35 |  | 
|---|
| 36 | static void STATIC_PaintTextfn( HWND hwnd, HDC hdc ); | 
|---|
| 37 | static void STATIC_PaintRectfn( HWND hwnd, HDC hdc ); | 
|---|
| 38 | static void STATIC_PaintIconfn( HWND hwnd, HDC hdc ); | 
|---|
| 39 | static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc ); | 
|---|
| 40 | static void STATIC_PaintMetafilefn(HWND hwnd,HDC hdc); | 
|---|
| 41 | static void STATIC_PaintOwnerDrawfn(HWND hwnd,HDC hdc); | 
|---|
| 42 | static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc ); | 
|---|
| 43 |  | 
|---|
| 44 | static COLORREF color_windowframe, color_background, color_window; | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 | typedef void (*pfPaint)( HWND, HDC ); | 
|---|
| 48 |  | 
|---|
| 49 | static pfPaint staticPaintFunc[SS_TYPEMASK+1] = | 
|---|
| 50 | { | 
|---|
| 51 | STATIC_PaintTextfn,      /* SS_LEFT */ | 
|---|
| 52 | STATIC_PaintTextfn,      /* SS_CENTER */ | 
|---|
| 53 | STATIC_PaintTextfn,      /* SS_RIGHT */ | 
|---|
| 54 | STATIC_PaintIconfn,      /* SS_ICON */ | 
|---|
| 55 | STATIC_PaintRectfn,      /* SS_BLACKRECT */ | 
|---|
| 56 | STATIC_PaintRectfn,      /* SS_GRAYRECT */ | 
|---|
| 57 | STATIC_PaintRectfn,      /* SS_WHITERECT */ | 
|---|
| 58 | STATIC_PaintRectfn,      /* SS_BLACKFRAME */ | 
|---|
| 59 | STATIC_PaintRectfn,      /* SS_GRAYFRAME */ | 
|---|
| 60 | STATIC_PaintRectfn,      /* SS_WHITEFRAME */ | 
|---|
| 61 | NULL,                    /* SS_USERITEM */ | 
|---|
| 62 | STATIC_PaintTextfn,      /* SS_SIMPLE */ | 
|---|
| 63 | STATIC_PaintTextfn,      /* SS_LEFTNOWORDWRAP */ | 
|---|
| 64 | STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */ | 
|---|
| 65 | STATIC_PaintBitmapfn,    /* SS_BITMAP */ | 
|---|
| 66 | STATIC_PaintMetafilefn,  /* SS_ENHMETAFILE */ | 
|---|
| 67 | STATIC_PaintEtchedfn,    /* SS_ETCHEDHORIZ */ | 
|---|
| 68 | STATIC_PaintEtchedfn,    /* SS_ETCHEDVERT */ | 
|---|
| 69 | STATIC_PaintEtchedfn,    /* SS_ETCHEDFRAME */ | 
|---|
| 70 | }; | 
|---|
| 71 |  | 
|---|
| 72 | static void STATIC_ResizeWindow(HWND hwnd,DWORD dwStyle,INT w,INT h) | 
|---|
| 73 | { | 
|---|
| 74 | if (dwStyle & SS_RIGHTJUST) | 
|---|
| 75 | { | 
|---|
| 76 | RECT rect; | 
|---|
| 77 |  | 
|---|
| 78 | GetWindowRect(hwnd,&rect); | 
|---|
| 79 | SetWindowPos(hwnd,0,rect.right-w,rect.bottom-h,w,h,SWP_NOACTIVATE | SWP_NOZORDER); | 
|---|
| 80 | } else SetWindowPos(hwnd,0,0,0,w,h,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | /*********************************************************************** | 
|---|
| 84 | *           STATIC_SetIcon | 
|---|
| 85 | * | 
|---|
| 86 | * Set the icon for an SS_ICON control. | 
|---|
| 87 | */ | 
|---|
| 88 | static HICON STATIC_SetIcon( HWND hwnd, HICON hicon ) | 
|---|
| 89 | { | 
|---|
| 90 | HICON prevIcon; | 
|---|
| 91 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); | 
|---|
| 92 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 93 | ICONINFO ii; | 
|---|
| 94 | BITMAP bmp; | 
|---|
| 95 |  | 
|---|
| 96 | if (infoPtr == NULL) | 
|---|
| 97 | return 0; | 
|---|
| 98 |  | 
|---|
| 99 | if ((dwStyle & SS_TYPEMASK) != SS_ICON) return 0; | 
|---|
| 100 |  | 
|---|
| 101 | if (infoPtr->hIcon) DestroyIcon(infoPtr->hIcon); | 
|---|
| 102 | prevIcon = infoPtr->hIcon; | 
|---|
| 103 | infoPtr->hIcon = hicon; | 
|---|
| 104 |  | 
|---|
| 105 | if (!GetIconInfo(hicon,&ii)) return prevIcon; | 
|---|
| 106 | if (ii.hbmColor) | 
|---|
| 107 | GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp); | 
|---|
| 108 | else | 
|---|
| 109 | { | 
|---|
| 110 | GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp); | 
|---|
| 111 | bmp.bmHeight /= 2; | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | #if 1 | 
|---|
| 115 | //SvL: Breaks MS Visual C++ install dialogs with static controls (no resize) | 
|---|
| 116 | if (!(dwStyle & (SS_CENTERIMAGE))) STATIC_ResizeWindow(hwnd,dwStyle,bmp.bmWidth,bmp.bmHeight); | 
|---|
| 117 | #else | 
|---|
| 118 | if (!(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE))) STATIC_ResizeWindow(hwnd,dwStyle,bmp.bmWidth,bmp.bmHeight); | 
|---|
| 119 | #endif | 
|---|
| 120 |  | 
|---|
| 121 | if (ii.hbmColor) DeleteObject(ii.hbmColor); | 
|---|
| 122 | if (ii.hbmMask) DeleteObject(ii.hbmMask); | 
|---|
| 123 |  | 
|---|
| 124 | return prevIcon; | 
|---|
| 125 | } | 
|---|
| 126 |  | 
|---|
| 127 | /*********************************************************************** | 
|---|
| 128 | *           STATIC_SetBitmap | 
|---|
| 129 | * | 
|---|
| 130 | * Set the bitmap for an SS_BITMAP control. | 
|---|
| 131 | */ | 
|---|
| 132 | static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap ) | 
|---|
| 133 | { | 
|---|
| 134 | HBITMAP hOldBitmap; | 
|---|
| 135 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); | 
|---|
| 136 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 137 |  | 
|---|
| 138 | if (infoPtr == NULL) | 
|---|
| 139 | return 0; | 
|---|
| 140 |  | 
|---|
| 141 | if ((dwStyle & SS_TYPEMASK) != SS_BITMAP) return 0; | 
|---|
| 142 |  | 
|---|
| 143 | if (hBitmap && (GetObjectType(hBitmap) != OBJ_BITMAP)) { | 
|---|
| 144 | //ERR("huh? hBitmap!=0, but not bitmap\n"); | 
|---|
| 145 | return 0; | 
|---|
| 146 | } | 
|---|
| 147 | hOldBitmap = infoPtr->hIcon; | 
|---|
| 148 | infoPtr->hIcon = hBitmap; | 
|---|
| 149 | #if 1 | 
|---|
| 150 | //SvL: Breaks MS Visual C++ install dialogs with static controls (no resize) | 
|---|
| 151 | if (hBitmap && !(dwStyle & (SS_CENTERIMAGE))) | 
|---|
| 152 | #else | 
|---|
| 153 | if (hBitmap && !(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE))) | 
|---|
| 154 | #endif | 
|---|
| 155 | { | 
|---|
| 156 | BITMAP bm; | 
|---|
| 157 |  | 
|---|
| 158 | GetObjectA(hBitmap,sizeof(bm),&bm); | 
|---|
| 159 | STATIC_ResizeWindow(hwnd,dwStyle,bm.bmWidth,bm.bmHeight); | 
|---|
| 160 | } | 
|---|
| 161 |  | 
|---|
| 162 | return hOldBitmap; | 
|---|
| 163 | } | 
|---|
| 164 |  | 
|---|
| 165 | static HENHMETAFILE STATIC_SetMetafile(HWND hwnd,HENHMETAFILE hMetafile) | 
|---|
| 166 | { | 
|---|
| 167 | HENHMETAFILE hOldMetafile; | 
|---|
| 168 |  | 
|---|
| 169 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); | 
|---|
| 170 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 171 |  | 
|---|
| 172 | if ((dwStyle & SS_TYPEMASK) != SS_ENHMETAFILE) return 0; | 
|---|
| 173 |  | 
|---|
| 174 | hOldMetafile = infoPtr->hIcon; | 
|---|
| 175 | infoPtr->hIcon = hMetafile; | 
|---|
| 176 |  | 
|---|
| 177 | return hOldMetafile; | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | /*********************************************************************** | 
|---|
| 181 | *           STATIC_LoadIcon | 
|---|
| 182 | * | 
|---|
| 183 | * Load the icon for an SS_ICON control. | 
|---|
| 184 | */ | 
|---|
| 185 | static HICON STATIC_LoadIcon( HWND hwnd, LPCSTR name ) | 
|---|
| 186 | { | 
|---|
| 187 | HICON hicon; | 
|---|
| 188 |  | 
|---|
| 189 | hicon = LoadIconA(GetWindowLongA(hwnd,GWL_HINSTANCE),name); | 
|---|
| 190 |  | 
|---|
| 191 | if (!hicon) | 
|---|
| 192 | hicon = LoadIconA(0, name); | 
|---|
| 193 |  | 
|---|
| 194 | return hicon; | 
|---|
| 195 | } | 
|---|
| 196 |  | 
|---|
| 197 | /*********************************************************************** | 
|---|
| 198 | *           STATIC_LoadBitmap | 
|---|
| 199 | * | 
|---|
| 200 | * Load the bitmap for an SS_BITMAP control. | 
|---|
| 201 | */ | 
|---|
| 202 | static HBITMAP STATIC_LoadBitmap( HWND hwnd, LPCSTR name ) | 
|---|
| 203 | { | 
|---|
| 204 | HBITMAP hbitmap; | 
|---|
| 205 |  | 
|---|
| 206 | hbitmap = LoadBitmapA(GetWindowLongA(hwnd,GWL_HINSTANCE),name); | 
|---|
| 207 |  | 
|---|
| 208 | if (!hbitmap)  /* Try OEM icon (FIXME: is this right?) */ | 
|---|
| 209 | hbitmap = LoadBitmapA(0,name); | 
|---|
| 210 |  | 
|---|
| 211 | return hbitmap; | 
|---|
| 212 | } | 
|---|
| 213 |  | 
|---|
| 214 | static HBITMAP STATIC_LoadMetafile(HWND hwnd,LPCSTR name) | 
|---|
| 215 | { | 
|---|
| 216 | HENHMETAFILE hMetafile; | 
|---|
| 217 |  | 
|---|
| 218 | hMetafile = GetEnhMetaFileA(name); //CB: right? | 
|---|
| 219 |  | 
|---|
| 220 | return hMetafile; | 
|---|
| 221 | } | 
|---|
| 222 |  | 
|---|
| 223 | /* message handler */ | 
|---|
| 224 |  | 
|---|
| 225 | LRESULT STATIC_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 226 | { | 
|---|
| 227 | CREATESTRUCTA *cs = (CREATESTRUCTA*)lParam; | 
|---|
| 228 | STATICINFO* infoPtr; | 
|---|
| 229 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 230 | DWORD style = dwStyle & SS_TYPEMASK; | 
|---|
| 231 | DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE); | 
|---|
| 232 |  | 
|---|
| 233 | infoPtr = (STATICINFO*)malloc(sizeof(STATICINFO)); | 
|---|
| 234 | infoPtr->hFont = 0; | 
|---|
| 235 | infoPtr->dummy = 0; | 
|---|
| 236 | infoPtr->hIcon = 0; | 
|---|
| 237 | SetInfoPtr(hwnd,(DWORD)infoPtr); | 
|---|
| 238 |  | 
|---|
| 239 | if (dwStyle & SS_SUNKEN) | 
|---|
| 240 | { | 
|---|
| 241 | dwExStyle |= WS_EX_STATICEDGE; | 
|---|
| 242 | SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle); | 
|---|
| 243 | } | 
|---|
| 244 |  | 
|---|
| 245 | if (style == SS_ICON) | 
|---|
| 246 | { | 
|---|
| 247 | if (cs->lpszName) //CB: is 0 a valid icon id? winhlp32: lpszName = NULL | 
|---|
| 248 | { | 
|---|
| 249 | if (!HIWORD(cs->lpszName) || cs->lpszName[0]) | 
|---|
| 250 | STATIC_SetIcon(hwnd,STATIC_LoadIcon(hwnd,cs->lpszName)); | 
|---|
| 251 | } | 
|---|
| 252 | return TRUE; | 
|---|
| 253 | } | 
|---|
| 254 | if (style == SS_BITMAP) | 
|---|
| 255 | { | 
|---|
| 256 | if (cs->lpszName) | 
|---|
| 257 | STATIC_SetBitmap(hwnd,STATIC_LoadBitmap(hwnd,cs->lpszName)); | 
|---|
| 258 | return TRUE; | 
|---|
| 259 | } | 
|---|
| 260 | if (style == SS_ENHMETAFILE) | 
|---|
| 261 | { | 
|---|
| 262 | if (cs->lpszName) STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,cs->lpszName)); | 
|---|
| 263 | return TRUE; | 
|---|
| 264 | } | 
|---|
| 265 | if (!HIWORD(cs->lpszName) && (cs->lpszName)) return TRUE; | 
|---|
| 266 |  | 
|---|
| 267 | return DefWindowProcA(hwnd,WM_NCCREATE,wParam,lParam); | 
|---|
| 268 | } | 
|---|
| 269 |  | 
|---|
| 270 | LRESULT STATIC_Create(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 271 | { | 
|---|
| 272 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 273 |  | 
|---|
| 274 | if ((style < 0L) || (style > SS_TYPEMASK)) | 
|---|
| 275 | { | 
|---|
| 276 | //Unknown style | 
|---|
| 277 | return (LRESULT)-1; | 
|---|
| 278 | } | 
|---|
| 279 |  | 
|---|
| 280 | /* initialise colours */ | 
|---|
| 281 | color_windowframe  = GetSysColor(COLOR_WINDOWFRAME); | 
|---|
| 282 | color_background   = GetSysColor(COLOR_BACKGROUND); | 
|---|
| 283 | color_window       = GetSysColor(COLOR_WINDOW); | 
|---|
| 284 |  | 
|---|
| 285 | return 0; | 
|---|
| 286 | } | 
|---|
| 287 |  | 
|---|
| 288 | LRESULT STATIC_NCDestroy(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 289 | { | 
|---|
| 290 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd); | 
|---|
| 291 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 292 |  | 
|---|
| 293 | if ((style == SS_ICON) && infoPtr->hIcon) | 
|---|
| 294 | { | 
|---|
| 295 | DestroyIcon(infoPtr->hIcon); | 
|---|
| 296 | } else if ((style == SS_BITMAP) && infoPtr->hIcon) | 
|---|
| 297 | { | 
|---|
| 298 | DeleteObject(infoPtr->hIcon); | 
|---|
| 299 | } else if ((style == SS_ENHMETAFILE) && infoPtr->hIcon) | 
|---|
| 300 | { | 
|---|
| 301 | DeleteEnhMetaFile((HENHMETAFILE)infoPtr->hIcon); | 
|---|
| 302 | } | 
|---|
| 303 |  | 
|---|
| 304 | free(infoPtr); | 
|---|
| 305 |  | 
|---|
| 306 | return DefWindowProcA(hwnd,WM_NCDESTROY,wParam,lParam); | 
|---|
| 307 | } | 
|---|
| 308 |  | 
|---|
| 309 | LRESULT STATIC_Paint(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 310 | { | 
|---|
| 311 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 312 | PAINTSTRUCT ps; | 
|---|
| 313 |  | 
|---|
| 314 | BeginPaint(hwnd,&ps); | 
|---|
| 315 | if (staticPaintFunc[style]) (staticPaintFunc[style])(hwnd,ps.hdc); | 
|---|
| 316 | EndPaint(hwnd,&ps); | 
|---|
| 317 |  | 
|---|
| 318 | return 0; | 
|---|
| 319 | } | 
|---|
| 320 |  | 
|---|
| 321 | LRESULT STATIC_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 322 | { | 
|---|
| 323 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 324 |  | 
|---|
| 325 | if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),wParam ? STN_ENABLE:STN_DISABLE),hwnd); | 
|---|
| 326 |  | 
|---|
| 327 | InvalidateRect(hwnd,NULL,FALSE); | 
|---|
| 328 |  | 
|---|
| 329 | return 0; | 
|---|
| 330 | } | 
|---|
| 331 |  | 
|---|
| 332 | LRESULT STATIC_SysColorChange(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 333 | { | 
|---|
| 334 | color_windowframe  = GetSysColor(COLOR_WINDOWFRAME); | 
|---|
| 335 | color_background   = GetSysColor(COLOR_BACKGROUND); | 
|---|
| 336 | color_window       = GetSysColor(COLOR_WINDOW); | 
|---|
| 337 |  | 
|---|
| 338 | InvalidateRect(hwnd,NULL,TRUE); | 
|---|
| 339 |  | 
|---|
| 340 | return 0; | 
|---|
| 341 | } | 
|---|
| 342 |  | 
|---|
| 343 | LRESULT STATIC_SetText(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 344 | { | 
|---|
| 345 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 346 |  | 
|---|
| 347 | if (style == SS_ICON) | 
|---|
| 348 | STATIC_SetIcon(hwnd,STATIC_LoadIcon(hwnd,(LPCSTR)lParam)); | 
|---|
| 349 | else if (style == SS_BITMAP) | 
|---|
| 350 | STATIC_SetBitmap(hwnd,STATIC_LoadBitmap(hwnd,(LPCSTR)lParam)); | 
|---|
| 351 | else if (style == SS_ENHMETAFILE) | 
|---|
| 352 | STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,(LPCSTR)lParam)); | 
|---|
| 353 | else | 
|---|
| 354 | DefWindowProcA(hwnd,WM_SETTEXT,wParam,lParam); | 
|---|
| 355 |  | 
|---|
| 356 | InvalidateRect(hwnd,NULL,FALSE); | 
|---|
| 357 |  | 
|---|
| 358 | return TRUE; | 
|---|
| 359 | } | 
|---|
| 360 |  | 
|---|
| 361 | LRESULT STATIC_GetText(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 362 | { | 
|---|
| 363 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 364 |  | 
|---|
| 365 | if (style == SS_ICON) | 
|---|
| 366 | { | 
|---|
| 367 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd); | 
|---|
| 368 |  | 
|---|
| 369 | if ((wParam < 4) || !lParam) return 0; | 
|---|
| 370 | memcpy((VOID*)lParam,&infoPtr->hIcon,4); | 
|---|
| 371 |  | 
|---|
| 372 | return 4; | 
|---|
| 373 | } else return DefWindowProcA(hwnd,WM_GETTEXT,wParam,lParam); | 
|---|
| 374 | } | 
|---|
| 375 |  | 
|---|
| 376 | LRESULT STATIC_GetTextLength(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 377 | { | 
|---|
| 378 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 379 |  | 
|---|
| 380 | if (style == SS_ICON) return 4; | 
|---|
| 381 | else return DefWindowProcA(hwnd,WM_GETTEXTLENGTH,wParam,lParam); | 
|---|
| 382 | } | 
|---|
| 383 |  | 
|---|
| 384 | LRESULT STATIC_SetFont(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 385 | { | 
|---|
| 386 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd); | 
|---|
| 387 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 388 |  | 
|---|
| 389 | if (style == SS_ICON) return 0; | 
|---|
| 390 | if (style == SS_BITMAP) return 0; | 
|---|
| 391 | if (style == SS_ENHMETAFILE) return 0; | 
|---|
| 392 |  | 
|---|
| 393 | infoPtr->hFont = (HFONT)wParam; | 
|---|
| 394 |  | 
|---|
| 395 | if (LOWORD(lParam)) | 
|---|
| 396 | { | 
|---|
| 397 | InvalidateRect(hwnd,NULL,FALSE); | 
|---|
| 398 | UpdateWindow(hwnd); | 
|---|
| 399 | } | 
|---|
| 400 |  | 
|---|
| 401 | return 0; | 
|---|
| 402 | } | 
|---|
| 403 |  | 
|---|
| 404 | LRESULT STATIC_GetFont(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 405 | { | 
|---|
| 406 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd); | 
|---|
| 407 |  | 
|---|
| 408 | return infoPtr->hFont; | 
|---|
| 409 | } | 
|---|
| 410 |  | 
|---|
| 411 | LRESULT STATIC_NCHitTest(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 412 | { | 
|---|
| 413 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 414 | LRESULT lResult; | 
|---|
| 415 |  | 
|---|
| 416 | if (dwStyle & SS_NOTIFY) | 
|---|
| 417 | lResult = HTCLIENT; | 
|---|
| 418 | else lResult = HTTRANSPARENT; | 
|---|
| 419 |  | 
|---|
| 420 | return lResult; | 
|---|
| 421 | } | 
|---|
| 422 |  | 
|---|
| 423 | LRESULT STATIC_GetDlgCode(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 424 | { | 
|---|
| 425 | return DLGC_STATIC; | 
|---|
| 426 | } | 
|---|
| 427 |  | 
|---|
| 428 | LRESULT STATIC_GetIcon(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 429 | { | 
|---|
| 430 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd); | 
|---|
| 431 |  | 
|---|
| 432 | return infoPtr->hIcon; | 
|---|
| 433 | } | 
|---|
| 434 |  | 
|---|
| 435 | LRESULT STATIC_GetImage(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 436 | { | 
|---|
| 437 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd); | 
|---|
| 438 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK; | 
|---|
| 439 |  | 
|---|
| 440 | switch (wParam) | 
|---|
| 441 | { | 
|---|
| 442 | case IMAGE_BITMAP: | 
|---|
| 443 | if (style & SS_BITMAP) return infoPtr->hIcon; | 
|---|
| 444 | break; | 
|---|
| 445 |  | 
|---|
| 446 | case IMAGE_CURSOR: | 
|---|
| 447 | case IMAGE_ICON: | 
|---|
| 448 | if (style & SS_ICON) return infoPtr->hIcon; | 
|---|
| 449 | break; | 
|---|
| 450 |  | 
|---|
| 451 | case IMAGE_ENHMETAFILE: | 
|---|
| 452 | if (style & SS_ENHMETAFILE) return infoPtr->hIcon; | 
|---|
| 453 | break; | 
|---|
| 454 |  | 
|---|
| 455 | default: | 
|---|
| 456 | break; | 
|---|
| 457 | } | 
|---|
| 458 |  | 
|---|
| 459 | return 0; | 
|---|
| 460 | } | 
|---|
| 461 |  | 
|---|
| 462 | LRESULT STATIC_SetImage(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 463 | { | 
|---|
| 464 | LRESULT lResult = 0; | 
|---|
| 465 |  | 
|---|
| 466 | switch (wParam) | 
|---|
| 467 | { | 
|---|
| 468 | case IMAGE_CURSOR: | 
|---|
| 469 | case IMAGE_ICON: | 
|---|
| 470 | lResult = STATIC_SetIcon(hwnd,(HICON)lParam); | 
|---|
| 471 | break; | 
|---|
| 472 |  | 
|---|
| 473 | case IMAGE_BITMAP: | 
|---|
| 474 | lResult = STATIC_SetBitmap(hwnd,(HBITMAP)lParam); | 
|---|
| 475 | break; | 
|---|
| 476 |  | 
|---|
| 477 | case IMAGE_ENHMETAFILE: | 
|---|
| 478 | lResult = STATIC_SetMetafile(hwnd,(HENHMETAFILE)lParam); | 
|---|
| 479 | break; | 
|---|
| 480 |  | 
|---|
| 481 | default: | 
|---|
| 482 | return 0; | 
|---|
| 483 | } | 
|---|
| 484 |  | 
|---|
| 485 | if (lResult) InvalidateRect(hwnd,NULL,FALSE); | 
|---|
| 486 |  | 
|---|
| 487 | return lResult; | 
|---|
| 488 | } | 
|---|
| 489 |  | 
|---|
| 490 | LRESULT STATIC_SetIconMsg(HWND hwnd,WPARAM wParam,LPARAM lParam) | 
|---|
| 491 | { | 
|---|
| 492 | LRESULT lResult; | 
|---|
| 493 |  | 
|---|
| 494 | lResult = STATIC_SetIcon(hwnd,(HICON)wParam); | 
|---|
| 495 |  | 
|---|
| 496 | InvalidateRect(hwnd,NULL,FALSE); | 
|---|
| 497 |  | 
|---|
| 498 | return lResult; | 
|---|
| 499 | } | 
|---|
| 500 |  | 
|---|
| 501 | LRESULT STATIC_Click(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) | 
|---|
| 502 | { | 
|---|
| 503 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 504 |  | 
|---|
| 505 | if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),STN_CLICKED),hwnd); | 
|---|
| 506 |  | 
|---|
| 507 | return DefWindowProcA(hwnd,uMsg,wParam,lParam); | 
|---|
| 508 | } | 
|---|
| 509 |  | 
|---|
| 510 | LRESULT STATIC_DoubleClick(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) | 
|---|
| 511 | { | 
|---|
| 512 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 513 |  | 
|---|
| 514 | if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),STN_DBLCLK),hwnd); | 
|---|
| 515 |  | 
|---|
| 516 | return DefWindowProcA(hwnd,uMsg,wParam,lParam); | 
|---|
| 517 | } | 
|---|
| 518 |  | 
|---|
| 519 | /*********************************************************************** | 
|---|
| 520 | *           StaticWndProc | 
|---|
| 521 | */ | 
|---|
| 522 | LRESULT WINAPI StaticWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) | 
|---|
| 523 | { | 
|---|
| 524 | switch (uMsg) | 
|---|
| 525 | { | 
|---|
| 526 | case WM_NCCREATE: | 
|---|
| 527 | return STATIC_NCCreate(hwnd,wParam,lParam); | 
|---|
| 528 |  | 
|---|
| 529 | case WM_CREATE: | 
|---|
| 530 | return STATIC_Create(hwnd,wParam,lParam); | 
|---|
| 531 |  | 
|---|
| 532 | case WM_NCDESTROY: | 
|---|
| 533 | return STATIC_NCDestroy(hwnd,wParam,lParam); | 
|---|
| 534 |  | 
|---|
| 535 | case WM_PAINT: | 
|---|
| 536 | return STATIC_Paint(hwnd,wParam,lParam); | 
|---|
| 537 |  | 
|---|
| 538 | case WM_ENABLE: | 
|---|
| 539 | return STATIC_Enable(hwnd,wParam,lParam); | 
|---|
| 540 |  | 
|---|
| 541 | case WM_SYSCOLORCHANGE: | 
|---|
| 542 | return STATIC_SysColorChange(hwnd,wParam,lParam); | 
|---|
| 543 |  | 
|---|
| 544 | case WM_SETTEXT: | 
|---|
| 545 | return STATIC_SetText(hwnd,wParam,lParam); | 
|---|
| 546 |  | 
|---|
| 547 | case WM_GETTEXT: | 
|---|
| 548 | return STATIC_GetText(hwnd,wParam,lParam); | 
|---|
| 549 |  | 
|---|
| 550 | case WM_GETTEXTLENGTH: | 
|---|
| 551 | return STATIC_GetTextLength(hwnd,wParam,lParam); | 
|---|
| 552 |  | 
|---|
| 553 | case WM_SETFONT: | 
|---|
| 554 | return STATIC_SetFont(hwnd,wParam,lParam); | 
|---|
| 555 |  | 
|---|
| 556 | case WM_GETFONT: | 
|---|
| 557 | return STATIC_GetFont(hwnd,wParam,lParam); | 
|---|
| 558 |  | 
|---|
| 559 | case WM_NCHITTEST: | 
|---|
| 560 | return STATIC_NCHitTest(hwnd,wParam,lParam); | 
|---|
| 561 |  | 
|---|
| 562 | case WM_GETDLGCODE: | 
|---|
| 563 | return STATIC_GetDlgCode(hwnd,wParam,lParam); | 
|---|
| 564 |  | 
|---|
| 565 | case WM_LBUTTONDOWN: | 
|---|
| 566 | case WM_NCLBUTTONDOWN: | 
|---|
| 567 | return STATIC_Click(hwnd,uMsg,wParam,lParam); | 
|---|
| 568 |  | 
|---|
| 569 | case WM_LBUTTONDBLCLK: | 
|---|
| 570 | case WM_NCLBUTTONDBLCLK: | 
|---|
| 571 | return STATIC_DoubleClick(hwnd,uMsg,wParam,lParam); | 
|---|
| 572 |  | 
|---|
| 573 | case STM_GETIMAGE: | 
|---|
| 574 | return STATIC_GetImage(hwnd,wParam,lParam); | 
|---|
| 575 |  | 
|---|
| 576 | case STM_GETICON: | 
|---|
| 577 | return STATIC_GetIcon(hwnd,wParam,lParam); | 
|---|
| 578 |  | 
|---|
| 579 | case STM_SETIMAGE: | 
|---|
| 580 | return STATIC_SetImage(hwnd,wParam,lParam); | 
|---|
| 581 |  | 
|---|
| 582 | case STM_SETICON: | 
|---|
| 583 | return STATIC_SetIconMsg(hwnd,wParam,lParam); | 
|---|
| 584 |  | 
|---|
| 585 | case STM_MSGMAX: | 
|---|
| 586 | return 0; //CB: undocumented! | 
|---|
| 587 |  | 
|---|
| 588 | default: | 
|---|
| 589 | return DefWindowProcA(hwnd,uMsg,wParam,lParam); | 
|---|
| 590 | break; | 
|---|
| 591 | } | 
|---|
| 592 |  | 
|---|
| 593 | return DefWindowProcA(hwnd,uMsg,wParam,lParam); | 
|---|
| 594 | } | 
|---|
| 595 |  | 
|---|
| 596 |  | 
|---|
| 597 | static void STATIC_PaintTextfn(HWND hwnd, HDC hdc ) | 
|---|
| 598 | { | 
|---|
| 599 | RECT rc; | 
|---|
| 600 | HBRUSH hBrush; | 
|---|
| 601 | WORD wFormat; | 
|---|
| 602 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 603 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); | 
|---|
| 604 | INT textLen; | 
|---|
| 605 |  | 
|---|
| 606 | GetClientRect(hwnd,&rc); | 
|---|
| 607 |  | 
|---|
| 608 | switch (dwStyle & SS_TYPEMASK) | 
|---|
| 609 | { | 
|---|
| 610 | case SS_LEFT: | 
|---|
| 611 | wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; | 
|---|
| 612 | break; | 
|---|
| 613 |  | 
|---|
| 614 | case SS_CENTER: | 
|---|
| 615 | case SS_CENTERIMAGE: | 
|---|
| 616 | wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; | 
|---|
| 617 | break; | 
|---|
| 618 |  | 
|---|
| 619 | case SS_RIGHT: | 
|---|
| 620 | wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; | 
|---|
| 621 | break; | 
|---|
| 622 |  | 
|---|
| 623 | case SS_SIMPLE: | 
|---|
| 624 | wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP; | 
|---|
| 625 | break; | 
|---|
| 626 |  | 
|---|
| 627 | case SS_LEFTNOWORDWRAP: | 
|---|
| 628 | wFormat = DT_LEFT | DT_EXPANDTABS | DT_VCENTER; | 
|---|
| 629 | break; | 
|---|
| 630 |  | 
|---|
| 631 | default: | 
|---|
| 632 | return; | 
|---|
| 633 | } | 
|---|
| 634 |  | 
|---|
| 635 | if (dwStyle & SS_NOPREFIX) wFormat |= DT_NOPREFIX; | 
|---|
| 636 | if (dwStyle & SS_ENDELLIPSIS) wFormat |= DT_END_ELLIPSIS; | 
|---|
| 637 | if (dwStyle & SS_PATHELLIPSIS) wFormat |= DT_PATH_ELLIPSIS; | 
|---|
| 638 | if (dwStyle & SS_WORDELLIPSIS) wFormat |= DT_WORD_ELLIPSIS; | 
|---|
| 639 |  | 
|---|
| 640 | if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont ); | 
|---|
| 641 | //SvL: This is what the latest Wine code does. Fixes the common color dialog | 
|---|
| 642 | #if 1 | 
|---|
| 643 | if ((dwStyle & SS_NOPREFIX) || ((dwStyle & SS_TYPEMASK) != SS_SIMPLE)) | 
|---|
| 644 | { | 
|---|
| 645 | hBrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC, | 
|---|
| 646 | hdc, hwnd ); | 
|---|
| 647 | if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH); | 
|---|
| 648 | FillRect( hdc, &rc, hBrush ); | 
|---|
| 649 | } | 
|---|
| 650 | #else | 
|---|
| 651 | hBrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC, | 
|---|
| 652 | hdc, hwnd ); | 
|---|
| 653 | if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH); | 
|---|
| 654 | FillRect( hdc, &rc, hBrush ); | 
|---|
| 655 | #endif | 
|---|
| 656 |  | 
|---|
| 657 | if (!IsWindowEnabled(hwnd)) SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT)); | 
|---|
| 658 |  | 
|---|
| 659 | textLen = GetWindowTextLengthA(hwnd); | 
|---|
| 660 | if (textLen > 0) | 
|---|
| 661 | { | 
|---|
| 662 | char* text; | 
|---|
| 663 |  | 
|---|
| 664 | textLen++; | 
|---|
| 665 | text = (char*)malloc(textLen); | 
|---|
| 666 | GetWindowTextA(hwnd,text,textLen); | 
|---|
| 667 | DrawTextExA(hdc,text,-1,&rc,wFormat,NULL); | 
|---|
| 668 | free(text); | 
|---|
| 669 | } | 
|---|
| 670 | } | 
|---|
| 671 |  | 
|---|
| 672 | static void STATIC_PaintRectfn( HWND hwnd, HDC hdc ) | 
|---|
| 673 | { | 
|---|
| 674 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 675 | RECT rc; | 
|---|
| 676 | HBRUSH hBrush; | 
|---|
| 677 |  | 
|---|
| 678 | GetClientRect( hwnd, &rc); | 
|---|
| 679 |  | 
|---|
| 680 | switch (dwStyle & SS_TYPEMASK) | 
|---|
| 681 | { | 
|---|
| 682 | case SS_BLACKRECT: | 
|---|
| 683 | hBrush = CreateSolidBrush(color_windowframe); | 
|---|
| 684 | FillRect( hdc, &rc, hBrush ); | 
|---|
| 685 | break; | 
|---|
| 686 | case SS_GRAYRECT: | 
|---|
| 687 | hBrush = CreateSolidBrush(color_background); | 
|---|
| 688 | FillRect( hdc, &rc, hBrush ); | 
|---|
| 689 | break; | 
|---|
| 690 | case SS_WHITERECT: | 
|---|
| 691 | hBrush = CreateSolidBrush(color_window); | 
|---|
| 692 | FillRect( hdc, &rc, hBrush ); | 
|---|
| 693 | break; | 
|---|
| 694 | case SS_BLACKFRAME: | 
|---|
| 695 | hBrush = CreateSolidBrush(color_windowframe); | 
|---|
| 696 | FrameRect( hdc, &rc, hBrush ); | 
|---|
| 697 | break; | 
|---|
| 698 | case SS_GRAYFRAME: | 
|---|
| 699 | hBrush = CreateSolidBrush(color_background); | 
|---|
| 700 | FrameRect( hdc, &rc, hBrush ); | 
|---|
| 701 | break; | 
|---|
| 702 | case SS_WHITEFRAME: | 
|---|
| 703 | hBrush = CreateSolidBrush(color_window); | 
|---|
| 704 | FrameRect( hdc, &rc, hBrush ); | 
|---|
| 705 | break; | 
|---|
| 706 | default: | 
|---|
| 707 | return; | 
|---|
| 708 | } | 
|---|
| 709 | DeleteObject( hBrush ); | 
|---|
| 710 | } | 
|---|
| 711 |  | 
|---|
| 712 |  | 
|---|
| 713 | static void STATIC_PaintIconfn( HWND hwnd, HDC hdc ) | 
|---|
| 714 | { | 
|---|
| 715 | RECT rc; | 
|---|
| 716 | HBRUSH hbrush; | 
|---|
| 717 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); | 
|---|
| 718 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 719 |  | 
|---|
| 720 | GetClientRect( hwnd, &rc ); | 
|---|
| 721 | hbrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC, | 
|---|
| 722 | hdc, hwnd ); | 
|---|
| 723 | FillRect( hdc, &rc, hbrush ); | 
|---|
| 724 |  | 
|---|
| 725 | if (dwStyle & SS_CENTERIMAGE) | 
|---|
| 726 | { | 
|---|
| 727 | ICONINFO ii; | 
|---|
| 728 | BITMAP bmp; | 
|---|
| 729 |  | 
|---|
| 730 | #if 0 | 
|---|
| 731 | //TODO: fill with upper left pixel of icon | 
|---|
| 732 | COLORREF color; | 
|---|
| 733 |  | 
|---|
| 734 | color = GetPixel(hMemDC, 0, 0); | 
|---|
| 735 | hbrush = CreateSolidBrush(color); | 
|---|
| 736 | FillRect( hdc, &rc, hbrush ); | 
|---|
| 737 | DeleteObject(hbrush); | 
|---|
| 738 | #endif | 
|---|
| 739 |  | 
|---|
| 740 | if (!GetIconInfo(infoPtr->hIcon,&ii)) return; | 
|---|
| 741 | if (ii.hbmColor) | 
|---|
| 742 | GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp); | 
|---|
| 743 | else | 
|---|
| 744 | { | 
|---|
| 745 | GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp); | 
|---|
| 746 | bmp.bmHeight /= 2; | 
|---|
| 747 | } | 
|---|
| 748 | DrawIcon(hdc,(rc.right-bmp.bmWidth)/2,(rc.bottom-bmp.bmHeight)/2,infoPtr->hIcon); | 
|---|
| 749 | if (ii.hbmColor) DeleteObject(ii.hbmColor); | 
|---|
| 750 | if (ii.hbmMask) DeleteObject(ii.hbmMask); | 
|---|
| 751 | } | 
|---|
| 752 | else | 
|---|
| 753 | if (infoPtr->hIcon) { | 
|---|
| 754 | DrawIcon(hdc,rc.left,rc.top,infoPtr->hIcon); | 
|---|
| 755 | } | 
|---|
| 756 | } | 
|---|
| 757 |  | 
|---|
| 758 | static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc ) | 
|---|
| 759 | { | 
|---|
| 760 | RECT rc; | 
|---|
| 761 | HBRUSH hbrush; | 
|---|
| 762 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); | 
|---|
| 763 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 764 | HDC hMemDC; | 
|---|
| 765 | HBITMAP oldbitmap; | 
|---|
| 766 |  | 
|---|
| 767 | GetClientRect( hwnd, &rc ); | 
|---|
| 768 | hbrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC, | 
|---|
| 769 | hdc, hwnd ); | 
|---|
| 770 |  | 
|---|
| 771 | if (infoPtr->hIcon) | 
|---|
| 772 | { | 
|---|
| 773 | BITMAP bm; | 
|---|
| 774 |  | 
|---|
| 775 | if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP) return; | 
|---|
| 776 | if (!(hMemDC = CreateCompatibleDC( hdc ))) return; | 
|---|
| 777 |  | 
|---|
| 778 | GetObjectA(infoPtr->hIcon, sizeof(bm), &bm); | 
|---|
| 779 | oldbitmap = SelectObject(hMemDC, infoPtr->hIcon); | 
|---|
| 780 |  | 
|---|
| 781 | // Paint the image in center area | 
|---|
| 782 | if(dwStyle & SS_CENTERIMAGE) | 
|---|
| 783 | { | 
|---|
| 784 | SIZE szbm; | 
|---|
| 785 | SIZE szdc; | 
|---|
| 786 | COLORREF color; | 
|---|
| 787 |  | 
|---|
| 788 | //SvL: Fill client area with pixel in upper left corner (SDK docs) | 
|---|
| 789 | color = GetPixel(hMemDC, 0, 0); | 
|---|
| 790 | hbrush = CreateSolidBrush(color); | 
|---|
| 791 | FillRect( hdc, &rc, hbrush ); | 
|---|
| 792 | DeleteObject(hbrush); | 
|---|
| 793 |  | 
|---|
| 794 | if(bm.bmWidth > rc.right - rc.left) | 
|---|
| 795 | { | 
|---|
| 796 | szdc.cx = 0; | 
|---|
| 797 | szbm.cx = (bm.bmWidth - (rc.right - rc.left)) / 2; | 
|---|
| 798 | bm.bmWidth = rc.right - rc.left; | 
|---|
| 799 | } | 
|---|
| 800 | else | 
|---|
| 801 | { | 
|---|
| 802 | szbm.cx = 0; | 
|---|
| 803 | szdc.cx = ((rc.right - rc.left) - bm.bmWidth) / 2; | 
|---|
| 804 | } | 
|---|
| 805 | if(bm.bmHeight > rc.bottom - rc.top) | 
|---|
| 806 | { | 
|---|
| 807 | szdc.cy = 0; | 
|---|
| 808 | szbm.cy = (bm.bmHeight - (rc.bottom - rc.top)) / 2; | 
|---|
| 809 | bm.bmWidth = rc.bottom - rc.top; | 
|---|
| 810 | } | 
|---|
| 811 | else | 
|---|
| 812 | { | 
|---|
| 813 | szbm.cy = 0; | 
|---|
| 814 | szdc.cy = ((rc.bottom - rc.top) - bm.bmHeight) / 2; | 
|---|
| 815 | } | 
|---|
| 816 | BitBlt(hdc, szdc.cx, szdc.cy, bm.bmWidth, bm.bmHeight, hMemDC, | 
|---|
| 817 | szbm.cx, szbm.cy, SRCCOPY); | 
|---|
| 818 | } | 
|---|
| 819 | else | 
|---|
| 820 | { | 
|---|
| 821 | FillRect( hdc, &rc, hbrush ); | 
|---|
| 822 | BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); | 
|---|
| 823 | } | 
|---|
| 824 |  | 
|---|
| 825 | SelectObject(hMemDC, oldbitmap); | 
|---|
| 826 | DeleteDC(hMemDC); | 
|---|
| 827 | } | 
|---|
| 828 | } | 
|---|
| 829 |  | 
|---|
| 830 | static void STATIC_PaintMetafilefn(HWND hwnd,HDC hdc) | 
|---|
| 831 | { | 
|---|
| 832 | RECT rect; | 
|---|
| 833 | HBRUSH hbrush; | 
|---|
| 834 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); | 
|---|
| 835 |  | 
|---|
| 836 | GetClientRect(hwnd,&rect); | 
|---|
| 837 | hbrush = SendMessageA(GetParent(hwnd),WM_CTLCOLORSTATIC,hdc,hwnd); | 
|---|
| 838 | FillRect(hdc,&rect,hbrush); | 
|---|
| 839 |  | 
|---|
| 840 | if (infoPtr->hIcon) PlayEnhMetaFile(hdc,(HENHMETAFILE)infoPtr->hIcon,&rect); | 
|---|
| 841 | } | 
|---|
| 842 |  | 
|---|
| 843 | static void STATIC_PaintOwnerDrawfn(HWND hwnd,HDC hdc) | 
|---|
| 844 | { | 
|---|
| 845 | DRAWITEMSTRUCT di; | 
|---|
| 846 |  | 
|---|
| 847 | di.CtlType    = ODT_STATIC; | 
|---|
| 848 | di.CtlID      = GetWindowLongA(hwnd,GWL_ID); | 
|---|
| 849 | di.itemID     = 0; | 
|---|
| 850 | di.itemAction = ODA_DRAWENTIRE; | 
|---|
| 851 | di.itemState  = ODS_DEFAULT; | 
|---|
| 852 | di.hwndItem   = hwnd; | 
|---|
| 853 | di.hDC        = hdc; | 
|---|
| 854 | GetClientRect(hwnd,&di.rcItem); | 
|---|
| 855 | di.itemData   = 0; | 
|---|
| 856 |  | 
|---|
| 857 | SendMessageA(GetParent(hwnd),WM_CTLCOLORSTATIC,hdc,hwnd); | 
|---|
| 858 | SendMessageA(GetParent(hwnd),WM_DRAWITEM,di.CtlID,(LPARAM)&di); | 
|---|
| 859 | } | 
|---|
| 860 |  | 
|---|
| 861 | static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc ) | 
|---|
| 862 | { | 
|---|
| 863 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 864 | RECT rc; | 
|---|
| 865 |  | 
|---|
| 866 | GetClientRect( hwnd, &rc ); | 
|---|
| 867 | switch (dwStyle & SS_TYPEMASK) | 
|---|
| 868 | { | 
|---|
| 869 | case SS_ETCHEDHORZ: | 
|---|
| 870 | DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM); | 
|---|
| 871 | break; | 
|---|
| 872 | case SS_ETCHEDVERT: | 
|---|
| 873 | DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT); | 
|---|
| 874 | break; | 
|---|
| 875 | case SS_ETCHEDFRAME: | 
|---|
| 876 | DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT); | 
|---|
| 877 | break; | 
|---|
| 878 | } | 
|---|
| 879 | } | 
|---|
| 880 |  | 
|---|
| 881 | BOOL STATIC_Register() | 
|---|
| 882 | { | 
|---|
| 883 | WNDCLASSA wndClass; | 
|---|
| 884 |  | 
|---|
| 885 | //SvL: Don't check this now | 
|---|
| 886 | //    if (GlobalFindAtomA(STATICCLASSNAME)) return FALSE; | 
|---|
| 887 |  | 
|---|
| 888 | ZeroMemory(&wndClass,sizeof(WNDCLASSA)); | 
|---|
| 889 | wndClass.style         = CS_GLOBALCLASS | CS_HREDRAW | CS_PARENTDC; | 
|---|
| 890 | wndClass.lpfnWndProc   = (WNDPROC)StaticWndProc; | 
|---|
| 891 | wndClass.cbClsExtra    = 0; | 
|---|
| 892 | wndClass.cbWndExtra    = sizeof(STATICINFO); | 
|---|
| 893 | wndClass.hCursor       = LoadCursorA (0,IDC_ARROWA); | 
|---|
| 894 | wndClass.hbrBackground = (HBRUSH)0; | 
|---|
| 895 | wndClass.lpszClassName = STATICCLASSNAME; | 
|---|
| 896 |  | 
|---|
| 897 | return RegisterClassA(&wndClass); | 
|---|
| 898 | } | 
|---|
| 899 |  | 
|---|
| 900 |  | 
|---|
| 901 | BOOL STATIC_Unregister() | 
|---|
| 902 | { | 
|---|
| 903 | if (GlobalFindAtomA (STATICCLASSNAME)) | 
|---|
| 904 | return UnregisterClassA(STATICCLASSNAME,(HINSTANCE)NULL); | 
|---|
| 905 | else return FALSE; | 
|---|
| 906 | } | 
|---|