Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Desktop window class. |
| 3 | * |
| 4 | * Copyright 1994 Alexandre Julliard |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 19 | */ |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 20 | |
Patrik Stridvall | d016f81 | 2002-08-17 00:43:16 +0000 | [diff] [blame] | 21 | #include "config.h" |
| 22 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 23 | #include <stdarg.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 24 | #include <stdio.h> |
| 25 | #include <string.h> |
Patrik Stridvall | d016f81 | 2002-08-17 00:43:16 +0000 | [diff] [blame] | 26 | #ifdef HAVE_UNISTD_H |
| 27 | # include <unistd.h> |
| 28 | #endif |
Patrik Stridvall | 8d8703c | 1999-02-04 14:05:38 +0000 | [diff] [blame] | 29 | |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 30 | #include "windef.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 31 | #include "winbase.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 32 | #include "wingdi.h" |
Alexandre Julliard | 7f3418f | 2000-03-25 17:30:13 +0000 | [diff] [blame] | 33 | #include "user.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 34 | #include "controls.h" |
Michael Veksler | ca1bc86 | 1999-01-01 18:57:33 +0000 | [diff] [blame] | 35 | #include "wine/winuser16.h" |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 36 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 37 | static HBRUSH hbrushPattern; |
| 38 | static HBITMAP hbitmapWallPaper; |
| 39 | static SIZE bitmapSize; |
| 40 | static BOOL fTileWallPaper; |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 41 | |
| 42 | static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); |
| 43 | |
| 44 | |
| 45 | /********************************************************************* |
| 46 | * desktop class descriptor |
| 47 | */ |
| 48 | const struct builtin_class_descr DESKTOP_builtin_class = |
| 49 | { |
| 50 | DESKTOP_CLASS_ATOM, /* name */ |
Alexandre Julliard | b062210 | 2003-12-10 04:14:35 +0000 | [diff] [blame] | 51 | CS_DBLCLKS, /* style */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 52 | NULL, /* procA (winproc is Unicode only) */ |
| 53 | DesktopWndProc, /* procW */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 54 | 0, /* extra */ |
Alexandre Julliard | cf52644 | 2003-09-10 03:56:47 +0000 | [diff] [blame] | 55 | IDC_ARROW, /* cursor */ |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 56 | (HBRUSH)(COLOR_BACKGROUND+1) /* brush */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
Patrik Stridvall | b87fe2e | 1999-04-01 08:16:08 +0000 | [diff] [blame] | 59 | |
| 60 | /*********************************************************************** |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 61 | * DESKTOP_LoadBitmap |
| 62 | * |
| 63 | * Load a bitmap from a file. Used by SetDeskWallPaper(). |
| 64 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 65 | static HBITMAP DESKTOP_LoadBitmap( HDC hdc, const char *filename ) |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 66 | { |
| 67 | BITMAPFILEHEADER *fileHeader; |
| 68 | BITMAPINFO *bitmapInfo; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 69 | HBITMAP hbitmap; |
| 70 | HFILE file; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 71 | LPSTR buffer; |
| 72 | LONG size; |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 73 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 74 | /* Read all the file into memory */ |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 75 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 76 | if ((file = _lopen( filename, OF_READ )) == HFILE_ERROR) |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 77 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 78 | UINT len = GetWindowsDirectoryA( NULL, 0 ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 79 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, |
| 80 | len + strlen(filename) + 2 ))) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 81 | return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 82 | GetWindowsDirectoryA( buffer, len + 1 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 83 | strcat( buffer, "\\" ); |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 84 | strcat( buffer, filename ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 85 | file = _lopen( buffer, OF_READ ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 86 | HeapFree( GetProcessHeap(), 0, buffer ); |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 87 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 88 | if (file == HFILE_ERROR) return 0; |
| 89 | size = _llseek( file, 0, 2 ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 90 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size ))) |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 91 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 92 | _lclose( file ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 93 | return 0; |
| 94 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 95 | _llseek( file, 0, 0 ); |
| 96 | size = _lread( file, buffer, size ); |
| 97 | _lclose( file ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 98 | fileHeader = (BITMAPFILEHEADER *)buffer; |
| 99 | bitmapInfo = (BITMAPINFO *)(buffer + sizeof(BITMAPFILEHEADER)); |
Vincent BĂ©ron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 100 | |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 101 | /* Check header content */ |
| 102 | if ((fileHeader->bfType != 0x4d42) || (size < fileHeader->bfSize)) |
| 103 | { |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 104 | HeapFree( GetProcessHeap(), 0, buffer ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 105 | return 0; |
| 106 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 107 | hbitmap = CreateDIBitmap( hdc, &bitmapInfo->bmiHeader, CBM_INIT, |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 108 | buffer + fileHeader->bfOffBits, |
| 109 | bitmapInfo, DIB_RGB_COLORS ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 110 | HeapFree( GetProcessHeap(), 0, buffer ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 111 | return hbitmap; |
| 112 | } |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 113 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 114 | |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 115 | |
| 116 | /*********************************************************************** |
| 117 | * DesktopWndProc |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 118 | */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 119 | static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 120 | { |
Alexandre Julliard | b650372 | 2003-04-19 21:27:19 +0000 | [diff] [blame] | 121 | /* all messages are ignored */ |
| 122 | return 0; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 125 | /*********************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 126 | * PaintDesktop (USER32.@) |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 127 | * |
| 128 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 129 | BOOL WINAPI PaintDesktop(HDC hdc) |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 130 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 131 | HWND hwnd = GetDesktopWindow(); |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 132 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 133 | /* check for an owning thread; otherwise don't paint anything (non-desktop mode) */ |
| 134 | if (GetWindowThreadProcessId( hwnd, NULL )) |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 135 | { |
| 136 | RECT rect; |
| 137 | |
| 138 | GetClientRect( hwnd, &rect ); |
| 139 | |
| 140 | /* Paint desktop pattern (only if wall paper does not cover everything) */ |
| 141 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 142 | if (!hbitmapWallPaper || |
| 143 | (!fTileWallPaper && ((bitmapSize.cx < rect.right) || (bitmapSize.cy < rect.bottom)))) |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 144 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 145 | HBRUSH brush = hbrushPattern; |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 146 | if (!brush) brush = (HBRUSH)GetClassLongA( hwnd, GCL_HBRBACKGROUND ); |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 147 | /* Set colors in case pattern is a monochrome bitmap */ |
| 148 | SetBkColor( hdc, RGB(0,0,0) ); |
| 149 | SetTextColor( hdc, GetSysColor(COLOR_BACKGROUND) ); |
| 150 | FillRect( hdc, &rect, brush ); |
| 151 | } |
| 152 | |
| 153 | /* Paint wall paper */ |
| 154 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 155 | if (hbitmapWallPaper) |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 156 | { |
| 157 | INT x, y; |
| 158 | HDC hMemDC = CreateCompatibleDC( hdc ); |
| 159 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 160 | SelectObject( hMemDC, hbitmapWallPaper ); |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 161 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 162 | if (fTileWallPaper) |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 163 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 164 | for (y = 0; y < rect.bottom; y += bitmapSize.cy) |
| 165 | for (x = 0; x < rect.right; x += bitmapSize.cx) |
| 166 | BitBlt( hdc, x, y, bitmapSize.cx, bitmapSize.cy, hMemDC, 0, 0, SRCCOPY ); |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 167 | } |
| 168 | else |
| 169 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 170 | x = (rect.left + rect.right - bitmapSize.cx) / 2; |
| 171 | y = (rect.top + rect.bottom - bitmapSize.cy) / 2; |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 172 | if (x < 0) x = 0; |
| 173 | if (y < 0) y = 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 174 | BitBlt( hdc, x, y, bitmapSize.cx, bitmapSize.cy, hMemDC, 0, 0, SRCCOPY ); |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 175 | } |
| 176 | DeleteDC( hMemDC ); |
| 177 | } |
| 178 | } |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 179 | return TRUE; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 180 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 181 | |
| 182 | /*********************************************************************** |
Patrik Stridvall | 15a3b74 | 2001-04-27 18:03:51 +0000 | [diff] [blame] | 183 | * OldSetDeskPattern (USER.279) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 184 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 185 | BOOL16 WINAPI SetDeskPattern(void) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 186 | { |
Alexandre Julliard | b650372 | 2003-04-19 21:27:19 +0000 | [diff] [blame] | 187 | return SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | |
| 191 | /*********************************************************************** |
Patrik Stridvall | 15a3b74 | 2001-04-27 18:03:51 +0000 | [diff] [blame] | 192 | * SetDeskWallPaper (USER.285) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 193 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 194 | BOOL16 WINAPI SetDeskWallPaper16( LPCSTR filename ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 195 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 196 | return SetDeskWallPaper( filename ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | |
| 200 | /*********************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 201 | * SetDeskWallPaper (USER32.@) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 202 | * |
| 203 | * FIXME: is there a unicode version? |
| 204 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 205 | BOOL WINAPI SetDeskWallPaper( LPCSTR filename ) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 206 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 207 | HBITMAP hbitmap; |
| 208 | HDC hdc; |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 209 | char buffer[256]; |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 210 | |
| 211 | if (filename == (LPSTR)-1) |
| 212 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 213 | GetProfileStringA( "desktop", "WallPaper", "(None)", buffer, 256 ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 214 | filename = buffer; |
| 215 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 216 | hdc = GetDC( 0 ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 217 | hbitmap = DESKTOP_LoadBitmap( hdc, filename ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 218 | ReleaseDC( 0, hdc ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 219 | if (hbitmapWallPaper) DeleteObject( hbitmapWallPaper ); |
| 220 | hbitmapWallPaper = hbitmap; |
| 221 | fTileWallPaper = GetProfileIntA( "desktop", "TileWallPaper", 0 ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 222 | if (hbitmap) |
| 223 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 224 | BITMAP bmp; |
| 225 | GetObjectA( hbitmap, sizeof(bmp), &bmp ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 226 | bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1; |
| 227 | bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1; |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 228 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 229 | return TRUE; |
| 230 | } |
| 231 | |
| 232 | |
| 233 | /*********************************************************************** |
| 234 | * DESKTOP_SetPattern |
| 235 | * |
| 236 | * Set the desktop pattern. |
| 237 | */ |
Justin Chevrier | 0a25dd4 | 2004-03-04 01:41:11 +0000 | [diff] [blame] | 238 | BOOL DESKTOP_SetPattern( LPCWSTR pattern ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 239 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 240 | int pat[8]; |
| 241 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 242 | if (hbrushPattern) DeleteObject( hbrushPattern ); |
Justin Chevrier | 0a25dd4 | 2004-03-04 01:41:11 +0000 | [diff] [blame] | 243 | hbrushPattern = 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 244 | memset( pat, 0, sizeof(pat) ); |
Justin Chevrier | 0a25dd4 | 2004-03-04 01:41:11 +0000 | [diff] [blame] | 245 | if (pattern) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 246 | { |
Justin Chevrier | 0a25dd4 | 2004-03-04 01:41:11 +0000 | [diff] [blame] | 247 | char buffer[64]; |
| 248 | WideCharToMultiByte( CP_ACP, 0, pattern, -1, buffer, sizeof(buffer), NULL, NULL ); |
| 249 | if (sscanf( buffer, " %d %d %d %d %d %d %d %d", |
| 250 | &pat[0], &pat[1], &pat[2], &pat[3], |
| 251 | &pat[4], &pat[5], &pat[6], &pat[7] )) |
| 252 | { |
| 253 | WORD pattern[8]; |
| 254 | HBITMAP hbitmap; |
| 255 | int i; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 256 | |
Justin Chevrier | 0a25dd4 | 2004-03-04 01:41:11 +0000 | [diff] [blame] | 257 | for (i = 0; i < 8; i++) pattern[i] = pat[i] & 0xffff; |
| 258 | hbitmap = CreateBitmap( 8, 8, 1, 1, (LPSTR)pattern ); |
| 259 | hbrushPattern = CreatePatternBrush( hbitmap ); |
| 260 | DeleteObject( hbitmap ); |
| 261 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 262 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 263 | return TRUE; |
| 264 | } |