Skip to content

Commit c65efd0

Browse files
winesynclearn-more
authored andcommitted
[WINESYNC] msi: Add support for bitmap buttons.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48974 Signed-off-by: Hans Leidekker <[email protected]> Signed-off-by: Alexandre Julliard <[email protected]> wine commit id 9cc044957791e0658ec3d0d8ad08eebfc08b522c by Hans Leidekker <[email protected]>
1 parent f4d2571 commit c65efd0

File tree

1 file changed

+91
-75
lines changed

1 file changed

+91
-75
lines changed

dll/win32/msi/dialog.c

Lines changed: 91 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,38 +1014,120 @@ static UINT msi_dialog_button_handler( msi_dialog *dialog, msi_control *control,
10141014
return r;
10151015
}
10161016

1017+
static HBITMAP msi_load_picture( MSIDATABASE *db, const WCHAR *name, INT cx, INT cy, DWORD flags )
1018+
{
1019+
HBITMAP hOleBitmap = 0, hBitmap = 0, hOldSrcBitmap, hOldDestBitmap;
1020+
MSIRECORD *rec = NULL;
1021+
IStream *stm = NULL;
1022+
IPicture *pic = NULL;
1023+
HDC srcdc, destdc;
1024+
BITMAP bm;
1025+
UINT r;
1026+
1027+
rec = msi_get_binary_record( db, name );
1028+
if (!rec)
1029+
goto end;
1030+
1031+
r = MSI_RecordGetIStream( rec, 2, &stm );
1032+
msiobj_release( &rec->hdr );
1033+
if (r != ERROR_SUCCESS)
1034+
goto end;
1035+
1036+
r = OleLoadPicture( stm, 0, TRUE, &IID_IPicture, (void **)&pic );
1037+
IStream_Release( stm );
1038+
if (FAILED( r ))
1039+
{
1040+
ERR("failed to load picture\n");
1041+
goto end;
1042+
}
1043+
1044+
r = IPicture_get_Handle( pic, (OLE_HANDLE *)&hOleBitmap );
1045+
if (FAILED( r ))
1046+
{
1047+
ERR("failed to get bitmap handle\n");
1048+
goto end;
1049+
}
1050+
1051+
/* make the bitmap the desired size */
1052+
r = GetObjectW( hOleBitmap, sizeof(bm), &bm );
1053+
if (r != sizeof(bm))
1054+
{
1055+
ERR("failed to get bitmap size\n");
1056+
goto end;
1057+
}
1058+
1059+
if (flags & LR_DEFAULTSIZE)
1060+
{
1061+
cx = bm.bmWidth;
1062+
cy = bm.bmHeight;
1063+
}
1064+
1065+
srcdc = CreateCompatibleDC( NULL );
1066+
hOldSrcBitmap = SelectObject( srcdc, hOleBitmap );
1067+
destdc = CreateCompatibleDC( NULL );
1068+
hBitmap = CreateCompatibleBitmap( srcdc, cx, cy );
1069+
hOldDestBitmap = SelectObject( destdc, hBitmap );
1070+
StretchBlt( destdc, 0, 0, cx, cy, srcdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY );
1071+
SelectObject( srcdc, hOldSrcBitmap );
1072+
SelectObject( destdc, hOldDestBitmap );
1073+
DeleteDC( srcdc );
1074+
DeleteDC( destdc );
1075+
1076+
end:
1077+
if (pic) IPicture_Release( pic );
1078+
return hBitmap;
1079+
}
1080+
10171081
static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec )
10181082
{
10191083
msi_control *control;
1020-
UINT attributes, style;
1084+
UINT attributes, style, cx = 0, cy = 0, flags = 0;
1085+
WCHAR *name = NULL;
10211086

10221087
TRACE("%p %p\n", dialog, rec);
10231088

10241089
style = WS_TABSTOP;
10251090
attributes = MSI_RecordGetInteger( rec, 8 );
1026-
if( attributes & msidbControlAttributesIcon )
1027-
style |= BS_ICON;
1091+
if (attributes & msidbControlAttributesIcon) style |= BS_ICON;
1092+
else if (attributes & msidbControlAttributesBitmap)
1093+
{
1094+
style |= BS_BITMAP;
1095+
if (attributes & msidbControlAttributesFixedSize) flags |= LR_DEFAULTSIZE;
1096+
else
1097+
{
1098+
cx = msi_dialog_scale_unit( dialog, MSI_RecordGetInteger(rec, 6) );
1099+
cy = msi_dialog_scale_unit( dialog, MSI_RecordGetInteger(rec, 7) );
1100+
}
1101+
}
10281102

10291103
control = msi_dialog_add_control( dialog, rec, szButton, style );
1030-
if( !control )
1104+
if (!control)
10311105
return ERROR_FUNCTION_FAILED;
10321106

10331107
control->handler = msi_dialog_button_handler;
10341108

10351109
if (attributes & msidbControlAttributesIcon)
10361110
{
1037-
/* set the icon */
1038-
LPWSTR name = msi_get_binary_name( dialog->package, rec );
1111+
name = msi_get_binary_name( dialog->package, rec );
10391112
control->hIcon = msi_load_icon( dialog->package->db, name, attributes );
10401113
if (control->hIcon)
10411114
{
10421115
SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon );
10431116
}
1044-
else
1045-
ERR("Failed to load icon %s\n", debugstr_w(name));
1046-
msi_free( name );
1117+
else ERR("Failed to load icon %s\n", debugstr_w(name));
1118+
}
1119+
else if (attributes & msidbControlAttributesBitmap)
1120+
{
1121+
name = msi_get_binary_name( dialog->package, rec );
1122+
control->hBitmap = msi_load_picture( dialog->package->db, name, cx, cy, flags );
1123+
if (control->hBitmap)
1124+
{
1125+
SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) control->hBitmap );
1126+
}
1127+
else ERR("Failed to load bitmap %s\n", debugstr_w(name));
10471128
}
10481129

