2005-01-28 13:39:57 +01:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mike McCormack for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-28 13:39:57 +01:00
|
|
|
*/
|
|
|
|
|
2005-04-11 14:47:20 +02:00
|
|
|
#define COBJMACROS
|
2005-11-02 11:56:22 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2005-04-11 14:47:20 +02:00
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2006-08-04 02:42:05 +02:00
|
|
|
#include "wingdi.h"
|
2005-01-28 13:39:57 +01:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "msi.h"
|
|
|
|
#include "msipriv.h"
|
2005-02-02 10:55:51 +01:00
|
|
|
#include "msidefs.h"
|
2005-04-11 14:47:20 +02:00
|
|
|
#include "ocidl.h"
|
|
|
|
#include "olectl.h"
|
2005-06-07 22:30:02 +02:00
|
|
|
#include "richedit.h"
|
2005-09-28 17:12:10 +02:00
|
|
|
#include "commctrl.h"
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
#include "action.h"
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
|
2006-01-11 21:12:06 +01:00
|
|
|
extern HINSTANCE msi_hInstance;
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
struct msi_control_tag;
|
|
|
|
typedef struct msi_control_tag msi_control;
|
2005-02-09 14:24:31 +01:00
|
|
|
typedef UINT (*msi_handler)( msi_dialog *, msi_control *, WPARAM );
|
2005-02-02 10:55:51 +01:00
|
|
|
|
|
|
|
struct msi_control_tag
|
|
|
|
{
|
2005-09-16 21:40:00 +02:00
|
|
|
struct list entry;
|
2005-02-02 10:55:51 +01:00
|
|
|
HWND hwnd;
|
2005-02-09 14:24:31 +01:00
|
|
|
msi_handler handler;
|
2005-02-03 11:41:59 +01:00
|
|
|
LPWSTR property;
|
2005-06-01 21:48:48 +02:00
|
|
|
LPWSTR value;
|
2005-07-07 19:20:57 +02:00
|
|
|
HBITMAP hBitmap;
|
2005-06-23 18:43:38 +02:00
|
|
|
HICON hIcon;
|
2005-06-30 12:20:40 +02:00
|
|
|
LPWSTR tabnext;
|
2006-01-06 12:35:09 +01:00
|
|
|
HMODULE hDll;
|
2006-06-09 10:05:50 +02:00
|
|
|
float progress_current;
|
|
|
|
float progress_max;
|
2005-02-02 10:55:51 +01:00
|
|
|
WCHAR name[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct msi_font_tag
|
|
|
|
{
|
|
|
|
struct msi_font_tag *next;
|
|
|
|
HFONT hfont;
|
2006-06-27 11:04:16 +02:00
|
|
|
COLORREF color;
|
2005-02-02 10:55:51 +01:00
|
|
|
WCHAR name[1];
|
|
|
|
} msi_font;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
struct msi_dialog_tag
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
msi_dialog_event_handler event_handler;
|
2005-02-02 10:55:51 +01:00
|
|
|
BOOL finished;
|
2005-01-28 13:39:57 +01:00
|
|
|
INT scale;
|
2005-02-02 10:55:51 +01:00
|
|
|
DWORD attributes;
|
2005-01-28 13:39:57 +01:00
|
|
|
HWND hwnd;
|
2005-02-08 13:55:47 +01:00
|
|
|
LPWSTR default_font;
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_font *font_list;
|
2005-09-16 21:40:00 +02:00
|
|
|
struct list controls;
|
2005-07-05 18:18:46 +02:00
|
|
|
HWND hWndFocus;
|
2005-10-29 13:07:46 +02:00
|
|
|
LPWSTR control_default;
|
|
|
|
LPWSTR control_cancel;
|
2005-01-28 13:39:57 +01:00
|
|
|
WCHAR name[1];
|
|
|
|
};
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
typedef UINT (*msi_dialog_control_func)( msi_dialog *dialog, MSIRECORD *rec );
|
2005-01-28 13:39:57 +01:00
|
|
|
struct control_handler
|
|
|
|
{
|
|
|
|
LPCWSTR control_type;
|
|
|
|
msi_dialog_control_func func;
|
|
|
|
};
|
|
|
|
|
2005-03-04 13:32:08 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
msi_dialog* dialog;
|
|
|
|
msi_control *parent;
|
|
|
|
DWORD attributes;
|
2006-05-24 10:41:17 +02:00
|
|
|
LPWSTR propval;
|
2005-03-04 13:32:08 +01:00
|
|
|
} radio_button_group_descr;
|
|
|
|
|
2006-06-12 13:39:59 +02:00
|
|
|
static const WCHAR szMsiDialogClass[] = {
|
2005-06-04 11:48:47 +02:00
|
|
|
'M','s','i','D','i','a','l','o','g','C','l','o','s','e','C','l','a','s','s',0
|
|
|
|
};
|
2006-06-12 13:39:59 +02:00
|
|
|
static const WCHAR szMsiHiddenWindow[] = {
|
2005-06-04 11:48:47 +02:00
|
|
|
'M','s','i','H','i','d','d','e','n','W','i','n','d','o','w',0 };
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szStatic[] = { 'S','t','a','t','i','c',0 };
|
|
|
|
static const WCHAR szButton[] = { 'B','U','T','T','O','N', 0 };
|
|
|
|
static const WCHAR szButtonData[] = { 'M','S','I','D','A','T','A',0 };
|
2006-01-23 11:55:19 +01:00
|
|
|
static const WCHAR szProgress[] = { 'P','r','o','g','r','e','s','s',0 };
|
2005-06-04 11:48:47 +02:00
|
|
|
static const WCHAR szText[] = { 'T','e','x','t',0 };
|
|
|
|
static const WCHAR szPushButton[] = { 'P','u','s','h','B','u','t','t','o','n',0 };
|
|
|
|
static const WCHAR szLine[] = { 'L','i','n','e',0 };
|
|
|
|
static const WCHAR szBitmap[] = { 'B','i','t','m','a','p',0 };
|
|
|
|
static const WCHAR szCheckBox[] = { 'C','h','e','c','k','B','o','x',0 };
|
|
|
|
static const WCHAR szScrollableText[] = {
|
|
|
|
'S','c','r','o','l','l','a','b','l','e','T','e','x','t',0 };
|
|
|
|
static const WCHAR szComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
|
|
|
|
static const WCHAR szEdit[] = { 'E','d','i','t',0 };
|
|
|
|
static const WCHAR szMaskedEdit[] = { 'M','a','s','k','e','d','E','d','i','t',0 };
|
|
|
|
static const WCHAR szPathEdit[] = { 'P','a','t','h','E','d','i','t',0 };
|
2005-09-28 17:12:10 +02:00
|
|
|
static const WCHAR szProgressBar[] = {
|
|
|
|
'P','r','o','g','r','e','s','s','B','a','r',0 };
|
2005-06-04 11:48:47 +02:00
|
|
|
static const WCHAR szRadioButtonGroup[] = {
|
|
|
|
'R','a','d','i','o','B','u','t','t','o','n','G','r','o','u','p',0 };
|
2005-06-23 18:43:38 +02:00
|
|
|
static const WCHAR szIcon[] = { 'I','c','o','n',0 };
|
2005-10-30 20:21:24 +01:00
|
|
|
static const WCHAR szSelectionTree[] = {
|
|
|
|
'S','e','l','e','c','t','i','o','n','T','r','e','e',0 };
|
2006-07-13 23:03:23 +02:00
|
|
|
static const WCHAR szGroupBox[] = { 'G','r','o','u','p','B','o','x',0 };
|
2006-07-15 00:46:00 +02:00
|
|
|
static const WCHAR szListBox[] = { 'L','i','s','t','B','o','x',0 };
|
2005-06-04 11:48:47 +02:00
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
static UINT msi_dialog_checkbox_handler( msi_dialog *, msi_control *, WPARAM );
|
2005-02-03 11:41:59 +01:00
|
|
|
static void msi_dialog_checkbox_sync_state( msi_dialog *, msi_control * );
|
2005-02-09 14:24:31 +01:00
|
|
|
static UINT msi_dialog_button_handler( msi_dialog *, msi_control *, WPARAM );
|
|
|
|
static UINT msi_dialog_edit_handler( msi_dialog *, msi_control *, WPARAM );
|
2005-03-04 13:32:08 +01:00
|
|
|
static UINT msi_dialog_radiogroup_handler( msi_dialog *, msi_control *, WPARAM param );
|
2005-06-16 22:37:53 +02:00
|
|
|
static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog );
|
2005-03-04 13:32:08 +01:00
|
|
|
static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
2005-02-03 11:41:59 +01:00
|
|
|
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
/* dialog sequencing */
|
|
|
|
|
|
|
|
#define WM_MSI_DIALOG_CREATE (WM_USER+0x100)
|
|
|
|
#define WM_MSI_DIALOG_DESTROY (WM_USER+0x101)
|
|
|
|
|
|
|
|
static DWORD uiThreadId;
|
|
|
|
static HWND hMsiHiddenWindow;
|
|
|
|
|
2005-05-31 11:30:28 +02:00
|
|
|
static INT msi_dialog_scale_unit( msi_dialog *dialog, INT val )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
return (dialog->scale * val + 5) / 10;
|
|
|
|
}
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-06-04 11:48:47 +02:00
|
|
|
static msi_control *msi_dialog_find_control( msi_dialog *dialog, LPCWSTR name )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
|
|
|
|
2005-06-30 12:20:40 +02:00
|
|
|
if( !name )
|
|
|
|
return NULL;
|
2005-09-16 21:40:00 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
|
2005-06-04 11:48:47 +02:00
|
|
|
if( !strcmpW( control->name, name ) ) /* FIXME: case sensitive? */
|
2005-09-22 12:49:26 +02:00
|
|
|
return control;
|
|
|
|
return NULL;
|
2005-06-04 11:48:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static msi_control *msi_dialog_find_control_by_hwnd( msi_dialog *dialog, HWND hwnd )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
|
|
|
|
2005-09-16 21:40:00 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
|
2005-06-04 11:48:47 +02:00
|
|
|
if( hwnd == control->hwnd )
|
2005-09-22 12:49:26 +02:00
|
|
|
return control;
|
|
|
|
return NULL;
|
2005-06-04 11:48:47 +02:00
|
|
|
}
|
|
|
|
|
2005-09-16 21:01:18 +02:00
|
|
|
static LPWSTR msi_get_deformatted_field( MSIPACKAGE *package, MSIRECORD *rec, int field )
|
|
|
|
{
|
|
|
|
LPCWSTR str = MSI_RecordGetString( rec, field );
|
|
|
|
LPWSTR ret = NULL;
|
|
|
|
|
|
|
|
if (str)
|
|
|
|
deformat_string( package, str, &ret );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
/*
|
|
|
|
* msi_dialog_get_style
|
|
|
|
*
|
|
|
|
* Extract the {\style} string from the front of the text to display and
|
|
|
|
* update the pointer.
|
|
|
|
*/
|
2005-09-21 12:19:42 +02:00
|
|
|
static LPWSTR msi_dialog_get_style( LPCWSTR p, LPCWSTR *rest )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
|
|
|
LPWSTR ret = NULL;
|
2005-09-21 12:19:42 +02:00
|
|
|
LPCWSTR q, i;
|
2005-02-02 10:55:51 +01:00
|
|
|
DWORD len;
|
|
|
|
|
2005-09-21 12:19:42 +02:00
|
|
|
*rest = p;
|
|
|
|
if( !p )
|
2005-09-17 16:29:29 +02:00
|
|
|
return ret;
|
2005-02-02 10:55:51 +01:00
|
|
|
if( *p++ != '{' )
|
|
|
|
return ret;
|
|
|
|
q = strchrW( p, '}' );
|
|
|
|
if( !q )
|
|
|
|
return ret;
|
2005-09-22 12:54:56 +02:00
|
|
|
if( *p == '\\' || *p == '&' )
|
|
|
|
p++;
|
2005-09-21 12:19:42 +02:00
|
|
|
|
|
|
|
/* little bit of sanity checking to stop us getting confused with RTF */
|
|
|
|
for( i=p; i<q; i++ )
|
|
|
|
if( *i == '}' || *i == '\\' )
|
|
|
|
return ret;
|
2005-02-02 10:55:51 +01:00
|
|
|
|
2005-09-21 12:19:42 +02:00
|
|
|
*rest = ++q;
|
|
|
|
len = q - p;
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
ret = msi_alloc( len*sizeof(WCHAR) );
|
2005-02-02 10:55:51 +01:00
|
|
|
if( !ret )
|
|
|
|
return ret;
|
2005-03-28 16:17:51 +02:00
|
|
|
memcpy( ret, p, len*sizeof(WCHAR) );
|
2005-02-02 10:55:51 +01:00
|
|
|
ret[len-1] = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
msi_dialog *dialog = param;
|
|
|
|
msi_font *font;
|
|
|
|
LPCWSTR face, name;
|
|
|
|
LOGFONTW lf;
|
|
|
|
INT style;
|
|
|
|
HDC hdc;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
/* create a font and add it to the list */
|
|
|
|
name = MSI_RecordGetString( rec, 1 );
|
2005-09-20 13:59:14 +02:00
|
|
|
font = msi_alloc( sizeof *font + strlenW( name )*sizeof (WCHAR) );
|
2005-02-02 10:55:51 +01:00
|
|
|
strcpyW( font->name, name );
|
|
|
|
font->next = dialog->font_list;
|
|
|
|
dialog->font_list = font;
|
|
|
|
|
2006-06-27 11:04:16 +02:00
|
|
|
font->color = MSI_RecordGetInteger( rec, 4 );
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
memset( &lf, 0, sizeof lf );
|
|
|
|
face = MSI_RecordGetString( rec, 2 );
|
|
|
|
lf.lfHeight = MSI_RecordGetInteger( rec, 3 );
|
|
|
|
style = MSI_RecordGetInteger( rec, 5 );
|
2005-02-03 11:41:59 +01:00
|
|
|
if( style & msidbTextStyleStyleBitsBold )
|
2005-02-02 10:55:51 +01:00
|
|
|
lf.lfWeight = FW_BOLD;
|
2005-02-03 11:41:59 +01:00
|
|
|
if( style & msidbTextStyleStyleBitsItalic )
|
2005-02-02 10:55:51 +01:00
|
|
|
lf.lfItalic = TRUE;
|
2005-02-03 11:41:59 +01:00
|
|
|
if( style & msidbTextStyleStyleBitsUnderline )
|
2005-02-02 10:55:51 +01:00
|
|
|
lf.lfUnderline = TRUE;
|
2005-02-03 11:41:59 +01:00
|
|
|
if( style & msidbTextStyleStyleBitsStrike )
|
2005-02-02 10:55:51 +01:00
|
|
|
lf.lfStrikeOut = TRUE;
|
|
|
|
lstrcpynW( lf.lfFaceName, face, LF_FACESIZE );
|
|
|
|
|
|
|
|
/* adjust the height */
|
|
|
|
hdc = GetDC( dialog->hwnd );
|
|
|
|
if (hdc)
|
|
|
|
{
|
|
|
|
lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
|
|
|
|
ReleaseDC( dialog->hwnd, hdc );
|
|
|
|
}
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
font->hfont = CreateFontIndirectW( &lf );
|
|
|
|
|
|
|
|
TRACE("Adding font style %s\n", debugstr_w(font->name) );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static msi_font *msi_dialog_find_font( msi_dialog *dialog, LPCWSTR name )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_font *font;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
for( font = dialog->font_list; font; font = font->next )
|
|
|
|
if( !strcmpW( font->name, name ) ) /* FIXME: case sensitive? */
|
|
|
|
break;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
return font;
|
|
|
|
}
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_set_font( msi_dialog *dialog, HWND hwnd, LPCWSTR name )
|
|
|
|
{
|
|
|
|
msi_font *font;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
font = msi_dialog_find_font( dialog, name );
|
|
|
|
if( font )
|
|
|
|
SendMessageW( hwnd, WM_SETFONT, (WPARAM) font->hfont, TRUE );
|
|
|
|
else
|
|
|
|
ERR("No font entry for %s\n", debugstr_w(name));
|
2005-01-28 13:39:57 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_build_font_list( msi_dialog *dialog )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','`','T','e','x','t','S','t','y','l','e','`',' ',0
|
|
|
|
};
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
|
|
|
|
TRACE("dialog %p\n", dialog );
|
|
|
|
|
|
|
|
r = MSI_OpenQuery( dialog->package->db, &view, query );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MSI_IterateRecords( view, NULL, msi_dialog_add_font, dialog );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-03-24 16:09:31 +01:00
|
|
|
static msi_control *msi_dialog_create_window( msi_dialog *dialog,
|
2006-01-23 11:55:33 +01:00
|
|
|
MSIRECORD *rec, DWORD exstyle, LPCWSTR szCls, LPCWSTR name, LPCWSTR text,
|
2005-03-24 16:09:31 +01:00
|
|
|
DWORD style, HWND parent )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-03-24 16:09:31 +01:00
|
|
|
DWORD x, y, width, height;
|
2005-09-21 12:19:42 +02:00
|
|
|
LPWSTR font = NULL, title_font = NULL;
|
|
|
|
LPCWSTR title = NULL;
|
2005-03-24 16:09:31 +01:00
|
|
|
msi_control *control;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-06-07 22:04:21 +02:00
|
|
|
style |= WS_CHILD;
|
2005-02-02 10:55:51 +01:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
control = msi_alloc( sizeof *control + strlenW(name)*sizeof(WCHAR) );
|
2005-02-02 10:55:51 +01:00
|
|
|
strcpyW( control->name, name );
|
2005-09-16 21:40:00 +02:00
|
|
|
list_add_head( &dialog->controls, &control->entry );
|
2005-02-09 14:24:31 +01:00
|
|
|
control->handler = NULL;
|
2005-02-03 11:41:59 +01:00
|
|
|
control->property = NULL;
|
2005-06-01 21:48:48 +02:00
|
|
|
control->value = NULL;
|
2005-07-07 19:20:57 +02:00
|
|
|
control->hBitmap = NULL;
|
2005-06-23 18:43:38 +02:00
|
|
|
control->hIcon = NULL;
|
2006-01-06 12:35:09 +01:00
|
|
|
control->hDll = NULL;
|
2005-06-30 12:20:40 +02:00
|
|
|
control->tabnext = strdupW( MSI_RecordGetString( rec, 11) );
|
2006-06-09 10:05:50 +02:00
|
|
|
control->progress_current = 0;
|
|
|
|
control->progress_max = 100;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
x = MSI_RecordGetInteger( rec, 4 );
|
|
|
|
y = MSI_RecordGetInteger( rec, 5 );
|
|
|
|
width = MSI_RecordGetInteger( rec, 6 );
|
|
|
|
height = MSI_RecordGetInteger( rec, 7 );
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
x = msi_dialog_scale_unit( dialog, x );
|
|
|
|
y = msi_dialog_scale_unit( dialog, y );
|
|
|
|
width = msi_dialog_scale_unit( dialog, width );
|
|
|
|
height = msi_dialog_scale_unit( dialog, height );
|
|
|
|
|
2005-02-08 13:55:47 +01:00
|
|
|
if( text )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2005-09-21 12:19:42 +02:00
|
|
|
deformat_string( dialog->package, text, &title_font );
|
|
|
|
font = msi_dialog_get_style( title_font, &title );
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
2005-03-24 16:09:31 +01:00
|
|
|
|
2006-01-23 11:55:33 +01:00
|
|
|
control->hwnd = CreateWindowExW( exstyle, szCls, title, style,
|
2005-03-24 16:09:31 +01:00
|
|
|
x, y, width, height, parent, NULL, NULL, NULL );
|
|
|
|
|
|
|
|
TRACE("Dialog %s control %s hwnd %p\n",
|
|
|
|
debugstr_w(dialog->name), debugstr_w(text), control->hwnd );
|
|
|
|
|
2005-02-08 13:55:47 +01:00
|
|
|
msi_dialog_set_font( dialog, control->hwnd,
|
|
|
|
font ? font : dialog->default_font );
|
2005-03-24 16:09:31 +01:00
|
|
|
|
2005-09-21 12:19:42 +02:00
|
|
|
msi_free( title_font );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( font );
|
2005-03-24 16:09:31 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
return control;
|
|
|
|
}
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-07-12 19:01:10 +02:00
|
|
|
static MSIRECORD *msi_get_binary_record( MSIDATABASE *db, LPCWSTR name )
|
|
|
|
{
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR query[] = {
|
2005-07-12 19:01:10 +02:00
|
|
|
's','e','l','e','c','t',' ','*',' ',
|
|
|
|
'f','r','o','m',' ','B','i','n','a','r','y',' ',
|
|
|
|
'w','h','e','r','e',' ',
|
|
|
|
'`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0
|
|
|
|
};
|
|
|
|
|
|
|
|
return MSI_QueryGetRecord( db, query, name );
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPWSTR msi_create_tmp_path(void)
|
|
|
|
{
|
|
|
|
WCHAR tmp[MAX_PATH];
|
|
|
|
LPWSTR path = NULL;
|
|
|
|
static const WCHAR prefix[] = { 'm','s','i',0 };
|
|
|
|
DWORD len, r;
|
|
|
|
|
|
|
|
r = GetTempPathW( MAX_PATH, tmp );
|
|
|
|
if( !r )
|
|
|
|
return path;
|
|
|
|
len = lstrlenW( tmp ) + 20;
|
2005-09-20 13:59:14 +02:00
|
|
|
path = msi_alloc( len * sizeof (WCHAR) );
|
2005-07-12 19:01:10 +02:00
|
|
|
if( path )
|
|
|
|
{
|
|
|
|
r = GetTempFileNameW( tmp, prefix, 0, path );
|
|
|
|
if (!r)
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( path );
|
2005-07-12 19:01:10 +02:00
|
|
|
path = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HANDLE msi_load_image( MSIDATABASE *db, LPCWSTR name, UINT type,
|
|
|
|
UINT cx, UINT cy, UINT flags )
|
|
|
|
{
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
HANDLE himage = NULL;
|
|
|
|
LPWSTR tmp;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("%p %s %u %u %08x\n", db, debugstr_w(name), cx, cy, flags);
|
|
|
|
|
|
|
|
tmp = msi_create_tmp_path();
|
|
|
|
if( !tmp )
|
|
|
|
return himage;
|
|
|
|
|
|
|
|
rec = msi_get_binary_record( db, name );
|
|
|
|
if( rec )
|
|
|
|
{
|
|
|
|
r = MSI_RecordStreamToFile( rec, 2, tmp );
|
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
himage = LoadImageW( 0, tmp, type, cx, cy, flags );
|
|
|
|
DeleteFileW( tmp );
|
|
|
|
}
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
}
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( tmp );
|
2005-07-12 19:01:10 +02:00
|
|
|
return himage;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HICON msi_load_icon( MSIDATABASE *db, LPCWSTR text, UINT attributes )
|
|
|
|
{
|
|
|
|
DWORD cx = 0, cy = 0, flags;
|
|
|
|
|
|
|
|
flags = LR_LOADFROMFILE | LR_DEFAULTSIZE;
|
|
|
|
if( attributes & msidbControlAttributesFixedSize )
|
|
|
|
{
|
|
|
|
flags &= ~LR_DEFAULTSIZE;
|
|
|
|
if( attributes & msidbControlAttributesIconSize16 )
|
|
|
|
{
|
|
|
|
cx += 16;
|
|
|
|
cy += 16;
|
|
|
|
}
|
|
|
|
if( attributes & msidbControlAttributesIconSize32 )
|
|
|
|
{
|
|
|
|
cx += 32;
|
|
|
|
cy += 32;
|
|
|
|
}
|
|
|
|
/* msidbControlAttributesIconSize48 handled by above logic */
|
|
|
|
}
|
|
|
|
return msi_load_image( db, text, IMAGE_ICON, cx, cy, flags );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-04 11:48:47 +02:00
|
|
|
/* called from the Control Event subscription code */
|
|
|
|
void msi_dialog_handle_event( msi_dialog* dialog, LPCWSTR control,
|
|
|
|
LPCWSTR attribute, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
msi_control* ctrl;
|
2006-01-11 12:12:16 +01:00
|
|
|
LPCWSTR font_text, text = NULL;
|
|
|
|
LPWSTR font;
|
2005-06-04 11:48:47 +02:00
|
|
|
|
|
|
|
ctrl = msi_dialog_find_control( dialog, control );
|
|
|
|
if (!ctrl)
|
|
|
|
return;
|
2006-01-23 11:55:19 +01:00
|
|
|
if( !lstrcmpW(attribute, szText) )
|
2005-09-28 17:12:10 +02:00
|
|
|
{
|
2006-01-23 11:55:19 +01:00
|
|
|
font_text = MSI_RecordGetString( rec , 1 );
|
|
|
|
font = msi_dialog_get_style( font_text, &text );
|
|
|
|
SetWindowTextW( ctrl->hwnd, text );
|
|
|
|
msi_free( font );
|
|
|
|
msi_dialog_check_messages( NULL );
|
|
|
|
}
|
|
|
|
else if( !lstrcmpW(attribute, szProgress) )
|
|
|
|
{
|
2006-06-09 10:05:50 +02:00
|
|
|
DWORD func, val;
|
|
|
|
|
|
|
|
func = MSI_RecordGetInteger( rec , 1 );
|
|
|
|
val = MSI_RecordGetInteger( rec , 2 );
|
|
|
|
|
|
|
|
switch (func)
|
|
|
|
{
|
|
|
|
case 0: /* init */
|
|
|
|
ctrl->progress_max = val;
|
|
|
|
ctrl->progress_current = 0;
|
|
|
|
SendMessageW(ctrl->hwnd, PBM_SETRANGE, 0, MAKELPARAM(0,100));
|
|
|
|
SendMessageW(ctrl->hwnd, PBM_SETPOS, 0, 0);
|
|
|
|
break;
|
|
|
|
case 1: /* FIXME: not sure what this is supposed to do */
|
|
|
|
break;
|
|
|
|
case 2: /* move */
|
|
|
|
ctrl->progress_current += val;
|
|
|
|
SendMessageW(ctrl->hwnd, PBM_SETPOS, 100*(ctrl->progress_current/ctrl->progress_max), 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown progress message %ld\n", func);
|
|
|
|
break;
|
|
|
|
}
|
2006-01-23 11:55:19 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Attribute %s not being set\n", debugstr_w(attribute));
|
2005-06-04 11:48:47 +02:00
|
|
|
return;
|
2005-09-28 17:12:10 +02:00
|
|
|
}
|
2005-06-04 11:48:47 +02:00
|
|
|
}
|
|
|
|
|
2005-06-06 17:40:15 +02:00
|
|
|
static void msi_dialog_map_events(msi_dialog* dialog, LPCWSTR control)
|
2005-06-04 11:48:47 +02:00
|
|
|
{
|
2006-01-24 14:00:32 +01:00
|
|
|
static const WCHAR Query[] = {
|
2005-06-04 11:48:47 +02:00
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','E','v','e','n','t','M','a','p','p','i','n','g','`',' ',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
|
|
|
|
'A','N','D',' ',
|
|
|
|
'`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',0
|
|
|
|
};
|
|
|
|
MSIRECORD *row;
|
|
|
|
LPCWSTR event, attribute;
|
|
|
|
|
|
|
|
row = MSI_QueryGetRecord( dialog->package->db, Query, dialog->name, control );
|
|
|
|
if (!row)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event = MSI_RecordGetString( row, 3 );
|
|
|
|
attribute = MSI_RecordGetString( row, 4 );
|
|
|
|
ControlEvent_SubscribeToEvent( dialog->package, event, control, attribute );
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
}
|
|
|
|
|
2005-03-24 16:09:31 +01:00
|
|
|
/* everything except radio buttons */
|
|
|
|
static msi_control *msi_dialog_add_control( msi_dialog *dialog,
|
|
|
|
MSIRECORD *rec, LPCWSTR szCls, DWORD style )
|
|
|
|
{
|
|
|
|
DWORD attributes;
|
|
|
|
LPCWSTR text, name;
|
2006-01-23 11:55:33 +01:00
|
|
|
DWORD exstyle = 0;
|
2005-03-24 16:09:31 +01:00
|
|
|
|
|
|
|
name = MSI_RecordGetString( rec, 2 );
|
|
|
|
attributes = MSI_RecordGetInteger( rec, 8 );
|
|
|
|
text = MSI_RecordGetString( rec, 10 );
|
2005-06-24 13:34:43 +02:00
|
|
|
if( attributes & msidbControlAttributesVisible )
|
2005-03-24 16:09:31 +01:00
|
|
|
style |= WS_VISIBLE;
|
2005-06-24 13:34:43 +02:00
|
|
|
if( ~attributes & msidbControlAttributesEnabled )
|
2005-03-24 16:09:31 +01:00
|
|
|
style |= WS_DISABLED;
|
2006-01-23 11:55:33 +01:00
|
|
|
if( attributes & msidbControlAttributesSunken )
|
|
|
|
exstyle |= WS_EX_CLIENTEDGE;
|
2005-06-04 11:48:47 +02:00
|
|
|
|
|
|
|
msi_dialog_map_events(dialog, name);
|
|
|
|
|
2006-01-23 11:55:33 +01:00
|
|
|
return msi_dialog_create_window( dialog, rec, exstyle, szCls, name,
|
|
|
|
text, style, dialog->hwnd );
|
2005-03-24 16:09:31 +01:00
|
|
|
}
|
|
|
|
|
2005-06-24 13:34:43 +02:00
|
|
|
struct msi_text_info
|
|
|
|
{
|
2006-06-27 11:04:16 +02:00
|
|
|
msi_font *font;
|
2005-06-24 13:34:43 +02:00
|
|
|
WNDPROC oldproc;
|
|
|
|
DWORD attributes;
|
|
|
|
};
|
|
|
|
|
2005-06-27 20:46:22 +02:00
|
|
|
/*
|
|
|
|
* we don't erase our own background,
|
|
|
|
* so we have to make sure that the parent window redraws first
|
|
|
|
*/
|
|
|
|
static void msi_text_on_settext( HWND hWnd )
|
|
|
|
{
|
|
|
|
HWND hParent;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
hParent = GetParent( hWnd );
|
|
|
|
GetWindowRect( hWnd, &rc );
|
|
|
|
MapWindowPoints( NULL, hParent, (LPPOINT) &rc, 2 );
|
|
|
|
InvalidateRect( hParent, &rc, TRUE );
|
|
|
|
}
|
|
|
|
|
2005-06-24 13:34:43 +02:00
|
|
|
static LRESULT WINAPI
|
|
|
|
MSIText_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct msi_text_info *info;
|
2005-06-27 20:46:22 +02:00
|
|
|
LRESULT r = 0;
|
2005-06-24 13:34:43 +02:00
|
|
|
|
|
|
|
TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
info = GetPropW(hWnd, szButtonData);
|
|
|
|
|
2006-06-27 11:04:16 +02:00
|
|
|
if ( info->font )
|
|
|
|
SetTextColor( (HDC)wParam, info->font->color );
|
|
|
|
|
2005-06-24 13:34:43 +02:00
|
|
|
if( msg == WM_CTLCOLORSTATIC &&
|
|
|
|
( info->attributes & msidbControlAttributesTransparent ) )
|
|
|
|
{
|
|
|
|
SetBkMode( (HDC)wParam, TRANSPARENT );
|
|
|
|
return (LRESULT) GetStockObject(NULL_BRUSH);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
switch( msg )
|
|
|
|
{
|
2005-06-27 20:46:22 +02:00
|
|
|
case WM_SETTEXT:
|
|
|
|
msi_text_on_settext( hWnd );
|
|
|
|
break;
|
2005-06-24 13:34:43 +02:00
|
|
|
case WM_NCDESTROY:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( info );
|
2005-06-24 13:34:43 +02:00
|
|
|
RemovePropW( hWnd, szButtonData );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_text_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
2005-06-24 13:34:43 +02:00
|
|
|
msi_control *control;
|
|
|
|
struct msi_text_info *info;
|
2006-06-27 11:04:16 +02:00
|
|
|
LPCWSTR text, ptr;
|
|
|
|
LPWSTR font_name;
|
2005-06-24 13:34:43 +02:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
TRACE("%p %p\n", dialog, rec);
|
|
|
|
|
2005-06-24 13:34:43 +02:00
|
|
|
control = msi_dialog_add_control( dialog, rec, szStatic, SS_LEFT | WS_GROUP );
|
|
|
|
if( !control )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
info = msi_alloc( sizeof *info );
|
2005-06-24 13:34:43 +02:00
|
|
|
if( !info )
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2006-06-27 11:04:16 +02:00
|
|
|
text = MSI_RecordGetString( rec, 10 );
|
|
|
|
font_name = msi_dialog_get_style( text, &ptr );
|
|
|
|
info->font = ( font_name ) ? msi_dialog_find_font( dialog, font_name ) : NULL;
|
|
|
|
msi_free( font_name );
|
|
|
|
|
2005-06-24 13:34:43 +02:00
|
|
|
info->attributes = MSI_RecordGetInteger( rec, 8 );
|
|
|
|
if( info->attributes & msidbControlAttributesTransparent )
|
|
|
|
SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT );
|
|
|
|
|
|
|
|
info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)MSIText_WndProc );
|
|
|
|
SetPropW( control->hwnd, szButtonData, info );
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_control *control;
|
2005-07-12 19:01:10 +02:00
|
|
|
UINT attributes, style;
|
2005-09-16 21:01:18 +02:00
|
|
|
LPWSTR text;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
TRACE("%p %p\n", dialog, rec);
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-07-12 19:01:10 +02:00
|
|
|
style = WS_TABSTOP;
|
|
|
|
attributes = MSI_RecordGetInteger( rec, 8 );
|
|
|
|
if( attributes & msidbControlAttributesIcon )
|
|
|
|
style |= BS_ICON;
|
|
|
|
|
|
|
|
control = msi_dialog_add_control( dialog, rec, szButton, style );
|
|
|
|
if( !control )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
control->handler = msi_dialog_button_handler;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-07-12 19:01:10 +02:00
|
|
|
/* set the icon */
|
2005-09-16 21:01:18 +02:00
|
|
|
text = msi_get_deformatted_field( dialog->package, rec, 10 );
|
2005-07-12 19:01:10 +02:00
|
|
|
control->hIcon = msi_load_icon( dialog->package->db, text, attributes );
|
|
|
|
if( attributes & msidbControlAttributesIcon )
|
|
|
|
SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( text );
|
2005-07-12 19:01:10 +02:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-06-01 21:48:48 +02:00
|
|
|
static LPWSTR msi_get_checkbox_value( msi_dialog *dialog, LPCWSTR prop )
|
|
|
|
{
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR query[] = {
|
2005-06-01 21:48:48 +02:00
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','`','C','h','e','c','k','B','o','x',' ','`',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','P','r','o','p','e','r','t','y','`',' ','=',' ',
|
|
|
|
'\'','%','s','\'',0
|
|
|
|
};
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
LPWSTR ret = NULL;
|
|
|
|
|
|
|
|
/* find if there is a value associated with the checkbox */
|
2005-06-02 12:29:28 +02:00
|
|
|
rec = MSI_QueryGetRecord( dialog->package->db, query, prop );
|
2005-06-01 21:48:48 +02:00
|
|
|
if (!rec)
|
|
|
|
return ret;
|
|
|
|
|
2005-09-23 12:05:23 +02:00
|
|
|
ret = msi_get_deformatted_field( dialog->package, rec, 2 );
|
|
|
|
if( ret && !ret[0] )
|
2005-06-01 21:48:48 +02:00
|
|
|
{
|
2005-09-23 12:05:23 +02:00
|
|
|
msi_free( ret );
|
|
|
|
ret = NULL;
|
2005-06-01 21:48:48 +02:00
|
|
|
}
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2005-09-15 17:04:08 +02:00
|
|
|
ret = msi_dup_property( dialog->package, prop );
|
2005-06-01 21:48:48 +02:00
|
|
|
if( ret && !ret[0] )
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( ret );
|
2005-06-01 21:48:48 +02:00
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_checkbox_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
2005-02-03 11:41:59 +01:00
|
|
|
LPCWSTR prop;
|
2005-02-02 10:55:51 +01:00
|
|
|
|
|
|
|
TRACE("%p %p\n", dialog, rec);
|
|
|
|
|
|
|
|
control = msi_dialog_add_control( dialog, rec, szButton,
|
2005-06-20 16:11:43 +02:00
|
|
|
BS_CHECKBOX | BS_MULTILINE | WS_TABSTOP );
|
2005-02-09 14:24:31 +01:00
|
|
|
control->handler = msi_dialog_checkbox_handler;
|
2005-02-03 11:41:59 +01:00
|
|
|
prop = MSI_RecordGetString( rec, 9 );
|
|
|
|
if( prop )
|
2005-06-01 21:48:48 +02:00
|
|
|
{
|
2005-03-16 12:31:35 +01:00
|
|
|
control->property = strdupW( prop );
|
2005-06-01 21:48:48 +02:00
|
|
|
control->value = msi_get_checkbox_value( dialog, prop );
|
|
|
|
TRACE("control %s value %s\n", debugstr_w(control->property),
|
|
|
|
debugstr_w(control->value));
|
|
|
|
}
|
2005-02-03 11:41:59 +01:00
|
|
|
msi_dialog_checkbox_sync_state( dialog, control );
|
2005-02-02 10:55:51 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2005-01-28 13:39:57 +01:00
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_line_control( msi_dialog *dialog, MSIRECORD *rec )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
TRACE("%p %p\n", dialog, rec);
|
|
|
|
|
|
|
|
msi_dialog_add_control( dialog, rec, szStatic, SS_ETCHEDHORZ | SS_SUNKEN );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-01-03 12:15:04 +01:00
|
|
|
/******************** Scroll Text ********************************************/
|
|
|
|
|
|
|
|
struct msi_scrolltext_info
|
|
|
|
{
|
|
|
|
msi_dialog *dialog;
|
|
|
|
msi_control *control;
|
|
|
|
WNDPROC oldproc;
|
|
|
|
};
|
|
|
|
|
|
|
|
static LRESULT WINAPI
|
|
|
|
MSIScrollText_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct msi_scrolltext_info *info;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
info = GetPropW( hWnd, szButtonData );
|
|
|
|
|
|
|
|
r = CallWindowProcW( info->oldproc, hWnd, msg, wParam, lParam );
|
|
|
|
|
|
|
|
switch( msg )
|
|
|
|
{
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
msi_free( info );
|
|
|
|
RemovePropW( hWnd, szButtonData );
|
|
|
|
break;
|
2006-01-06 12:19:33 +01:00
|
|
|
case WM_PAINT:
|
|
|
|
/* native MSI sets a wait cursor here */
|
2006-01-03 12:15:04 +01:00
|
|
|
msi_dialog_button_handler( info->dialog, info->control, BN_CLICKED );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-06-07 22:30:02 +02:00
|
|
|
struct msi_streamin_info
|
|
|
|
{
|
|
|
|
LPSTR string;
|
|
|
|
DWORD offset;
|
|
|
|
DWORD length;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD CALLBACK
|
|
|
|
msi_richedit_stream_in( DWORD_PTR arg, LPBYTE buffer, LONG count, LONG *pcb )
|
|
|
|
{
|
|
|
|
struct msi_streamin_info *info = (struct msi_streamin_info*) arg;
|
|
|
|
|
|
|
|
if( (count + info->offset) > info->length )
|
|
|
|
count = info->length - info->offset;
|
|
|
|
memcpy( buffer, &info->string[ info->offset ], count );
|
|
|
|
*pcb = count;
|
|
|
|
info->offset += count;
|
|
|
|
|
|
|
|
TRACE("%ld/%ld\n", info->offset, info->length);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-03 12:15:04 +01:00
|
|
|
static void msi_scrolltext_add_text( msi_control *control, LPCWSTR text )
|
|
|
|
{
|
|
|
|
struct msi_streamin_info info;
|
|
|
|
EDITSTREAM es;
|
|
|
|
|
|
|
|
info.string = strdupWtoA( text );
|
|
|
|
info.offset = 0;
|
|
|
|
info.length = lstrlenA( info.string ) + 1;
|
|
|
|
|
|
|
|
es.dwCookie = (DWORD_PTR) &info;
|
|
|
|
es.dwError = 0;
|
|
|
|
es.pfnCallback = msi_richedit_stream_in;
|
|
|
|
|
|
|
|
SendMessageW( control->hwnd, EM_STREAMIN, SF_RTF, (LPARAM) &es );
|
|
|
|
|
|
|
|
msi_free( info.string );
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_scrolltext_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRichEdit20W[] = {
|
2005-06-17 22:54:42 +02:00
|
|
|
'R','i','c','h','E','d','i','t','2','0','W',0
|
|
|
|
};
|
2006-01-03 12:15:04 +01:00
|
|
|
struct msi_scrolltext_info *info;
|
2005-06-07 22:30:02 +02:00
|
|
|
msi_control *control;
|
2006-01-06 12:35:09 +01:00
|
|
|
HMODULE hRichedit;
|
2005-06-07 22:30:02 +02:00
|
|
|
DWORD style;
|
2005-09-16 20:45:33 +02:00
|
|
|
|
2006-01-03 12:15:04 +01:00
|
|
|
info = msi_alloc( sizeof *info );
|
|
|
|
if (!info)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2006-01-06 12:35:09 +01:00
|
|
|
hRichedit = LoadLibraryA("riched20");
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-06-20 16:11:43 +02:00
|
|
|
style = WS_BORDER | ES_MULTILINE | WS_VSCROLL |
|
|
|
|
ES_READONLY | ES_AUTOVSCROLL | WS_TABSTOP;
|
2005-06-17 22:54:42 +02:00
|
|
|
control = msi_dialog_add_control( dialog, rec, szRichEdit20W, style );
|
2005-09-16 20:45:33 +02:00
|
|
|
if (!control)
|
2006-01-03 12:15:04 +01:00
|
|
|
{
|
2006-01-06 12:35:09 +01:00
|
|
|
FreeLibrary( hRichedit );
|
2006-01-03 12:15:04 +01:00
|
|
|
msi_free( info );
|
2005-09-16 20:45:33 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2006-01-03 12:15:04 +01:00
|
|
|
}
|
2005-09-16 20:45:33 +02:00
|
|
|
|
2006-01-06 12:35:09 +01:00
|
|
|
control->hDll = hRichedit;
|
|
|
|
|
2006-01-03 12:15:04 +01:00
|
|
|
info->dialog = dialog;
|
|
|
|
info->control = control;
|
2005-06-07 22:30:02 +02:00
|
|
|
|
2006-01-03 12:15:04 +01:00
|
|
|
/* subclass the static control */
|
|
|
|
info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)MSIScrollText_WndProc );
|
|
|
|
SetPropW( control->hwnd, szButtonData, info );
|
2005-06-07 22:30:02 +02:00
|
|
|
|
2006-01-03 12:15:04 +01:00
|
|
|
/* add the text into the richedit */
|
|
|
|
msi_scrolltext_add_text( control, MSI_RecordGetString( rec, 10 ) );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-10-26 12:10:34 +02:00
|
|
|
static HBITMAP msi_load_picture( MSIDATABASE *db, LPCWSTR name,
|
|
|
|
INT cx, INT cy, DWORD flags )
|
|
|
|
{
|
|
|
|
HBITMAP hOleBitmap = 0, hBitmap = 0, hOldSrcBitmap, hOldDestBitmap;
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
IStream *stm = NULL;
|
|
|
|
IPicture *pic = NULL;
|
|
|
|
HDC srcdc, destdc;
|
|
|
|
BITMAP bm;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
rec = msi_get_binary_record( db, name );
|
|
|
|
if( !rec )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = MSI_RecordGetIStream( rec, 2, &stm );
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = OleLoadPicture( stm, 0, TRUE, &IID_IPicture, (LPVOID*) &pic );
|
|
|
|
IStream_Release( stm );
|
|
|
|
if( FAILED( r ) )
|
|
|
|
{
|
|
|
|
ERR("failed to load picture\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IPicture_get_Handle( pic, (OLE_HANDLE*) &hOleBitmap );
|
|
|
|
if( FAILED( r ) )
|
|
|
|
{
|
|
|
|
ERR("failed to get bitmap handle\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make the bitmap the desired size */
|
|
|
|
r = GetObjectW( hOleBitmap, sizeof bm, &bm );
|
|
|
|
if (r != sizeof bm )
|
|
|
|
{
|
|
|
|
ERR("failed to get bitmap size\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & LR_DEFAULTSIZE)
|
|
|
|
{
|
|
|
|
cx = bm.bmWidth;
|
|
|
|
cy = bm.bmHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
srcdc = CreateCompatibleDC( NULL );
|
|
|
|
hOldSrcBitmap = SelectObject( srcdc, hOleBitmap );
|
|
|
|
destdc = CreateCompatibleDC( NULL );
|
|
|
|
hBitmap = CreateCompatibleBitmap( srcdc, cx, cy );
|
|
|
|
hOldDestBitmap = SelectObject( destdc, hBitmap );
|
|
|
|
StretchBlt( destdc, 0, 0, cx, cy,
|
|
|
|
srcdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
|
|
SelectObject( srcdc, hOldSrcBitmap );
|
|
|
|
SelectObject( destdc, hOldDestBitmap );
|
|
|
|
DeleteDC( srcdc );
|
|
|
|
DeleteDC( destdc );
|
|
|
|
|
|
|
|
end:
|
|
|
|
if ( pic )
|
|
|
|
IPicture_Release( pic );
|
|
|
|
return hBitmap;
|
|
|
|
}
|
|
|
|
|
2005-07-07 19:20:57 +02:00
|
|
|
static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
UINT cx, cy, flags, style, attributes;
|
|
|
|
msi_control *control;
|
2005-09-16 21:01:18 +02:00
|
|
|
LPWSTR text;
|
2005-07-07 19:20:57 +02:00
|
|
|
|
|
|
|
flags = LR_LOADFROMFILE;
|
|
|
|
style = SS_BITMAP | SS_LEFT | WS_GROUP;
|
|
|
|
|
|
|
|
attributes = MSI_RecordGetInteger( rec, 8 );
|
|
|
|
if( attributes & msidbControlAttributesFixedSize )
|
|
|
|
{
|
|
|
|
flags |= LR_DEFAULTSIZE;
|
|
|
|
style |= SS_CENTERIMAGE;
|
2005-07-12 19:01:10 +02:00
|
|
|
}
|
2005-07-07 19:20:57 +02:00
|
|
|
|
|
|
|
control = msi_dialog_add_control( dialog, rec, szStatic, style );
|
|
|
|
cx = MSI_RecordGetInteger( rec, 6 );
|
|
|
|
cy = MSI_RecordGetInteger( rec, 7 );
|
|
|
|
cx = msi_dialog_scale_unit( dialog, cx );
|
|
|
|
cy = msi_dialog_scale_unit( dialog, cy );
|
|
|
|
|
2005-09-16 21:01:18 +02:00
|
|
|
text = msi_get_deformatted_field( dialog->package, rec, 10 );
|
2005-10-26 12:10:34 +02:00
|
|
|
control->hBitmap = msi_load_picture( dialog->package->db, text, cx, cy, flags );
|
2005-07-07 19:20:57 +02:00
|
|
|
if( control->hBitmap )
|
|
|
|
SendMessageW( control->hwnd, STM_SETIMAGE,
|
|
|
|
IMAGE_BITMAP, (LPARAM) control->hBitmap );
|
|
|
|
else
|
|
|
|
ERR("Failed to load bitmap %s\n", debugstr_w(text));
|
2005-09-16 21:01:18 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( text );
|
2005-07-07 19:20:57 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2005-06-23 18:43:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
2005-07-12 19:01:10 +02:00
|
|
|
DWORD attributes;
|
2005-09-16 21:01:18 +02:00
|
|
|
LPWSTR text;
|
2005-06-23 18:43:38 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
control = msi_dialog_add_control( dialog, rec, szStatic,
|
|
|
|
SS_ICON | SS_CENTERIMAGE | WS_GROUP );
|
2005-07-07 19:20:57 +02:00
|
|
|
|
2005-06-23 18:43:38 +02:00
|
|
|
attributes = MSI_RecordGetInteger( rec, 8 );
|
2005-09-16 21:01:18 +02:00
|
|
|
text = msi_get_deformatted_field( dialog->package, rec, 10 );
|
2005-07-12 19:01:10 +02:00
|
|
|
control->hIcon = msi_load_icon( dialog->package->db, text, attributes );
|
2005-07-07 19:20:57 +02:00
|
|
|
if( control->hIcon )
|
|
|
|
SendMessageW( control->hwnd, STM_SETICON, (WPARAM) control->hIcon, 0 );
|
2005-06-23 18:43:38 +02:00
|
|
|
else
|
|
|
|
ERR("Failed to load bitmap %s\n", debugstr_w(text));
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( text );
|
2005-06-23 18:43:38 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
static UINT msi_dialog_combo_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
static const WCHAR szCombo[] = { 'C','O','M','B','O','B','O','X',0 };
|
|
|
|
|
|
|
|
msi_dialog_add_control( dialog, rec, szCombo,
|
|
|
|
SS_BITMAP | SS_LEFT | SS_CENTERIMAGE );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_edit_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
|
|
|
LPCWSTR prop;
|
|
|
|
LPWSTR val;
|
|
|
|
|
2005-06-20 16:11:43 +02:00
|
|
|
control = msi_dialog_add_control( dialog, rec, szEdit,
|
|
|
|
WS_BORDER | WS_TABSTOP );
|
2005-02-09 14:24:31 +01:00
|
|
|
control->handler = msi_dialog_edit_handler;
|
|
|
|
prop = MSI_RecordGetString( rec, 9 );
|
|
|
|
if( prop )
|
2005-03-16 12:31:35 +01:00
|
|
|
control->property = strdupW( prop );
|
2005-09-15 17:04:08 +02:00
|
|
|
val = msi_dup_property( dialog->package, control->property );
|
2005-02-09 14:24:31 +01:00
|
|
|
SetWindowTextW( control->hwnd, val );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( val );
|
2005-02-09 14:24:31 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:37:53 +02:00
|
|
|
/******************** Masked Edit ********************************************/
|
|
|
|
|
|
|
|
#define MASK_MAX_GROUPS 10
|
|
|
|
|
|
|
|
struct msi_mask_group
|
|
|
|
{
|
|
|
|
UINT len;
|
|
|
|
UINT ofs;
|
|
|
|
WCHAR type;
|
|
|
|
HWND hwnd;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct msi_maskedit_info
|
|
|
|
{
|
|
|
|
msi_dialog *dialog;
|
|
|
|
WNDPROC oldproc;
|
|
|
|
HWND hwnd;
|
|
|
|
LPWSTR prop;
|
|
|
|
UINT num_chars;
|
|
|
|
UINT num_groups;
|
|
|
|
struct msi_mask_group group[MASK_MAX_GROUPS];
|
|
|
|
};
|
|
|
|
|
2005-10-30 20:16:55 +01:00
|
|
|
static BOOL msi_mask_editable( WCHAR type )
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case '%':
|
|
|
|
case '#':
|
|
|
|
case '&':
|
|
|
|
case '`':
|
|
|
|
case '?':
|
2005-11-28 10:36:54 +01:00
|
|
|
case '^':
|
2005-10-30 20:16:55 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:37:53 +02:00
|
|
|
static void msi_mask_control_change( struct msi_maskedit_info *info )
|
|
|
|
{
|
|
|
|
LPWSTR val;
|
|
|
|
UINT i, n, r;
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
val = msi_alloc( (info->num_chars+1)*sizeof(WCHAR) );
|
2005-06-16 22:37:53 +02:00
|
|
|
for( i=0, n=0; i<info->num_groups; i++ )
|
|
|
|
{
|
|
|
|
if( (info->group[i].len + n) > info->num_chars )
|
|
|
|
{
|
|
|
|
ERR("can't fit control %d text into template\n",i);
|
|
|
|
break;
|
|
|
|
}
|
2005-10-30 20:16:55 +01:00
|
|
|
if (!msi_mask_editable(info->group[i].type))
|
|
|
|
{
|
|
|
|
for(r=0; r<info->group[i].len; r++)
|
|
|
|
val[n+r] = info->group[i].type;
|
|
|
|
val[n+r] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = GetWindowTextW( info->group[i].hwnd, &val[n], info->group[i].len+1 );
|
|
|
|
if( r != info->group[i].len )
|
|
|
|
break;
|
|
|
|
}
|
2005-06-16 22:37:53 +02:00
|
|
|
n += r;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("%d/%d controls were good\n", i, info->num_groups);
|
|
|
|
|
|
|
|
if( i == info->num_groups )
|
|
|
|
{
|
|
|
|
TRACE("Set property %s to %s\n",
|
|
|
|
debugstr_w(info->prop), debugstr_w(val) );
|
|
|
|
CharUpperBuffW( val, info->num_chars );
|
|
|
|
MSI_SetPropertyW( info->dialog->package, info->prop, val );
|
|
|
|
msi_dialog_evaluate_control_conditions( info->dialog );
|
|
|
|
}
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( val );
|
2005-06-16 22:37:53 +02:00
|
|
|
}
|
|
|
|
|
2005-06-30 12:59:40 +02:00
|
|
|
/* now move to the next control if necessary */
|
|
|
|
static VOID msi_mask_next_control( struct msi_maskedit_info *info, HWND hWnd )
|
|
|
|
{
|
|
|
|
HWND hWndNext;
|
|
|
|
UINT len, i;
|
|
|
|
|
|
|
|
for( i=0; i<info->num_groups; i++ )
|
|
|
|
if( info->group[i].hwnd == hWnd )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* don't move from the last control */
|
|
|
|
if( i >= (info->num_groups-1) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
len = SendMessageW( hWnd, WM_GETTEXTLENGTH, 0, 0 );
|
|
|
|
if( len < info->group[i].len )
|
|
|
|
return;
|
|
|
|
|
|
|
|
hWndNext = GetNextDlgTabItem( GetParent( hWnd ), hWnd, FALSE );
|
|
|
|
SetFocus( hWndNext );
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:37:53 +02:00
|
|
|
static LRESULT WINAPI
|
|
|
|
MSIMaskedEdit_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct msi_maskedit_info *info;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
info = GetPropW(hWnd, szButtonData);
|
|
|
|
|
|
|
|
r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
switch( msg )
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
2005-06-30 12:59:40 +02:00
|
|
|
{
|
2005-06-16 22:37:53 +02:00
|
|
|
msi_mask_control_change( info );
|
2005-06-30 12:59:40 +02:00
|
|
|
msi_mask_next_control( info, (HWND) lParam );
|
|
|
|
}
|
2005-06-16 22:37:53 +02:00
|
|
|
break;
|
|
|
|
case WM_NCDESTROY:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( info->prop );
|
|
|
|
msi_free( info );
|
2005-06-16 22:37:53 +02:00
|
|
|
RemovePropW( hWnd, szButtonData );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fish the various bits of the property out and put them in the control */
|
|
|
|
static void
|
|
|
|
msi_maskedit_set_text( struct msi_maskedit_info *info, LPCWSTR text )
|
|
|
|
{
|
|
|
|
LPCWSTR p;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
p = text;
|
|
|
|
for( i = 0; i < info->num_groups; i++ )
|
|
|
|
{
|
|
|
|
if( info->group[i].len < lstrlenW( p ) )
|
|
|
|
{
|
|
|
|
LPWSTR chunk = strdupW( p );
|
|
|
|
chunk[ info->group[i].len ] = 0;
|
|
|
|
SetWindowTextW( info->group[i].hwnd, chunk );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( chunk );
|
2005-06-16 22:37:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetWindowTextW( info->group[i].hwnd, p );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p += info->group[i].len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct msi_maskedit_info * msi_dialog_parse_groups( LPCWSTR mask )
|
|
|
|
{
|
|
|
|
struct msi_maskedit_info * info = NULL;
|
|
|
|
int i = 0, n = 0, total = 0;
|
|
|
|
LPCWSTR p;
|
|
|
|
|
|
|
|
TRACE("masked control, template %s\n", debugstr_w(mask));
|
|
|
|
|
|
|
|
if( !mask )
|
|
|
|
return info;
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
info = msi_alloc_zero( sizeof *info );
|
2005-06-16 22:37:53 +02:00
|
|
|
if( !info )
|
|
|
|
return info;
|
|
|
|
|
2006-01-04 14:49:50 +01:00
|
|
|
p = strchrW(mask, '<');
|
|
|
|
if( p )
|
|
|
|
p++;
|
|
|
|
else
|
|
|
|
p = mask;
|
|
|
|
|
2005-06-16 22:37:53 +02:00
|
|
|
for( i=0; i<MASK_MAX_GROUPS; i++ )
|
|
|
|
{
|
|
|
|
/* stop at the end of the string */
|
|
|
|
if( p[0] == 0 || p[0] == '>' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* count the number of the same identifier */
|
|
|
|
for( n=0; p[n] == p[0]; n++ )
|
|
|
|
;
|
|
|
|
info->group[i].ofs = total;
|
|
|
|
info->group[i].type = p[0];
|
|
|
|
if( p[n] == '=' )
|
|
|
|
{
|
|
|
|
n++;
|
|
|
|
total++; /* an extra not part of the group */
|
|
|
|
}
|
|
|
|
info->group[i].len = n;
|
|
|
|
total += n;
|
|
|
|
p += n;
|
|
|
|
}
|
|
|
|
|
2005-09-13 12:33:04 +02:00
|
|
|
TRACE("%d characters in %d groups\n", total, i );
|
2005-06-16 22:37:53 +02:00
|
|
|
if( i == MASK_MAX_GROUPS )
|
|
|
|
ERR("too many groups in PIDTemplate %s\n", debugstr_w(mask));
|
|
|
|
|
|
|
|
info->num_chars = total;
|
|
|
|
info->num_groups = i;
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-09-17 16:29:29 +02:00
|
|
|
msi_maskedit_create_children( struct msi_maskedit_info *info, LPCWSTR font )
|
2005-06-16 22:37:53 +02:00
|
|
|
{
|
|
|
|
DWORD width, height, style, wx, ww;
|
|
|
|
RECT rect;
|
|
|
|
HWND hwnd;
|
|
|
|
UINT i;
|
|
|
|
|
2006-01-04 14:49:50 +01:00
|
|
|
style = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL;
|
2005-06-16 22:37:53 +02:00
|
|
|
|
|
|
|
GetClientRect( info->hwnd, &rect );
|
|
|
|
|
|
|
|
width = rect.right - rect.left;
|
|
|
|
height = rect.bottom - rect.top;
|
|
|
|
|
|
|
|
for( i = 0; i < info->num_groups; i++ )
|
|
|
|
{
|
2005-10-30 20:16:55 +01:00
|
|
|
if (!msi_mask_editable( info->group[i].type ))
|
|
|
|
continue;
|
2005-06-16 22:37:53 +02:00
|
|
|
wx = (info->group[i].ofs * width) / info->num_chars;
|
|
|
|
ww = (info->group[i].len * width) / info->num_chars;
|
|
|
|
|
|
|
|
hwnd = CreateWindowW( szEdit, NULL, style, wx, 0, ww, height,
|
|
|
|
info->hwnd, NULL, NULL, NULL );
|
|
|
|
if( !hwnd )
|
|
|
|
{
|
|
|
|
ERR("failed to create mask edit sub window\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SendMessageW( hwnd, EM_LIMITTEXT, info->group[i].len, 0 );
|
|
|
|
|
2005-09-17 16:29:29 +02:00
|
|
|
msi_dialog_set_font( info->dialog, hwnd,
|
|
|
|
font?font:info->dialog->default_font );
|
2005-06-16 22:37:53 +02:00
|
|
|
info->group[i].hwnd = hwnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-30 20:16:55 +01:00
|
|
|
/*
|
|
|
|
* office 2003 uses "73931<````=````=````=````=`````>@@@@@"
|
|
|
|
* delphi 7 uses "<????-??????-??????-????>" and "<???-???>"
|
2005-11-28 10:36:54 +01:00
|
|
|
* filemaker pro 7 uses "<^^^^=^^^^=^^^^=^^^^=^^^^=^^^^=^^^^^>"
|
2005-10-30 20:16:55 +01:00
|
|
|
*/
|
2005-06-16 22:37:53 +02:00
|
|
|
static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
2005-09-21 12:19:42 +02:00
|
|
|
LPWSTR font_mask, val = NULL, font;
|
2005-06-16 22:37:53 +02:00
|
|
|
struct msi_maskedit_info *info = NULL;
|
|
|
|
UINT ret = ERROR_SUCCESS;
|
|
|
|
msi_control *control;
|
2005-09-21 12:19:42 +02:00
|
|
|
LPCWSTR prop, mask;
|
2005-06-16 22:37:53 +02:00
|
|
|
|
2005-09-17 16:29:29 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
2005-09-21 12:19:42 +02:00
|
|
|
font_mask = msi_get_deformatted_field( dialog->package, rec, 10 );
|
|
|
|
font = msi_dialog_get_style( font_mask, &mask );
|
2005-06-16 22:37:53 +02:00
|
|
|
if( !mask )
|
|
|
|
{
|
2005-09-17 16:29:29 +02:00
|
|
|
ERR("mask template is empty\n");
|
2005-06-16 22:37:53 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = msi_dialog_parse_groups( mask );
|
|
|
|
if( !info )
|
|
|
|
{
|
|
|
|
ERR("template %s is invalid\n", debugstr_w(mask));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->dialog = dialog;
|
|
|
|
|
2005-06-20 16:11:43 +02:00
|
|
|
control = msi_dialog_add_control( dialog, rec, szStatic,
|
|
|
|
SS_OWNERDRAW | WS_GROUP | WS_VISIBLE );
|
2005-06-16 22:37:53 +02:00
|
|
|
if( !control )
|
|
|
|
{
|
|
|
|
ERR("Failed to create maskedit container\n");
|
|
|
|
ret = ERROR_FUNCTION_FAILED;
|
|
|
|
goto end;
|
|
|
|
}
|
2005-06-20 16:11:43 +02:00
|
|
|
SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
|
2005-06-16 22:37:53 +02:00
|
|
|
|
|
|
|
info->hwnd = control->hwnd;
|
|
|
|
|
|
|
|
/* subclass the static control */
|
|
|
|
info->oldproc = (WNDPROC) SetWindowLongPtrW( info->hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)MSIMaskedEdit_WndProc );
|
|
|
|
SetPropW( control->hwnd, szButtonData, info );
|
|
|
|
|
|
|
|
prop = MSI_RecordGetString( rec, 9 );
|
|
|
|
if( prop )
|
|
|
|
info->prop = strdupW( prop );
|
|
|
|
|
2005-09-17 16:29:29 +02:00
|
|
|
msi_maskedit_create_children( info, font );
|
2005-06-16 22:37:53 +02:00
|
|
|
|
|
|
|
if( prop )
|
|
|
|
{
|
2005-09-15 17:04:08 +02:00
|
|
|
val = msi_dup_property( dialog->package, prop );
|
2005-06-16 22:37:53 +02:00
|
|
|
if( val )
|
|
|
|
{
|
|
|
|
msi_maskedit_set_text( info, val );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( val );
|
2005-06-16 22:37:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
if( ret != ERROR_SUCCESS )
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( info );
|
2005-09-21 12:19:42 +02:00
|
|
|
msi_free( font_mask );
|
|
|
|
msi_free( font );
|
2005-06-16 22:37:53 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-09-28 17:12:10 +02:00
|
|
|
/******************** Progress Bar *****************************************/
|
|
|
|
|
|
|
|
static UINT msi_dialog_progress_bar( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
msi_dialog_add_control( dialog, rec, PROGRESS_CLASSW, WS_VISIBLE );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:37:53 +02:00
|
|
|
/******************** Path Edit ********************************************/
|
|
|
|
|
2005-02-16 17:25:36 +01:00
|
|
|
static UINT msi_dialog_pathedit_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
FIXME("not implemented properly\n");
|
|
|
|
return msi_dialog_edit_control( dialog, rec );
|
|
|
|
}
|
|
|
|
|
2005-03-30 19:08:31 +02:00
|
|
|
/* radio buttons are a bit different from normal controls */
|
2005-03-04 13:32:08 +01:00
|
|
|
static UINT msi_dialog_create_radiobutton( MSIRECORD *rec, LPVOID param )
|
2005-02-16 17:25:36 +01:00
|
|
|
{
|
2005-03-04 13:32:08 +01:00
|
|
|
radio_button_group_descr *group = (radio_button_group_descr *)param;
|
|
|
|
msi_dialog *dialog = group->dialog;
|
|
|
|
msi_control *control;
|
2005-03-24 16:09:31 +01:00
|
|
|
LPCWSTR prop, text, name;
|
2005-09-16 21:01:18 +02:00
|
|
|
DWORD style, attributes = group->attributes;
|
2005-03-04 13:32:08 +01:00
|
|
|
|
2005-06-20 16:11:43 +02:00
|
|
|
style = WS_CHILD | BS_AUTORADIOBUTTON | BS_MULTILINE | WS_TABSTOP;
|
2005-03-04 13:32:08 +01:00
|
|
|
name = MSI_RecordGetString( rec, 3 );
|
|
|
|
text = MSI_RecordGetString( rec, 8 );
|
|
|
|
if( attributes & 1 )
|
|
|
|
style |= WS_VISIBLE;
|
|
|
|
if( ~attributes & 2 )
|
|
|
|
style |= WS_DISABLED;
|
|
|
|
|
2006-01-23 11:55:33 +01:00
|
|
|
control = msi_dialog_create_window( dialog, rec, 0, szButton, name, text,
|
2005-03-24 16:09:31 +01:00
|
|
|
style, group->parent->hwnd );
|
2005-09-16 21:01:18 +02:00
|
|
|
if (!control)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-04 13:32:08 +01:00
|
|
|
control->handler = msi_dialog_radiogroup_handler;
|
|
|
|
|
2006-05-24 10:41:17 +02:00
|
|
|
if (!lstrcmpW(control->name, group->propval))
|
|
|
|
SendMessageW(control->hwnd, BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
|
2005-03-04 13:32:08 +01:00
|
|
|
prop = MSI_RecordGetString( rec, 1 );
|
|
|
|
if( prop )
|
2005-03-16 12:31:35 +01:00
|
|
|
control->property = strdupW( prop );
|
2005-02-16 17:25:36 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-03-04 13:32:08 +01:00
|
|
|
static UINT msi_dialog_radiogroup_control( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','R','a','d','i','o','B','u','t','t','o','n',' ',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
|
|
|
|
UINT r;
|
|
|
|
LPCWSTR prop;
|
|
|
|
msi_control *control;
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
radio_button_group_descr group;
|
|
|
|
MSIPACKAGE *package = dialog->package;
|
2005-06-07 22:04:21 +02:00
|
|
|
WNDPROC oldproc;
|
2005-03-04 13:32:08 +01:00
|
|
|
|
|
|
|
prop = MSI_RecordGetString( rec, 9 );
|
|
|
|
|
|
|
|
TRACE("%p %p %s\n", dialog, rec, debugstr_w( prop ));
|
|
|
|
|
|
|
|
/* Create parent group box to hold radio buttons */
|
2005-06-07 22:04:21 +02:00
|
|
|
control = msi_dialog_add_control( dialog, rec, szButton, BS_OWNERDRAW|WS_GROUP );
|
|
|
|
if( !control )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-04 13:32:08 +01:00
|
|
|
|
2005-06-07 22:04:21 +02:00
|
|
|
oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)MSIRadioGroup_WndProc );
|
|
|
|
SetPropW(control->hwnd, szButtonData, oldproc);
|
2005-06-20 16:11:43 +02:00
|
|
|
SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
|
2005-03-04 13:32:08 +01:00
|
|
|
|
|
|
|
if( prop )
|
2005-03-16 12:31:35 +01:00
|
|
|
control->property = strdupW( prop );
|
2005-03-04 13:32:08 +01:00
|
|
|
|
|
|
|
/* query the Radio Button table for all control in this group */
|
|
|
|
r = MSI_OpenQuery( package->db, &view, query, prop );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
ERR("query failed for dialog %s radio group %s\n",
|
|
|
|
debugstr_w(dialog->name), debugstr_w(prop));
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
group.dialog = dialog;
|
|
|
|
group.parent = control;
|
|
|
|
group.attributes = MSI_RecordGetInteger( rec, 8 );
|
2006-05-24 10:41:17 +02:00
|
|
|
group.propval = msi_dup_property( dialog->package, control->property );
|
2005-03-04 13:32:08 +01:00
|
|
|
|
|
|
|
r = MSI_IterateRecords( view, 0, msi_dialog_create_radiobutton, &group );
|
|
|
|
msiobj_release( &view->hdr );
|
2006-05-24 10:41:17 +02:00
|
|
|
msi_free( group.propval );
|
2005-03-04 13:32:08 +01:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-10-30 20:21:24 +01:00
|
|
|
/******************** Selection Tree ***************************************/
|
|
|
|
|
2006-01-11 21:12:06 +01:00
|
|
|
struct msi_selection_tree_info
|
|
|
|
{
|
|
|
|
msi_dialog *dialog;
|
|
|
|
HWND hwnd;
|
|
|
|
WNDPROC oldproc;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
msi_seltree_sync_item_state( HWND hwnd, MSIFEATURE *feature, HTREEITEM hItem )
|
|
|
|
{
|
|
|
|
TVITEMW tvi;
|
|
|
|
|
|
|
|
TRACE("Feature %s -> %d %d %d\n", debugstr_w(feature->Title),
|
|
|
|
feature->Installed, feature->Action, feature->ActionRequest);
|
|
|
|
|
|
|
|
tvi.mask = TVIF_STATE;
|
|
|
|
tvi.hItem = hItem;
|
|
|
|
tvi.state = INDEXTOSTATEIMAGEMASK( feature->Action );
|
|
|
|
tvi.stateMask = TVIS_STATEIMAGEMASK;
|
|
|
|
|
|
|
|
SendMessageW( hwnd, TVM_SETITEMW, 0, (LPARAM) &tvi );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT
|
|
|
|
msi_seltree_popup_menu( HWND hwnd, INT x, INT y )
|
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
INT r;
|
|
|
|
|
|
|
|
/* create a menu to display */
|
|
|
|
hMenu = CreatePopupMenu();
|
|
|
|
|
|
|
|
/* FIXME: load strings from resources */
|
|
|
|
AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_LOCAL, "Install feature locally");
|
|
|
|
AppendMenuA( hMenu, MF_GRAYED, 0x1000, "Install entire feature");
|
|
|
|
AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ADVERTISED, "Install on demand");
|
|
|
|
AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ABSENT, "Don't install");
|
|
|
|
r = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD,
|
|
|
|
x, y, 0, hwnd, NULL );
|
|
|
|
DestroyMenu( hMenu );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MSIFEATURE *
|
|
|
|
msi_seltree_feature_from_item( HWND hwnd, HTREEITEM hItem )
|
|
|
|
{
|
|
|
|
TVITEMW tvi;
|
|
|
|
|
|
|
|
/* get the feature from the item */
|
|
|
|
memset( &tvi, 0, sizeof tvi );
|
|
|
|
tvi.hItem = hItem;
|
|
|
|
tvi.mask = TVIF_PARAM | TVIF_HANDLE;
|
|
|
|
SendMessageW( hwnd, TVM_GETITEMW, 0, (LPARAM) &tvi );
|
|
|
|
|
|
|
|
return (MSIFEATURE*) tvi.lParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT
|
|
|
|
msi_seltree_menu( HWND hwnd, HTREEITEM hItem )
|
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
2006-07-18 00:17:38 +02:00
|
|
|
ComponentList *cl;
|
2006-01-11 21:12:06 +01:00
|
|
|
union {
|
|
|
|
RECT rc;
|
|
|
|
POINT pt[2];
|
|
|
|
HTREEITEM hItem;
|
|
|
|
} u;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
feature = msi_seltree_feature_from_item( hwnd, hItem );
|
|
|
|
if (!feature)
|
|
|
|
{
|
|
|
|
ERR("item %p feature was NULL\n", hItem);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the item's rectangle to put the menu just below it */
|
|
|
|
u.hItem = hItem;
|
|
|
|
SendMessageW( hwnd, TVM_GETITEMRECT, 0, (LPARAM) &u.rc );
|
|
|
|
MapWindowPoints( hwnd, NULL, u.pt, 2 );
|
|
|
|
|
|
|
|
r = msi_seltree_popup_menu( hwnd, u.rc.left, u.rc.top );
|
|
|
|
|
|
|
|
switch (r)
|
|
|
|
{
|
|
|
|
case INSTALLSTATE_LOCAL:
|
|
|
|
case INSTALLSTATE_ADVERTISED:
|
|
|
|
case INSTALLSTATE_ABSENT:
|
|
|
|
feature->ActionRequest = r;
|
|
|
|
feature->Action = r;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("select feature and all children\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update */
|
|
|
|
msi_seltree_sync_item_state( hwnd, feature, hItem );
|
|
|
|
|
2006-07-18 00:17:38 +02:00
|
|
|
/* update the feature's components */
|
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
|
|
|
{
|
|
|
|
cl->component->Action = feature->Action;
|
|
|
|
cl->component->ActionRequest = feature->ActionRequest;
|
|
|
|
}
|
|
|
|
|
2006-01-11 21:12:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI
|
|
|
|
MSISelectionTree_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct msi_selection_tree_info *info;
|
|
|
|
TVHITTESTINFO tvhti;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
info = GetPropW(hWnd, szButtonData);
|
|
|
|
|
|
|
|
switch( msg )
|
|
|
|
{
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
tvhti.pt.x = LOWORD( lParam );
|
|
|
|
tvhti.pt.y = HIWORD( lParam );
|
|
|
|
tvhti.flags = 0;
|
|
|
|
tvhti.hItem = 0;
|
|
|
|
r = CallWindowProcW(info->oldproc, hWnd, TVM_HITTEST, 0, (LPARAM) &tvhti );
|
|
|
|
if (tvhti.flags & TVHT_ONITEMSTATEICON)
|
|
|
|
return msi_seltree_menu( hWnd, tvhti.hItem );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
switch( msg )
|
|
|
|
{
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
msi_free( info );
|
|
|
|
RemovePropW( hWnd, szButtonData );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-10-30 20:21:24 +01:00
|
|
|
static void
|
2006-01-11 21:12:06 +01:00
|
|
|
msi_seltree_add_child_features( MSIPACKAGE *package, HWND hwnd,
|
|
|
|
LPCWSTR parent, HTREEITEM hParent )
|
2005-10-30 20:21:24 +01:00
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
TVINSERTSTRUCTW tvis;
|
|
|
|
HTREEITEM hitem;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
|
|
|
{
|
|
|
|
if ( lstrcmpW( parent, feature->Feature_Parent ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ( !feature->Title )
|
|
|
|
continue;
|
|
|
|
|
2006-07-21 19:10:01 +02:00
|
|
|
if ( !feature->Display )
|
|
|
|
continue;
|
|
|
|
|
2005-10-30 20:21:24 +01:00
|
|
|
memset( &tvis, 0, sizeof tvis );
|
|
|
|
tvis.hParent = hParent;
|
2006-07-18 20:40:44 +02:00
|
|
|
tvis.hInsertAfter = TVI_LAST;
|
2006-01-11 21:12:06 +01:00
|
|
|
tvis.u.item.mask = TVIF_TEXT | TVIF_PARAM;
|
|
|
|
tvis.u.item.pszText = feature->Title;
|
2005-11-02 11:56:22 +01:00
|
|
|
tvis.u.item.lParam = (LPARAM) feature;
|
2006-01-11 21:12:06 +01:00
|
|
|
|
2005-10-30 20:21:24 +01:00
|
|
|
hitem = (HTREEITEM) SendMessageW( hwnd, TVM_INSERTITEMW, 0, (LPARAM) &tvis );
|
|
|
|
if (!hitem)
|
|
|
|
continue;
|
|
|
|
|
2006-01-11 21:12:06 +01:00
|
|
|
msi_seltree_sync_item_state( hwnd, feature, hitem );
|
|
|
|
msi_seltree_add_child_features( package, hwnd,
|
|
|
|
feature->Feature, hitem );
|
2006-07-21 19:10:04 +02:00
|
|
|
|
|
|
|
/* the node is expanded if Display is odd */
|
|
|
|
if ( feature->Display % 2 != 0 )
|
|
|
|
SendMessageW( hwnd, TVM_EXPAND, TVE_EXPAND, (LPARAM) hitem );
|
2006-01-11 21:12:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void msi_seltree_create_imagelist( HWND hwnd )
|
|
|
|
{
|
|
|
|
const int bm_width = 32, bm_height = 16, bm_count = 3;
|
|
|
|
const int bm_resource = 0x1001;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
int i;
|
|
|
|
HBITMAP hbmp;
|
|
|
|
|
|
|
|
himl = ImageList_Create( bm_width, bm_height, FALSE, 4, 0 );
|
|
|
|
if (!himl)
|
|
|
|
{
|
|
|
|
ERR("failed to create image list\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<bm_count; i++)
|
|
|
|
{
|
|
|
|
hbmp = LoadBitmapW( msi_hInstance, MAKEINTRESOURCEW(i+bm_resource) );
|
|
|
|
if (!hbmp)
|
|
|
|
{
|
|
|
|
ERR("failed to load bitmap %d\n", i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a dummy bitmap at offset zero because the treeview
|
|
|
|
* can't use it as a state mask (zero means no user state).
|
|
|
|
*/
|
|
|
|
if (!i)
|
|
|
|
ImageList_Add( himl, hbmp, NULL );
|
|
|
|
|
|
|
|
ImageList_Add( himl, hbmp, NULL );
|
2005-10-30 20:21:24 +01:00
|
|
|
}
|
2006-01-11 21:12:06 +01:00
|
|
|
|
|
|
|
SendMessageW( hwnd, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)himl );
|
2005-10-30 20:21:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_selection_tree( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
|
|
|
LPCWSTR prop;
|
|
|
|
MSIPACKAGE *package = dialog->package;
|
2006-01-11 21:12:06 +01:00
|
|
|
DWORD style;
|
|
|
|
struct msi_selection_tree_info *info;
|
|
|
|
|
|
|
|
info = msi_alloc( sizeof *info );
|
|
|
|
if (!info)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-10-30 20:21:24 +01:00
|
|
|
|
2006-01-11 21:12:06 +01:00
|
|
|
/* create the treeview control */
|
2005-10-30 20:21:24 +01:00
|
|
|
prop = MSI_RecordGetString( rec, 9 );
|
2006-01-11 21:12:06 +01:00
|
|
|
style = TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT;
|
|
|
|
style |= WS_GROUP | WS_VSCROLL;
|
|
|
|
control = msi_dialog_add_control( dialog, rec, WC_TREEVIEWW, style );
|
2005-10-30 20:21:24 +01:00
|
|
|
if (!control)
|
2006-01-11 21:12:06 +01:00
|
|
|
{
|
|
|
|
msi_free(info);
|
2005-10-30 20:21:24 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2006-01-11 21:12:06 +01:00
|
|
|
}
|
2005-10-30 20:21:24 +01:00
|
|
|
|
2006-01-11 21:12:06 +01:00
|
|
|
/* subclass */
|
|
|
|
info->dialog = dialog;
|
|
|
|
info->hwnd = control->hwnd;
|
|
|
|
info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)MSISelectionTree_WndProc );
|
|
|
|
SetPropW( control->hwnd, szButtonData, info );
|
2005-10-30 20:21:24 +01:00
|
|
|
|
2006-01-11 21:12:06 +01:00
|
|
|
/* initialize it */
|
|
|
|
msi_seltree_create_imagelist( control->hwnd );
|
|
|
|
msi_seltree_add_child_features( package, control->hwnd, NULL, NULL );
|
2005-10-30 20:21:24 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-07-13 23:03:23 +02:00
|
|
|
/******************** Group Box ***************************************/
|
|
|
|
|
|
|
|
static UINT msi_dialog_group_box( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
|
|
|
DWORD style;
|
|
|
|
|
|
|
|
style = BS_GROUPBOX | WS_CHILD | WS_GROUP;
|
|
|
|
control = msi_dialog_add_control( dialog, rec, WC_BUTTONW, style );
|
|
|
|
if (!control)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-07-15 00:46:00 +02:00
|
|
|
/******************** List Box ***************************************/
|
|
|
|
|
|
|
|
struct msi_listbox_item
|
|
|
|
{
|
|
|
|
LPWSTR property;
|
|
|
|
LPWSTR value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct msi_listbox_info
|
|
|
|
{
|
|
|
|
msi_dialog *dialog;
|
|
|
|
HWND hwnd;
|
|
|
|
WNDPROC oldproc;
|
|
|
|
DWORD num_items;
|
|
|
|
struct msi_listbox_item *items;
|
|
|
|
};
|
|
|
|
|
|
|
|
static LRESULT WINAPI MSIListBox_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct msi_listbox_info *info;
|
|
|
|
LRESULT r;
|
|
|
|
DWORD j;
|
|
|
|
|
|
|
|
TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
info = GetPropW( hWnd, szButtonData );
|
|
|
|
if (!info)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
r = CallWindowProcW( info->oldproc, hWnd, msg, wParam, lParam );
|
|
|
|
|
|
|
|
switch( msg )
|
|
|
|
{
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
for (j = 0; j < info->num_items; j++)
|
|
|
|
{
|
|
|
|
msi_free( info->items[j].property );
|
|
|
|
msi_free( info->items[j].value );
|
|
|
|
}
|
|
|
|
msi_free( info->items );
|
|
|
|
msi_free( info );
|
|
|
|
RemovePropW( hWnd, szButtonData );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_listbox_add_item( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
struct msi_listbox_info *info = param;
|
|
|
|
struct msi_listbox_item *item;
|
|
|
|
LPCWSTR property, value, text;
|
|
|
|
static int index = 0;
|
|
|
|
|
|
|
|
item = &info->items[index++];
|
|
|
|
property = MSI_RecordGetString( rec, 1 );
|
|
|
|
value = MSI_RecordGetString( rec, 3 );
|
|
|
|
text = MSI_RecordGetString( rec, 4 );
|
|
|
|
|
|
|
|
item->property = strdupW( property );
|
|
|
|
item->value = strdupW( value );
|
|
|
|
|
|
|
|
SendMessageW( info->hwnd, LB_ADDSTRING, 0, (LPARAM)text );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_listbox_add_items( struct msi_listbox_info *info )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','`','L','i','s','t','B','o','x','`',' ',
|
|
|
|
'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0
|
|
|
|
};
|
|
|
|
|
|
|
|
r = MSI_OpenQuery( info->dialog->package->db, &view, query );
|
|
|
|
if ( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
|
|
|
|
/* just get the number of records */
|
|
|
|
r = MSI_IterateRecords( view, &count, NULL, NULL );
|
|
|
|
|
|
|
|
info->num_items = count;
|
|
|
|
info->items = msi_alloc( sizeof(*info->items) * count );
|
|
|
|
|
|
|
|
r = MSI_IterateRecords( view, NULL, msi_listbox_add_item, info );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_listbox_handler( msi_dialog *dialog,
|
|
|
|
msi_control *control, WPARAM param )
|
|
|
|
{
|
|
|
|
struct msi_listbox_info *info;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
if( HIWORD(param) != LBN_SELCHANGE )
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
info = GetPropW( control->hwnd, szButtonData );
|
|
|
|
index = SendMessageW( control->hwnd, LB_GETCURSEL, 0, 0 );
|
|
|
|
|
|
|
|
MSI_SetPropertyW( info->dialog->package,
|
|
|
|
info->items[index].property, info->items[index].value );
|
|
|
|
msi_dialog_evaluate_control_conditions( info->dialog );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_list_box( msi_dialog *dialog, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
struct msi_listbox_info *info;
|
|
|
|
msi_control *control;
|
|
|
|
DWORD style;
|
|
|
|
|
|
|
|
info = msi_alloc( sizeof *info );
|
|
|
|
if (!info)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
style = WS_TABSTOP | WS_GROUP | WS_CHILD | LBS_STANDARD;
|
|
|
|
control = msi_dialog_add_control( dialog, rec, WC_LISTBOXW, style );
|
|
|
|
if (!control)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
control->handler = msi_dialog_listbox_handler;
|
|
|
|
|
|
|
|
/* subclass */
|
|
|
|
info->dialog = dialog;
|
|
|
|
info->hwnd = control->hwnd;
|
|
|
|
info->items = NULL;
|
|
|
|
info->oldproc = (WNDPROC)SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)MSIListBox_WndProc );
|
|
|
|
SetPropW( control->hwnd, szButtonData, info );
|
|
|
|
|
|
|
|
msi_listbox_add_items( info );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-06-12 13:39:59 +02:00
|
|
|
static const struct control_handler msi_dialog_handler[] =
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
|
|
|
{ szText, msi_dialog_text_control },
|
2005-03-04 13:32:08 +01:00
|
|
|
{ szPushButton, msi_dialog_button_control },
|
2005-01-28 13:39:57 +01:00
|
|
|
{ szLine, msi_dialog_line_control },
|
|
|
|
{ szBitmap, msi_dialog_bitmap_control },
|
2005-02-02 10:55:51 +01:00
|
|
|
{ szCheckBox, msi_dialog_checkbox_control },
|
|
|
|
{ szScrollableText, msi_dialog_scrolltext_control },
|
2005-02-09 14:24:31 +01:00
|
|
|
{ szComboBox, msi_dialog_combo_control },
|
|
|
|
{ szEdit, msi_dialog_edit_control },
|
2005-06-16 22:37:53 +02:00
|
|
|
{ szMaskedEdit, msi_dialog_maskedit_control },
|
2005-02-16 17:25:36 +01:00
|
|
|
{ szPathEdit, msi_dialog_pathedit_control },
|
2005-09-28 17:12:10 +02:00
|
|
|
{ szProgressBar, msi_dialog_progress_bar },
|
2005-02-16 17:25:36 +01:00
|
|
|
{ szRadioButtonGroup, msi_dialog_radiogroup_control },
|
2005-06-23 18:43:38 +02:00
|
|
|
{ szIcon, msi_dialog_icon_control },
|
2005-10-30 20:21:24 +01:00
|
|
|
{ szSelectionTree, msi_dialog_selection_tree },
|
2006-07-13 23:03:23 +02:00
|
|
|
{ szGroupBox, msi_dialog_group_box },
|
2006-07-15 00:46:00 +02:00
|
|
|
{ szListBox, msi_dialog_list_box },
|
2005-01-28 13:39:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_CONTROL_TYPES (sizeof msi_dialog_handler/sizeof msi_dialog_handler[0])
|
|
|
|
|
|
|
|
static UINT msi_dialog_create_controls( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_dialog *dialog = param;
|
2005-01-28 13:39:57 +01:00
|
|
|
LPCWSTR control_type;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
/* find and call the function that can create this type of control */
|
|
|
|
control_type = MSI_RecordGetString( rec, 3 );
|
|
|
|
for( i=0; i<NUM_CONTROL_TYPES; i++ )
|
|
|
|
if (!strcmpiW( msi_dialog_handler[i].control_type, control_type ))
|
|
|
|
break;
|
|
|
|
if( i != NUM_CONTROL_TYPES )
|
|
|
|
msi_dialog_handler[i].func( dialog, rec );
|
|
|
|
else
|
|
|
|
ERR("no handler for element type %s\n", debugstr_w(control_type));
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_fill_controls( msi_dialog *dialog )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','C','o','n','t','r','o','l',' ',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
MSIPACKAGE *package = dialog->package;
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
/* query the Control table for all the elements of the control */
|
2005-02-02 10:55:51 +01:00
|
|
|
r = MSI_OpenQuery( package->db, &view, query, dialog->name );
|
2005-01-28 13:39:57 +01:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
|
2005-01-28 13:39:57 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
r = MSI_IterateRecords( view, 0, msi_dialog_create_controls, dialog );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_set_control_condition( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
static const WCHAR szHide[] = { 'H','i','d','e',0 };
|
|
|
|
static const WCHAR szShow[] = { 'S','h','o','w',0 };
|
|
|
|
static const WCHAR szDisable[] = { 'D','i','s','a','b','l','e',0 };
|
|
|
|
static const WCHAR szEnable[] = { 'E','n','a','b','l','e',0 };
|
|
|
|
msi_dialog *dialog = param;
|
|
|
|
msi_control *control;
|
|
|
|
LPCWSTR name, action, condition;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
name = MSI_RecordGetString( rec, 2 );
|
|
|
|
action = MSI_RecordGetString( rec, 3 );
|
|
|
|
condition = MSI_RecordGetString( rec, 4 );
|
|
|
|
r = MSI_EvaluateConditionW( dialog->package, condition );
|
|
|
|
control = msi_dialog_find_control( dialog, name );
|
2005-10-29 13:29:31 +02:00
|
|
|
if( r == MSICONDITION_TRUE && control )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
|
|
|
TRACE("%s control %s\n", debugstr_w(action), debugstr_w(name));
|
|
|
|
|
|
|
|
/* FIXME: case sensitive? */
|
2005-06-20 16:11:43 +02:00
|
|
|
if(!lstrcmpW(action, szHide))
|
2005-02-02 10:55:51 +01:00
|
|
|
ShowWindow(control->hwnd, SW_HIDE);
|
|
|
|
else if(!strcmpW(action, szShow))
|
|
|
|
ShowWindow(control->hwnd, SW_SHOW);
|
|
|
|
else if(!strcmpW(action, szDisable))
|
|
|
|
EnableWindow(control->hwnd, FALSE);
|
|
|
|
else if(!strcmpW(action, szEnable))
|
2005-02-03 11:41:59 +01:00
|
|
|
EnableWindow(control->hwnd, TRUE);
|
2005-02-02 10:55:51 +01:00
|
|
|
else
|
|
|
|
FIXME("Unhandled action %s\n", debugstr_w(action));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ',
|
|
|
|
'C','o','n','t','r','o','l','C','o','n','d','i','t','i','o','n',' ',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0
|
|
|
|
};
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
MSIPACKAGE *package = dialog->package;
|
|
|
|
|
|
|
|
TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
|
|
|
|
|
|
|
|
/* query the Control table for all the elements of the control */
|
|
|
|
r = MSI_OpenQuery( package->db, &view, query, dialog->name );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MSI_IterateRecords( view, 0, msi_dialog_set_control_condition, dialog );
|
2005-01-28 13:39:57 +01:00
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-01-03 12:12:09 +01:00
|
|
|
UINT msi_dialog_reset( msi_dialog *dialog )
|
|
|
|
{
|
|
|
|
/* FIXME: should restore the original values of any properties we changed */
|
|
|
|
return msi_dialog_evaluate_control_conditions( dialog );
|
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
/* figure out the height of 10 point MS Sans Serif */
|
|
|
|
static INT msi_dialog_get_sans_serif_height( HWND hwnd )
|
|
|
|
{
|
|
|
|
static const WCHAR szSansSerif[] = {
|
|
|
|
'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0 };
|
|
|
|
LOGFONTW lf;
|
|
|
|
TEXTMETRICW tm;
|
|
|
|
BOOL r;
|
|
|
|
LONG height = 0;
|
|
|
|
HFONT hFont, hOldFont;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
hdc = GetDC( hwnd );
|
|
|
|
if (hdc)
|
|
|
|
{
|
|
|
|
memset( &lf, 0, sizeof lf );
|
2005-02-02 10:55:51 +01:00
|
|
|
lf.lfHeight = MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72);
|
2005-01-28 13:39:57 +01:00
|
|
|
strcpyW( lf.lfFaceName, szSansSerif );
|
|
|
|
hFont = CreateFontIndirectW(&lf);
|
|
|
|
if (hFont)
|
|
|
|
{
|
|
|
|
hOldFont = SelectObject( hdc, hFont );
|
|
|
|
r = GetTextMetricsW( hdc, &tm );
|
|
|
|
if (r)
|
|
|
|
height = tm.tmHeight;
|
|
|
|
SelectObject( hdc, hOldFont );
|
|
|
|
DeleteObject( hFont );
|
|
|
|
}
|
|
|
|
ReleaseDC( hwnd, hdc );
|
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
/* fetch the associated record from the Dialog table */
|
|
|
|
static MSIRECORD *msi_get_dialog_record( msi_dialog *dialog )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','D','i','a','l','o','g',' ',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','D','i','a','l','o','g','`',' ','=',' ','\'','%','s','\'',0};
|
|
|
|
MSIPACKAGE *package = dialog->package;
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-06-02 12:29:28 +02:00
|
|
|
rec = MSI_QueryGetRecord( package->db, query, dialog->name );
|
|
|
|
if( !rec )
|
2005-01-28 13:39:57 +01:00
|
|
|
ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
2006-08-04 02:42:05 +02:00
|
|
|
static void msi_get_screen_resolution( msi_dialog *dialog, UINT *xres, UINT *yres )
|
2005-06-04 11:35:37 +02:00
|
|
|
{
|
2006-08-04 02:42:05 +02:00
|
|
|
WCHAR num[10];
|
|
|
|
DWORD sz = 10;
|
|
|
|
|
|
|
|
static const WCHAR szScreenX[] = {'S','c','r','e','e','n','X',0};
|
|
|
|
static const WCHAR szScreenY[] = {'S','c','r','e','e','n','Y',0};
|
|
|
|
|
|
|
|
*xres = 0;
|
|
|
|
*yres = 0;
|
|
|
|
|
|
|
|
MSI_GetPropertyW( dialog->package, szScreenX, num, &sz );
|
|
|
|
*xres = atolW( num );
|
|
|
|
|
|
|
|
sz = 10;
|
|
|
|
MSI_GetPropertyW( dialog->package, szScreenY, num, &sz );
|
|
|
|
*yres = atolW( num );
|
|
|
|
}
|
|
|
|
|
2006-08-07 10:08:27 +02:00
|
|
|
static void msi_dialog_adjust_dialog_pos( msi_dialog *dialog, MSIRECORD *rec, LPRECT pos )
|
2006-08-04 02:42:05 +02:00
|
|
|
{
|
|
|
|
UINT xres, yres;
|
2006-08-07 10:08:27 +02:00
|
|
|
POINT center;
|
|
|
|
SIZE sz;
|
2005-06-04 11:35:37 +02:00
|
|
|
LONG style;
|
2006-08-07 10:08:27 +02:00
|
|
|
|
|
|
|
center.x = MSI_RecordGetInteger( rec, 2 );
|
|
|
|
center.y = MSI_RecordGetInteger( rec, 3 );
|
|
|
|
|
|
|
|
sz.cx = MSI_RecordGetInteger( rec, 4 );
|
|
|
|
sz.cy = MSI_RecordGetInteger( rec, 5 );
|
|
|
|
|
|
|
|
sz.cx = msi_dialog_scale_unit( dialog, sz.cx );
|
|
|
|
sz.cy = msi_dialog_scale_unit( dialog, sz.cy );
|
2006-08-04 02:42:05 +02:00
|
|
|
|
|
|
|
msi_get_screen_resolution( dialog, &xres, &yres );
|
2006-08-07 10:08:27 +02:00
|
|
|
center.x = MulDiv( center.x, xres, 100 );
|
|
|
|
center.y = MulDiv( center.y, yres, 100 );
|
2005-06-04 11:35:37 +02:00
|
|
|
|
2006-08-04 02:42:05 +02:00
|
|
|
/* turn the client pos into the window rectangle */
|
2006-08-07 10:08:27 +02:00
|
|
|
pos->left = center.x - sz.cx/2;
|
|
|
|
pos->right = pos->left + sz.cx;
|
|
|
|
pos->top = center.y - sz.cy/2;
|
|
|
|
pos->bottom = pos->top + sz.cy;
|
|
|
|
|
|
|
|
TRACE("%lu %lu %lu %lu\n", pos->left, pos->top, pos->right, pos->bottom);
|
|
|
|
|
2005-06-04 11:35:37 +02:00
|
|
|
style = GetWindowLongPtrW( dialog->hwnd, GWL_STYLE );
|
2006-08-04 02:42:05 +02:00
|
|
|
AdjustWindowRect( pos, style, FALSE );
|
2005-06-04 11:35:37 +02:00
|
|
|
}
|
|
|
|
|
2005-06-30 12:20:40 +02:00
|
|
|
static BOOL msi_control_set_next( msi_control *control, msi_control *next )
|
|
|
|
{
|
|
|
|
return SetWindowPos( next->hwnd, control->hwnd, 0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW |
|
|
|
|
SWP_NOREPOSITION | SWP_NOSENDCHANGING | SWP_NOSIZE );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_set_tab_order( msi_dialog *dialog )
|
|
|
|
{
|
|
|
|
msi_control *control, *tab_next;
|
|
|
|
|
2005-09-16 21:40:00 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
|
2005-06-30 12:20:40 +02:00
|
|
|
{
|
|
|
|
tab_next = msi_dialog_find_control( dialog, control->tabnext );
|
|
|
|
if( !tab_next )
|
|
|
|
continue;
|
|
|
|
msi_control_set_next( control, tab_next );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-07-05 18:18:46 +02:00
|
|
|
static void msi_dialog_set_first_control( msi_dialog* dialog, LPCWSTR name )
|
|
|
|
{
|
|
|
|
msi_control *control;
|
|
|
|
|
|
|
|
control = msi_dialog_find_control( dialog, name );
|
|
|
|
if( control )
|
|
|
|
dialog->hWndFocus = control->hwnd;
|
|
|
|
else
|
|
|
|
dialog->hWndFocus = NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
static LRESULT msi_dialog_oncreate( HWND hwnd, LPCREATESTRUCTW cs )
|
|
|
|
{
|
|
|
|
static const WCHAR df[] = {
|
|
|
|
'D','e','f','a','u','l','t','U','I','F','o','n','t',0 };
|
2005-12-20 11:59:23 +01:00
|
|
|
static const WCHAR dfv[] = {
|
|
|
|
'M','S',' ','S','h','e','l','l',' ','D','l','g',0 };
|
2005-04-27 12:16:57 +02:00
|
|
|
msi_dialog *dialog = (msi_dialog*) cs->lpCreateParams;
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
LPWSTR title = NULL;
|
2006-08-04 02:42:05 +02:00
|
|
|
RECT pos;
|
2005-04-27 12:16:57 +02:00
|
|
|
|
|
|
|
TRACE("%p %p\n", dialog, dialog->package);
|
|
|
|
|
|
|
|
dialog->hwnd = hwnd;
|
|
|
|
SetWindowLongPtrW( hwnd, GWLP_USERDATA, (LONG_PTR) dialog );
|
|
|
|
|
|
|
|
rec = msi_get_dialog_record( dialog );
|
2005-01-28 13:39:57 +01:00
|
|
|
if( !rec )
|
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
TRACE("No record found for dialog %s\n", debugstr_w(dialog->name));
|
|
|
|
return -1;
|
2005-01-28 13:39:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dialog->scale = msi_dialog_get_sans_serif_height(dialog->hwnd);
|
|
|
|
|
2006-08-07 10:08:27 +02:00
|
|
|
msi_dialog_adjust_dialog_pos( dialog, rec, &pos );
|
2005-06-04 11:35:37 +02:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
dialog->attributes = MSI_RecordGetInteger( rec, 6 );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-09-15 17:04:08 +02:00
|
|
|
dialog->default_font = msi_dup_property( dialog->package, df );
|
2005-12-20 11:59:23 +01:00
|
|
|
if (!dialog->default_font)
|
|
|
|
{
|
|
|
|
dialog->default_font = strdupW(dfv);
|
|
|
|
if (!dialog->default_font) return -1;
|
|
|
|
}
|
2005-02-08 13:55:47 +01:00
|
|
|
|
2005-09-16 21:01:18 +02:00
|
|
|
title = msi_get_deformatted_field( dialog->package, rec, 7 );
|
2005-01-28 13:39:57 +01:00
|
|
|
SetWindowTextW( hwnd, title );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( title );
|
2005-09-16 21:01:18 +02:00
|
|
|
|
2006-08-07 10:08:27 +02:00
|
|
|
SetWindowPos( hwnd, 0, pos.left, pos.top,
|
|
|
|
pos.right - pos.left, pos.bottom - pos.top,
|
2006-08-04 02:42:05 +02:00
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_dialog_build_font_list( dialog );
|
|
|
|
msi_dialog_fill_controls( dialog );
|
|
|
|
msi_dialog_evaluate_control_conditions( dialog );
|
2005-06-30 12:20:40 +02:00
|
|
|
msi_dialog_set_tab_order( dialog );
|
2005-07-05 18:18:46 +02:00
|
|
|
msi_dialog_set_first_control( dialog, MSI_RecordGetString( rec, 8 ) );
|
|
|
|
msiobj_release( &rec->hdr );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
static UINT msi_dialog_send_event( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
|
|
|
|
{
|
|
|
|
LPWSTR event_fmt = NULL, arg_fmt = NULL;
|
|
|
|
|
|
|
|
TRACE("Sending control event %s %s\n", debugstr_w(event), debugstr_w(arg));
|
|
|
|
|
|
|
|
deformat_string( dialog->package, event, &event_fmt );
|
|
|
|
deformat_string( dialog->package, arg, &arg_fmt );
|
|
|
|
|
|
|
|
dialog->event_handler( dialog->package, event_fmt, arg_fmt, dialog );
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( event_fmt );
|
|
|
|
msi_free( arg_fmt );
|
2005-02-02 10:55:51 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_set_property( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
|
|
|
|
{
|
|
|
|
static const WCHAR szNullArg[] = { '{','}',0 };
|
|
|
|
LPWSTR p, prop, arg_fmt = NULL;
|
|
|
|
UINT len;
|
|
|
|
|
|
|
|
len = strlenW(event);
|
2005-09-20 13:59:14 +02:00
|
|
|
prop = msi_alloc( len*sizeof(WCHAR));
|
2005-02-02 10:55:51 +01:00
|
|
|
strcpyW( prop, &event[1] );
|
|
|
|
p = strchrW( prop, ']' );
|
|
|
|
if( p && p[1] == 0 )
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
if( strcmpW( szNullArg, arg ) )
|
|
|
|
deformat_string( dialog->package, arg, &arg_fmt );
|
|
|
|
MSI_SetPropertyW( dialog->package, prop, arg_fmt );
|
2005-09-21 11:43:29 +02:00
|
|
|
msi_free( arg_fmt );
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Badly formatted property string - what happens?\n");
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( prop );
|
2005-02-02 10:55:51 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_control_event( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
msi_dialog *dialog = param;
|
|
|
|
LPCWSTR condition, event, arg;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
condition = MSI_RecordGetString( rec, 5 );
|
|
|
|
r = MSI_EvaluateConditionW( dialog->package, condition );
|
2006-02-23 17:33:10 +01:00
|
|
|
if( r == MSICONDITION_TRUE || r == MSICONDITION_NONE )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
|
|
|
event = MSI_RecordGetString( rec, 3 );
|
|
|
|
arg = MSI_RecordGetString( rec, 4 );
|
|
|
|
if( event[0] == '[' )
|
|
|
|
msi_dialog_set_property( dialog, event, arg );
|
|
|
|
else
|
|
|
|
msi_dialog_send_event( dialog, event, arg );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
static UINT msi_dialog_button_handler( msi_dialog *dialog,
|
|
|
|
msi_control *control, WPARAM param )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','C','o','n','t','r','o','l','E','v','e','n','t',' ',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
|
|
|
|
'A','N','D',' ',
|
|
|
|
'`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',' ',
|
|
|
|
'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','i','n','g','`',0
|
|
|
|
};
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
UINT r;
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
if( HIWORD(param) != BN_CLICKED )
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
r = MSI_OpenQuery( dialog->package->db, &view, query,
|
|
|
|
dialog->name, control->name );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
ERR("query failed\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MSI_IterateRecords( view, 0, msi_dialog_control_event, dialog );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-02-03 11:41:59 +01:00
|
|
|
static UINT msi_dialog_get_checkbox_state( msi_dialog *dialog,
|
|
|
|
msi_control *control )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2005-02-03 11:41:59 +01:00
|
|
|
WCHAR state[2] = { 0 };
|
|
|
|
DWORD sz = 2;
|
|
|
|
|
|
|
|
MSI_GetPropertyW( dialog->package, control->property, state, &sz );
|
2005-06-01 21:48:48 +02:00
|
|
|
return state[0] ? 1 : 0;
|
2005-02-03 11:41:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void msi_dialog_set_checkbox_state( msi_dialog *dialog,
|
|
|
|
msi_control *control, UINT state )
|
|
|
|
{
|
2005-06-01 21:48:48 +02:00
|
|
|
static const WCHAR szState[] = { '1', 0 };
|
|
|
|
LPCWSTR val;
|
|
|
|
|
|
|
|
/* if uncheck then the property is set to NULL */
|
|
|
|
if (!state)
|
|
|
|
{
|
|
|
|
MSI_SetPropertyW( dialog->package, control->property, NULL );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for a custom state */
|
|
|
|
if (control->value && control->value[0])
|
|
|
|
val = control->value;
|
|
|
|
else
|
|
|
|
val = szState;
|
2005-02-03 11:41:59 +01:00
|
|
|
|
2005-06-01 21:48:48 +02:00
|
|
|
MSI_SetPropertyW( dialog->package, control->property, val );
|
2005-02-03 11:41:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void msi_dialog_checkbox_sync_state( msi_dialog *dialog,
|
|
|
|
msi_control *control )
|
|
|
|
{
|
|
|
|
UINT state;
|
|
|
|
|
|
|
|
state = msi_dialog_get_checkbox_state( dialog, control );
|
|
|
|
SendMessageW( control->hwnd, BM_SETCHECK,
|
|
|
|
state ? BST_CHECKED : BST_UNCHECKED, 0 );
|
|
|
|
}
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
static UINT msi_dialog_checkbox_handler( msi_dialog *dialog,
|
|
|
|
msi_control *control, WPARAM param )
|
2005-02-03 11:41:59 +01:00
|
|
|
{
|
|
|
|
UINT state;
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
if( HIWORD(param) != BN_CLICKED )
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2005-02-03 11:41:59 +01:00
|
|
|
TRACE("clicked checkbox %s, set %s\n", debugstr_w(control->name),
|
|
|
|
debugstr_w(control->property));
|
|
|
|
|
|
|
|
state = msi_dialog_get_checkbox_state( dialog, control );
|
|
|
|
state = state ? 0 : 1;
|
|
|
|
msi_dialog_set_checkbox_state( dialog, control, state );
|
|
|
|
msi_dialog_checkbox_sync_state( dialog, control );
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
return msi_dialog_button_handler( dialog, control, param );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_dialog_edit_handler( msi_dialog *dialog,
|
|
|
|
msi_control *control, WPARAM param )
|
|
|
|
{
|
|
|
|
UINT sz, r;
|
|
|
|
LPWSTR buf;
|
|
|
|
|
|
|
|
if( HIWORD(param) != EN_CHANGE )
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
TRACE("edit %s contents changed, set %s\n", debugstr_w(control->name),
|
|
|
|
debugstr_w(control->property));
|
|
|
|
|
|
|
|
sz = 0x20;
|
2005-09-20 13:59:14 +02:00
|
|
|
buf = msi_alloc( sz*sizeof(WCHAR) );
|
2005-02-09 14:24:31 +01:00
|
|
|
while( buf )
|
|
|
|
{
|
|
|
|
r = GetWindowTextW( control->hwnd, buf, sz );
|
|
|
|
if( r < (sz-1) )
|
|
|
|
break;
|
2005-09-20 13:59:14 +02:00
|
|
|
sz *= 2;
|
|
|
|
buf = msi_realloc( buf, sz*sizeof(WCHAR) );
|
2005-02-09 14:24:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MSI_SetPropertyW( dialog->package, control->property, buf );
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( buf );
|
2005-02-09 14:24:31 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
|
2005-03-04 13:32:08 +01:00
|
|
|
static UINT msi_dialog_radiogroup_handler( msi_dialog *dialog,
|
|
|
|
msi_control *control, WPARAM param )
|
|
|
|
{
|
|
|
|
if( HIWORD(param) != BN_CLICKED )
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
TRACE("clicked radio button %s, set %s\n", debugstr_w(control->name),
|
|
|
|
debugstr_w(control->property));
|
|
|
|
|
|
|
|
MSI_SetPropertyW( dialog->package, control->property, control->name );
|
|
|
|
|
|
|
|
return msi_dialog_button_handler( dialog, control, param );
|
|
|
|
}
|
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
static LRESULT msi_dialog_oncommand( msi_dialog *dialog, WPARAM param, HWND hwnd )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-10-29 13:07:46 +02:00
|
|
|
msi_control *control = NULL;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-02-09 14:24:31 +01:00
|
|
|
TRACE("%p %p %08x\n", dialog, hwnd, param);
|
2005-02-02 10:55:51 +01:00
|
|
|
|
2005-10-29 13:07:46 +02:00
|
|
|
switch (param)
|
|
|
|
{
|
|
|
|
case 1: /* enter */
|
|
|
|
control = msi_dialog_find_control( dialog, dialog->control_default );
|
|
|
|
break;
|
|
|
|
case 2: /* escape */
|
|
|
|
control = msi_dialog_find_control( dialog, dialog->control_cancel );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
control = msi_dialog_find_control_by_hwnd( dialog, hwnd );
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
if( control )
|
|
|
|
{
|
2005-02-09 14:24:31 +01:00
|
|
|
if( control->handler )
|
2005-02-03 11:41:59 +01:00
|
|
|
{
|
2005-02-09 14:24:31 +01:00
|
|
|
control->handler( dialog, control, param );
|
2005-02-03 11:41:59 +01:00
|
|
|
msi_dialog_evaluate_control_conditions( dialog );
|
|
|
|
}
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
else
|
2005-10-29 13:07:46 +02:00
|
|
|
ERR("button click from nowhere %p %d %p\n", dialog, param, hwnd);
|
2005-01-28 13:39:57 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-05 18:18:46 +02:00
|
|
|
static void msi_dialog_setfocus( msi_dialog *dialog )
|
|
|
|
{
|
|
|
|
HWND hwnd = dialog->hWndFocus;
|
|
|
|
|
|
|
|
hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, TRUE);
|
|
|
|
hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, FALSE);
|
|
|
|
SetFocus( hwnd );
|
|
|
|
dialog->hWndFocus = hwnd;
|
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
static LRESULT WINAPI MSIDialog_WndProc( HWND hwnd, UINT msg,
|
|
|
|
WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_dialog *dialog = (LPVOID) GetWindowLongPtrW( hwnd, GWLP_USERDATA );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
TRACE("0x%04x\n", msg);
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
return msi_dialog_oncreate( hwnd, (LPCREATESTRUCTW)lParam );
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
2005-02-09 14:24:31 +01:00
|
|
|
return msi_dialog_oncommand( dialog, wParam, (HWND)lParam );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-07-05 18:18:46 +02:00
|
|
|
case WM_ACTIVATE:
|
|
|
|
if( LOWORD(wParam) == WA_INACTIVE )
|
|
|
|
dialog->hWndFocus = GetFocus();
|
|
|
|
else
|
|
|
|
msi_dialog_setfocus( dialog );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_SETFOCUS:
|
|
|
|
msi_dialog_setfocus( dialog );
|
|
|
|
return 0;
|
|
|
|
|
2005-06-24 13:34:43 +02:00
|
|
|
/* bounce back to our subclassed static control */
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
return SendMessageW( (HWND) lParam, WM_CTLCOLORSTATIC, wParam, lParam );
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
case WM_DESTROY:
|
|
|
|
dialog->hwnd = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProcW(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2006-01-06 12:19:33 +01:00
|
|
|
static BOOL CALLBACK msi_radioground_child_enum( HWND hWnd, LPARAM lParam )
|
|
|
|
{
|
|
|
|
EnableWindow( hWnd, lParam );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
WNDPROC oldproc = (WNDPROC) GetPropW(hWnd, szButtonData);
|
2006-01-06 12:19:33 +01:00
|
|
|
LRESULT r;
|
2005-04-27 12:16:57 +02:00
|
|
|
|
|
|
|
TRACE("hWnd %p msg %04x wParam 0x%08x lParam 0x%08lx\n", hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
if (msg == WM_COMMAND) /* Forward notifications to dialog */
|
|
|
|
SendMessageW(GetParent(hWnd), msg, wParam, lParam);
|
|
|
|
|
2006-01-06 12:19:33 +01:00
|
|
|
r = CallWindowProcW(oldproc, hWnd, msg, wParam, lParam);
|
|
|
|
|
|
|
|
/* make sure the radio buttons show as disabled if the parent is disabled */
|
|
|
|
if (msg == WM_ENABLE)
|
|
|
|
EnumChildWindows( hWnd, msi_radioground_child_enum, wParam );
|
|
|
|
|
|
|
|
return r;
|
2005-04-27 12:16:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI MSIHiddenWindowProc( HWND hwnd, UINT msg,
|
|
|
|
WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
msi_dialog *dialog = (msi_dialog*) lParam;
|
|
|
|
|
|
|
|
TRACE("%d %p\n", msg, dialog);
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_MSI_DIALOG_CREATE:
|
|
|
|
return msi_dialog_run_message_loop( dialog );
|
|
|
|
case WM_MSI_DIALOG_DESTROY:
|
|
|
|
msi_dialog_destroy( dialog );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProcW( hwnd, msg, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
/* functions that interface to other modules within MSI */
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_dialog *msi_dialog_create( MSIPACKAGE* package, LPCWSTR szDialogName,
|
2005-01-28 13:39:57 +01:00
|
|
|
msi_dialog_event_handler event_handler )
|
|
|
|
{
|
2005-04-27 12:16:57 +02:00
|
|
|
MSIRECORD *rec = NULL;
|
2005-02-02 10:55:51 +01:00
|
|
|
msi_dialog *dialog;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
TRACE("%p %s\n", package, debugstr_w(szDialogName));
|
|
|
|
|
|
|
|
/* allocate the structure for the dialog to use */
|
2005-09-20 13:59:14 +02:00
|
|
|
dialog = msi_alloc_zero( sizeof *dialog + sizeof(WCHAR)*strlenW(szDialogName) );
|
2005-01-28 13:39:57 +01:00
|
|
|
if( !dialog )
|
|
|
|
return NULL;
|
|
|
|
strcpyW( dialog->name, szDialogName );
|
2005-04-27 12:16:57 +02:00
|
|
|
msiobj_addref( &package->hdr );
|
2005-01-28 13:39:57 +01:00
|
|
|
dialog->package = package;
|
|
|
|
dialog->event_handler = event_handler;
|
2005-04-27 12:16:57 +02:00
|
|
|
dialog->finished = 0;
|
2005-09-16 21:40:00 +02:00
|
|
|
list_init( &dialog->controls );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
/* verify that the dialog exists */
|
|
|
|
rec = msi_get_dialog_record( dialog );
|
|
|
|
if( !rec )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-09-13 13:25:07 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( dialog );
|
2005-01-28 13:39:57 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-27 12:16:57 +02:00
|
|
|
dialog->attributes = MSI_RecordGetInteger( rec, 6 );
|
2005-10-29 13:07:46 +02:00
|
|
|
dialog->control_default = strdupW( MSI_RecordGetString( rec, 9 ) );
|
|
|
|
dialog->control_cancel = strdupW( MSI_RecordGetString( rec, 10 ) );
|
2005-04-27 12:16:57 +02:00
|
|
|
msiobj_release( &rec->hdr );
|
2005-01-28 13:39:57 +01:00
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:11:43 +02:00
|
|
|
static void msi_process_pending_messages( HWND hdlg )
|
2005-04-27 12:16:57 +02:00
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ) )
|
|
|
|
{
|
2005-06-20 16:11:43 +02:00
|
|
|
if( hdlg && IsDialogMessageW( hdlg, &msg ))
|
|
|
|
continue;
|
2005-04-27 12:16:57 +02:00
|
|
|
TranslateMessage( &msg );
|
|
|
|
DispatchMessageW( &msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
void msi_dialog_end_dialog( msi_dialog *dialog )
|
|
|
|
{
|
2005-04-27 12:16:57 +02:00
|
|
|
TRACE("%p\n", dialog);
|
2005-02-02 10:55:51 +01:00
|
|
|
dialog->finished = 1;
|
2005-04-27 12:16:57 +02:00
|
|
|
PostMessageW(dialog->hwnd, WM_NULL, 0, 0);
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
void msi_dialog_check_messages( HANDLE handle )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2005-04-27 12:16:57 +02:00
|
|
|
DWORD r;
|
2005-02-02 10:55:51 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
/* in threads other than the UI thread, block */
|
|
|
|
if( uiThreadId != GetCurrentThreadId() )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2005-04-27 12:16:57 +02:00
|
|
|
if( handle )
|
|
|
|
WaitForSingleObject( handle, INFINITE );
|
|
|
|
return;
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
/* there's two choices for the UI thread */
|
|
|
|
while (1)
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2005-06-20 16:11:43 +02:00
|
|
|
msi_process_pending_messages( NULL );
|
2005-02-02 10:55:51 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
if( !handle )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* block here until somebody creates a new dialog or
|
|
|
|
* the handle we're waiting on becomes ready
|
|
|
|
*/
|
|
|
|
r = MsgWaitForMultipleObjects( 1, &handle, 0, INFINITE, QS_ALLINPUT );
|
|
|
|
if( r == WAIT_OBJECT_0 )
|
|
|
|
break;
|
|
|
|
}
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
UINT msi_dialog_run_message_loop( msi_dialog *dialog )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2006-03-22 06:06:30 +01:00
|
|
|
DWORD style;
|
2005-04-27 12:16:57 +02:00
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
if( uiThreadId != GetCurrentThreadId() )
|
|
|
|
return SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_CREATE, 0, (LPARAM) dialog );
|
|
|
|
|
|
|
|
/* create the dialog window, don't show it yet */
|
2006-03-22 06:06:30 +01:00
|
|
|
style = WS_OVERLAPPED;
|
|
|
|
if( dialog->attributes & msidbDialogAttributesVisible )
|
|
|
|
style |= WS_VISIBLE;
|
|
|
|
|
|
|
|
hwnd = CreateWindowW( szMsiDialogClass, dialog->name, style,
|
2005-04-27 12:16:57 +02:00
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
NULL, NULL, NULL, dialog );
|
|
|
|
if( !hwnd )
|
|
|
|
{
|
|
|
|
ERR("Failed to create dialog %s\n", debugstr_w( dialog->name ));
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
2005-02-02 10:55:51 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
ShowWindow( hwnd, SW_SHOW );
|
2005-09-29 12:48:08 +02:00
|
|
|
/* UpdateWindow( hwnd ); - and causes the transparent static controls not to paint */
|
2005-04-27 12:16:57 +02:00
|
|
|
|
|
|
|
if( dialog->attributes & msidbDialogAttributesModal )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2005-04-27 12:16:57 +02:00
|
|
|
while( !dialog->finished )
|
2005-02-08 13:55:47 +01:00
|
|
|
{
|
2006-08-01 03:17:03 +02:00
|
|
|
MsgWaitForMultipleObjects( 0, NULL, 0, INFINITE, QS_ALLINPUT );
|
2005-06-20 16:11:43 +02:00
|
|
|
msi_process_pending_messages( dialog->hwnd );
|
2005-02-08 13:55:47 +01:00
|
|
|
}
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
2005-04-27 12:16:57 +02:00
|
|
|
else
|
|
|
|
return ERROR_IO_PENDING;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void msi_dialog_do_preview( msi_dialog *dialog )
|
|
|
|
{
|
2005-04-27 12:16:57 +02:00
|
|
|
TRACE("\n");
|
2005-02-02 10:55:51 +01:00
|
|
|
dialog->attributes |= msidbDialogAttributesVisible;
|
|
|
|
dialog->attributes &= ~msidbDialogAttributesModal;
|
|
|
|
msi_dialog_run_message_loop( dialog );
|
|
|
|
}
|
|
|
|
|
|
|
|
void msi_dialog_destroy( msi_dialog *dialog )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
2005-04-27 12:16:57 +02:00
|
|
|
if( uiThreadId != GetCurrentThreadId() )
|
|
|
|
{
|
|
|
|
SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_DESTROY, 0, (LPARAM) dialog );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
if( dialog->hwnd )
|
|
|
|
ShowWindow( dialog->hwnd, SW_HIDE );
|
|
|
|
|
2005-09-16 20:45:33 +02:00
|
|
|
if( dialog->hwnd )
|
|
|
|
DestroyWindow( dialog->hwnd );
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
/* destroy the list of controls */
|
2005-09-16 21:40:00 +02:00
|
|
|
while( !list_empty( &dialog->controls ) )
|
2005-02-02 10:55:51 +01:00
|
|
|
{
|
2005-09-16 21:40:00 +02:00
|
|
|
msi_control *t = LIST_ENTRY( list_head( &dialog->controls ),
|
|
|
|
msi_control, entry );
|
|
|
|
list_remove( &t->entry );
|
2005-02-02 10:55:51 +01:00
|
|
|
/* leave dialog->hwnd - destroying parent destroys child windows */
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( t->property );
|
|
|
|
msi_free( t->value );
|
2005-07-07 19:20:57 +02:00
|
|
|
if( t->hBitmap )
|
|
|
|
DeleteObject( t->hBitmap );
|
2005-06-23 18:43:38 +02:00
|
|
|
if( t->hIcon )
|
|
|
|
DestroyIcon( t->hIcon );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( t->tabnext );
|
|
|
|
msi_free( t );
|
2006-01-06 12:35:09 +01:00
|
|
|
if (t->hDll)
|
|
|
|
FreeLibrary( t->hDll );
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* destroy the list of fonts */
|
|
|
|
while( dialog->font_list )
|
|
|
|
{
|
|
|
|
msi_font *t = dialog->font_list;
|
|
|
|
dialog->font_list = t->next;
|
|
|
|
DeleteObject( t->hfont );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( t );
|
2005-02-02 10:55:51 +01:00
|
|
|
}
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( dialog->default_font );
|
2005-02-02 10:55:51 +01:00
|
|
|
|
2005-10-29 13:07:46 +02:00
|
|
|
msi_free( dialog->control_default );
|
|
|
|
msi_free( dialog->control_cancel );
|
2005-05-09 21:33:50 +02:00
|
|
|
msiobj_release( &dialog->package->hdr );
|
2005-01-28 13:39:57 +01:00
|
|
|
dialog->package = NULL;
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( dialog );
|
2005-01-28 13:39:57 +01:00
|
|
|
}
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
BOOL msi_dialog_register_class( void )
|
2005-01-28 13:39:57 +01:00
|
|
|
{
|
|
|
|
WNDCLASSW cls;
|
|
|
|
|
|
|
|
ZeroMemory( &cls, sizeof cls );
|
|
|
|
cls.lpfnWndProc = MSIDialog_WndProc;
|
|
|
|
cls.hInstance = NULL;
|
|
|
|
cls.hIcon = LoadIconW(0, (LPWSTR)IDI_APPLICATION);
|
|
|
|
cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
|
2005-09-23 12:47:26 +02:00
|
|
|
cls.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
2005-01-28 13:39:57 +01:00
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = szMsiDialogClass;
|
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
if( !RegisterClassW( &cls ) )
|
|
|
|
return FALSE;
|
2005-01-28 13:39:57 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
cls.lpfnWndProc = MSIHiddenWindowProc;
|
|
|
|
cls.lpszClassName = szMsiHiddenWindow;
|
2005-03-04 13:32:08 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
if( !RegisterClassW( &cls ) )
|
|
|
|
return FALSE;
|
2005-03-04 13:32:08 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
uiThreadId = GetCurrentThreadId();
|
2005-03-04 13:32:08 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
hMsiHiddenWindow = CreateWindowW( szMsiHiddenWindow, NULL, WS_OVERLAPPED,
|
|
|
|
0, 0, 100, 100, NULL, NULL, NULL, NULL );
|
|
|
|
if( !hMsiHiddenWindow )
|
|
|
|
return FALSE;
|
2005-03-04 13:32:08 +01:00
|
|
|
|
2005-04-27 12:16:57 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void msi_dialog_unregister_class( void )
|
|
|
|
{
|
|
|
|
DestroyWindow( hMsiHiddenWindow );
|
2005-10-31 16:43:39 +01:00
|
|
|
hMsiHiddenWindow = NULL;
|
2005-04-27 12:16:57 +02:00
|
|
|
UnregisterClassW( szMsiDialogClass, NULL );
|
2005-10-31 16:43:39 +01:00
|
|
|
UnregisterClassW( szMsiHiddenWindow, NULL );
|
2005-04-27 12:16:57 +02:00
|
|
|
uiThreadId = 0;
|
2005-03-04 13:32:08 +01:00
|
|
|
}
|