1130+
msi_free( name );
10491131
return ERROR_SUCCESS;
10501132
}
10511133

@@ -1341,72 +1423,6 @@ static UINT msi_dialog_scrolltext_control( msi_dialog *dialog, MSIRECORD *rec )
13411423
return ERROR_SUCCESS;
13421424
}
13431425

1344-
static HBITMAP msi_load_picture( MSIDATABASE *db, LPCWSTR name,
1345-
INT cx, INT cy, DWORD flags )
1346-
{
1347-
HBITMAP hOleBitmap = 0, hBitmap = 0, hOldSrcBitmap, hOldDestBitmap;
1348-
MSIRECORD *rec = NULL;
1349-
IStream *stm = NULL;
1350-
IPicture *pic = NULL;
1351-
HDC srcdc, destdc;
1352-
BITMAP bm;
1353-
UINT r;
1354-
1355-
rec = msi_get_binary_record( db, name );
1356-
if( !rec )
1357-
goto end;
1358-
1359-
r = MSI_RecordGetIStream( rec, 2, &stm );
1360-
msiobj_release( &rec->hdr );
1361-
if( r != ERROR_SUCCESS )
1362-
goto end;
1363-
1364-
r = OleLoadPicture( stm, 0, TRUE, &IID_IPicture, (LPVOID*) &pic );
1365-
IStream_Release( stm );
1366-
if( FAILED( r ) )
1367-
{
1368-
ERR("failed to load picture\n");
1369-
goto end;
1370-
}
1371-
1372-
r = IPicture_get_Handle( pic, (OLE_HANDLE*) &hOleBitmap );
1373-
if( FAILED( r ) )
1374-
{
1375-
ERR("failed to get bitmap handle\n");
1376-
goto end;
1377-
}
1378-
1379-
/* make the bitmap the desired size */
1380-
r = GetObjectW( hOleBitmap, sizeof bm, &bm );
1381-
if (r != sizeof bm )
1382-
{
1383-
ERR("failed to get bitmap size\n");
1384-
goto end;
1385-
}
1386-
1387-
if (flags & LR_DEFAULTSIZE)
1388-
{
1389-
cx = bm.bmWidth;
1390-
cy = bm.bmHeight;
1391-
}
1392-
1393-
srcdc = CreateCompatibleDC( NULL );
1394-
hOldSrcBitmap = SelectObject( srcdc, hOleBitmap );
1395-
destdc = CreateCompatibleDC( NULL );
1396-
hBitmap = CreateCompatibleBitmap( srcdc, cx, cy );
1397-
hOldDestBitmap = SelectObject( destdc, hBitmap );
1398-
StretchBlt( destdc, 0, 0, cx, cy,
1399-
srcdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
1400-
SelectObject( srcdc, hOldSrcBitmap );
1401-
SelectObject( destdc, hOldDestBitmap );
1402-
DeleteDC( srcdc );
1403-
DeleteDC( destdc );
1404-
1405-
end:
1406-
if ( pic )
1407-
IPicture_Release( pic );
1408-
return hBitmap;
1409-
}
14101426

14111427
static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec )
14121428
{

0 commit comments

Comments
 (0)