2010-03-24 17:22:56 +00:00
// Unicode support by Jim Park -- 08/10/2007
2008-11-29 17:56:54 +00:00
# include <windows.h>
2009-02-04 14:08:31 +00:00
# include <nsis/pluginapi.h> // nsis plugin
2008-12-12 17:39:35 +00:00
2008-11-29 17:56:54 +00:00
# include "defs.h"
# include "input.h"
# include "rtl.h"
# ifndef ODS_NOACCEL
# define ODS_NOACCEL 0x0100
# define ODS_NOFOCUSRECT 0x0200
# endif
# ifndef DT_HIDEPREFIX
# define DT_HIDEPREFIX 0x00100000
# endif
HINSTANCE g_hInstance ;
struct nsDialog g_dialog ;
extra_parameters * g_pluginParms ;
2018-11-27 22:36:58 +00:00
LPTSTR g_callbackRetVar ;
2008-11-29 17:56:54 +00:00
2015-07-27 18:24:45 +00:00
static COLORREF GetLinkColor ( )
{
COLORREF clr = GetSysColor ( COLOR_HOTLIGHT ) ;
# ifndef _WIN64
// COLOR_HOTLIGHT is Win98/2000+. GetSysColorBrush is the correct way to
// detect valid colors but here we just assume nobody uses black.
if ( ! clr ) clr = RGB ( 0 , 0 , 255 ) ;
# endif
return clr ;
}
2008-11-29 17:56:54 +00:00
struct nsControl * NSDFUNC GetControl ( HWND hwCtl )
{
2015-09-17 14:30:07 +00:00
unsigned id = ( unsigned ) ( UINT_PTR ) GetProp ( hwCtl , NSCONTROL_ID_PROP ) ;
2008-11-29 17:56:54 +00:00
if ( id = = 0 | | id > g_dialog . controlCount )
{
return NULL ;
}
return & g_dialog . controls [ id - 1 ] ;
}
2013-09-06 23:48:59 +00:00
INT_PTR CALLBACK ParentProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam )
2008-11-29 17:56:54 +00:00
{
2013-09-06 23:48:59 +00:00
INT_PTR res ;
2008-11-29 17:56:54 +00:00
if ( message = = WM_NOTIFY_OUTER_NEXT )
{
if ( wParam = = ( WPARAM ) - 1 )
{
if ( g_pluginParms - > ExecuteCodeSegment ( g_dialog . callbacks . onBack - 1 , 0 ) )
{
return 0 ;
}
}
}
res = CallWindowProc ( g_dialog . parentOriginalWndproc , hwnd , message , wParam , lParam ) ;
if ( message = = WM_NOTIFY_OUTER_NEXT & & ! res )
{
DestroyWindow ( g_dialog . hwDialog ) ;
HeapFree ( GetProcessHeap ( ) , 0 , g_dialog . controls ) ;
g_dialog . hwDialog = NULL ;
g_dialog . controls = NULL ;
}
return res ;
}
LRESULT CALLBACK LinkWndProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam )
{
struct nsControl * ctl = GetControl ( hwnd ) ;
if ( ctl = = NULL )
return 0 ;
if ( message = = WM_SETCURSOR )
{
SetCursor ( LoadCursor ( NULL , IDC_HAND ) ) ;
return TRUE ;
}
return CallWindowProc ( ctl - > oldWndProc , hwnd , message , wParam , lParam ) ;
}
2013-09-06 23:48:59 +00:00
INT_PTR CALLBACK DialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam )
2008-11-29 17:56:54 +00:00
{
switch ( uMsg )
{
// handle notifications
case WM_COMMAND :
{
HWND hwCtl = GetDlgItem ( hwndDlg , LOWORD ( wParam ) ) ;
struct nsControl * ctl = GetControl ( hwCtl ) ;
if ( ctl = = NULL )
break ;
if ( HIWORD ( wParam ) = = BN_CLICKED & & ( ctl - > type = = NSCTL_BUTTON | | ctl - > type = = NSCTL_LINK ) )
{
if ( ctl - > callbacks . onClick )
{
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) hwCtl ) ;
2008-11-29 17:56:54 +00:00
g_pluginParms - > ExecuteCodeSegment ( ctl - > callbacks . onClick - 1 , 0 ) ;
}
}
else if ( HIWORD ( wParam ) = = EN_CHANGE & & ctl - > type = = NSCTL_EDIT )
{
if ( ctl - > callbacks . onChange )
{
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) hwCtl ) ;
2010-03-24 17:22:56 +00:00
g_pluginParms - > ExecuteCodeSegment ( ctl - > callbacks . onChange - 1 , 0 ) ;
}
2008-11-29 17:56:54 +00:00
}
else if ( HIWORD ( wParam ) = = LBN_SELCHANGE & & ctl - > type = = NSCTL_LISTBOX )
{
if ( ctl - > callbacks . onChange )
{
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) hwCtl ) ;
2010-03-24 17:22:56 +00:00
g_pluginParms - > ExecuteCodeSegment ( ctl - > callbacks . onChange - 1 , 0 ) ;
}
2008-11-29 17:56:54 +00:00
}
else if ( ( HIWORD ( wParam ) = = CBN_EDITUPDATE | | HIWORD ( wParam ) = = CBN_SELCHANGE )
& & ctl - > type = = NSCTL_COMBOBOX )
{
if ( ctl - > callbacks . onChange )
{
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) hwCtl ) ;
2010-03-24 17:22:56 +00:00
g_pluginParms - > ExecuteCodeSegment ( ctl - > callbacks . onChange - 1 , 0 ) ;
}
2008-11-29 17:56:54 +00:00
}
else if ( HIWORD ( wParam ) = = STN_CLICKED & & ctl - > type = = NSCTL_STATIC )
{
if ( ctl - > callbacks . onClick )
{
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) hwCtl ) ;
2010-03-24 17:22:56 +00:00
g_pluginParms - > ExecuteCodeSegment ( ctl - > callbacks . onClick - 1 , 0 ) ;
}
2008-11-29 17:56:54 +00:00
}
break ;
}
case WM_NOTIFY :
{
LPNMHDR nmhdr = ( LPNMHDR ) lParam ;
struct nsControl * ctl = GetControl ( nmhdr - > hwndFrom ) ;
2018-11-27 22:15:26 +00:00
int * pFlag = & g_pluginParms - > exec_flags - > silent , orgFlag , ret ; // The silent flag can only be changed in .onInit and custom pages will not be displayed in silent mode so we can use this flag in the callback
2008-11-29 17:56:54 +00:00
if ( ctl = = NULL )
break ;
if ( ! ctl - > callbacks . onNotify )
break ;
2018-11-27 22:15:26 +00:00
orgFlag = * pFlag , * pFlag = 0 ;
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) nmhdr ) ;
pushintptr ( nmhdr - > code ) ;
pushintptr ( ( INT_PTR ) nmhdr - > hwndFrom ) ;
2008-11-29 17:56:54 +00:00
g_pluginParms - > ExecuteCodeSegment ( ctl - > callbacks . onNotify - 1 , 0 ) ;
2018-11-27 22:15:26 +00:00
ret = * pFlag , * pFlag = orgFlag ;
if ( ret )
2018-11-27 22:36:58 +00:00
return DlgRet ( hwndDlg , StrToIntPtr ( g_callbackRetVar ) ) ;
2008-11-29 17:56:54 +00:00
}
2018-11-27 22:15:26 +00:00
break ;
2008-11-29 17:56:54 +00:00
// handle links
case WM_DRAWITEM :
{
DRAWITEMSTRUCT * lpdis = ( DRAWITEMSTRUCT * ) lParam ;
RECT rc ;
2010-03-24 17:22:56 +00:00
TCHAR text [ 1024 ] ;
2008-11-29 17:56:54 +00:00
// http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
// says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,...) to make
// sure, does not seem to be required, might be a win2k bug, or it might
// only apply to menus
BOOL hideFocus = ( lpdis - > itemState & ODS_NOFOCUSRECT ) ;
BOOL hideAccel = ( lpdis - > itemState & ODS_NOACCEL ) ;
struct nsControl * ctl = GetControl ( lpdis - > hwndItem ) ;
if ( ctl = = NULL )
break ;
// We need lpdis->rcItem later
rc = lpdis - > rcItem ;
// Get button's text
2010-03-24 17:22:56 +00:00
text [ 0 ] = _T ( ' \0 ' ) ;
2008-11-29 17:56:54 +00:00
GetWindowText ( lpdis - > hwndItem , text , 1024 ) ;
// Calculate needed size of the control
DrawText ( lpdis - > hDC , text , - 1 , & rc , DT_VCENTER | DT_WORDBREAK | DT_CALCRECT ) ;
// Make some more room so the focus rect won't cut letters off
rc . right = min ( rc . right + 2 , lpdis - > rcItem . right ) ;
// Move rect to right if in RTL mode
if ( g_dialog . rtl )
{
rc . left + = lpdis - > rcItem . right - rc . right ;
rc . right + = lpdis - > rcItem . right - rc . right ;
}
if ( lpdis - > itemAction & ODA_DRAWENTIRE )
{
DWORD xtraDrawStyle = ( g_dialog . rtl ? DT_RTLREADING : 0 ) ;
if ( hideAccel )
xtraDrawStyle | = DT_HIDEPREFIX ;
2015-07-27 18:24:45 +00:00
// Use the system color unless the user has set another using SetCtlColors
2011-11-19 15:41:45 +00:00
if ( ! GetWindowLongPtr ( lpdis - > hwndItem , GWLP_USERDATA ) )
2015-07-27 18:24:45 +00:00
SetTextColor ( lpdis - > hDC , GetLinkColor ( ) ) ;
2008-11-29 17:56:54 +00:00
// Draw the text
DrawText ( lpdis - > hDC , text , - 1 , & rc , xtraDrawStyle | DT_CENTER | DT_VCENTER | DT_WORDBREAK ) ;
}
// Draw the focus rect if needed
if ( ( ( lpdis - > itemState & ODS_FOCUS ) & & ( lpdis - > itemAction & ODA_DRAWENTIRE ) ) | | ( lpdis - > itemAction & ODA_FOCUS ) )
{
// NB: when not in DRAWENTIRE mode, this will actually toggle the focus
// rectangle since it's drawn in a XOR way
if ( ! hideFocus )
DrawFocusRect ( lpdis - > hDC , & rc ) ;
}
return TRUE ;
}
// handle colors
case WM_CTLCOLORSTATIC :
case WM_CTLCOLOREDIT :
case WM_CTLCOLORDLG :
case WM_CTLCOLORBTN :
case WM_CTLCOLORLISTBOX :
// let the NSIS window handle colors, it knows best
return SendMessage ( g_dialog . hwParent , uMsg , wParam , lParam ) ;
// bye bye
case WM_DESTROY :
{
unsigned i ;
for ( i = 0 ; i < g_dialog . controlCount ; i + + )
{
RemoveProp ( g_dialog . controls [ i ] . window , NSCONTROL_ID_PROP ) ;
}
break ;
}
}
return FALSE ;
}
2008-12-12 18:45:53 +00:00
static UINT_PTR PluginCallback ( enum NSPIM msg )
{
return 0 ;
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) Create ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
HWND hwPlacementRect ;
RECT rcPlacement ;
EXDLL_INIT ( ) ;
2008-12-12 18:45:53 +00:00
extra - > RegisterPluginCallback ( g_hInstance , PluginCallback ) ;
2008-11-29 17:56:54 +00:00
g_dialog . hwParent = hwndParent ;
g_pluginParms = extra ;
2018-11-27 22:36:58 +00:00
g_callbackRetVar = GetVar ( variables , string_size , 31 ) ; // The undocumented $_OUTDIR variable
2008-11-29 17:56:54 +00:00
hwPlacementRect = GetDlgItem ( hwndParent , popint ( ) ) ;
GetWindowRect ( hwPlacementRect , & rcPlacement ) ;
MapWindowPoints ( NULL , hwndParent , ( LPPOINT ) & rcPlacement , 2 ) ;
g_dialog . hwDialog = CreateDialog ( g_hInstance , MAKEINTRESOURCE ( 1 ) , hwndParent , DialogProc ) ;
if ( g_dialog . hwDialog = = NULL )
{
2010-03-24 17:22:56 +00:00
pushstring ( _T ( " error " ) ) ;
2008-11-29 17:56:54 +00:00
return ;
}
SetWindowPos (
g_dialog . hwDialog ,
0 ,
rcPlacement . left ,
rcPlacement . top ,
rcPlacement . right - rcPlacement . left ,
rcPlacement . bottom - rcPlacement . top ,
SWP_NOZORDER | SWP_NOACTIVATE
) ;
2011-11-19 15:41:45 +00:00
g_dialog . parentOriginalWndproc = ( WNDPROC ) SetWindowLongPtr ( hwndParent , DWLP_DLGPROC , ( LONG_PTR ) ParentProc ) ;
2008-11-29 17:56:54 +00:00
g_dialog . rtl = FALSE ;
g_dialog . controlCount = 0 ;
g_dialog . controls = ( struct nsControl * ) HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , 0 ) ;
2008-12-12 19:52:32 +00:00
g_dialog . callbacks . onBack = 0 ;
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) g_dialog . hwDialog ) ;
2008-11-29 17:56:54 +00:00
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) CreateControl ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * className ;
TCHAR * text ;
2008-11-29 17:56:54 +00:00
HWND hwItem ;
int x , y , width , height ;
DWORD style , exStyle ;
size_t id ;
// get info from stack
2010-03-24 17:22:56 +00:00
className = ( TCHAR * ) HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , ( g_stringsize * 2 ) * sizeof ( TCHAR ) ) ;
2008-11-29 17:56:54 +00:00
text = & className [ g_stringsize ] ;
if ( ! className )
{
2010-03-24 17:22:56 +00:00
pushstring ( _T ( " error " ) ) ;
2008-11-29 17:56:54 +00:00
return ;
}
2008-12-12 17:39:35 +00:00
if ( popstringn ( className , 0 ) )
2008-11-29 17:56:54 +00:00
{
2010-03-24 17:22:56 +00:00
pushstring ( _T ( " error " ) ) ;
2008-11-29 17:56:54 +00:00
HeapFree ( GetProcessHeap ( ) , 0 , className ) ;
return ;
}
2008-12-12 17:39:35 +00:00
style = ( DWORD ) popint_or ( ) ;
exStyle = ( DWORD ) popint_or ( ) ;
2008-11-29 17:56:54 +00:00
PopPlacement ( & x , & y , & width , & height ) ;
2008-12-12 17:39:35 +00:00
if ( popstringn ( text , 0 ) )
2008-11-29 17:56:54 +00:00
{
2010-03-24 17:22:56 +00:00
pushstring ( _T ( " error " ) ) ;
2008-11-29 17:56:54 +00:00
HeapFree ( GetProcessHeap ( ) , 0 , className ) ;
return ;
}
// create item descriptor
id = g_dialog . controlCount ;
g_dialog . controlCount + + ;
g_dialog . controls = ( struct nsControl * ) HeapReAlloc (
GetProcessHeap ( ) ,
HEAP_ZERO_MEMORY ,
g_dialog . controls ,
g_dialog . controlCount * sizeof ( struct nsControl ) ) ;
2010-03-24 17:22:56 +00:00
if ( ! lstrcmpi ( className , _T ( " BUTTON " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_BUTTON ;
2010-03-24 17:22:56 +00:00
else if ( ! lstrcmpi ( className , _T ( " EDIT " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_EDIT ;
2010-03-24 17:22:56 +00:00
else if ( ! lstrcmpi ( className , _T ( " COMBOBOX " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_COMBOBOX ;
2010-03-24 17:22:56 +00:00
else if ( ! lstrcmpi ( className , _T ( " LISTBOX " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_LISTBOX ;
2010-03-24 17:22:56 +00:00
else if ( ! lstrcmpi ( className , _T ( " RichEdit " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_RICHEDIT ;
2010-03-24 17:22:56 +00:00
else if ( ! lstrcmpi ( className , _T ( " RICHEDIT_CLASS " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_RICHEDIT2 ;
2010-03-24 17:22:56 +00:00
else if ( ! lstrcmpi ( className , _T ( " STATIC " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_STATIC ;
2010-03-24 17:22:56 +00:00
else if ( ! lstrcmpi ( className , _T ( " LINK " ) ) )
2008-11-29 17:56:54 +00:00
g_dialog . controls [ id ] . type = NSCTL_LINK ;
else
g_dialog . controls [ id ] . type = NSCTL_UNKNOWN ;
// apply rtl to style
ConvertStyleToRTL ( g_dialog . controls [ id ] . type , & style , & exStyle ) ;
// create item's window
hwItem = CreateWindowEx (
exStyle ,
2010-03-24 17:22:56 +00:00
lstrcmpi ( className , _T ( " LINK " ) ) ? className : _T ( " BUTTON " ) ,
2008-11-29 17:56:54 +00:00
text ,
style ,
x , y , width , height ,
g_dialog . hwDialog ,
( HMENU ) ( 1200 + id ) ,
g_hInstance ,
NULL ) ;
g_dialog . controls [ id ] . window = hwItem ;
// remember id
SetProp ( hwItem , NSCONTROL_ID_PROP , ( HANDLE ) ( id + 1 ) ) ;
// set font
SendMessage ( hwItem , WM_SETFONT , SendMessage ( g_dialog . hwParent , WM_GETFONT , 0 , 0 ) , TRUE ) ;
// set the WndProc for the link control
if ( g_dialog . controls [ id ] . type = = NSCTL_LINK )
2011-11-19 15:41:45 +00:00
g_dialog . controls [ id ] . oldWndProc = ( WNDPROC ) SetWindowLongPtr ( hwItem , GWLP_WNDPROC , ( LONG_PTR ) LinkWndProc ) ;
2008-11-29 17:56:54 +00:00
// push back result
2013-09-06 23:48:59 +00:00
pushintptr ( ( INT_PTR ) hwItem ) ;
2008-11-29 17:56:54 +00:00
// done
HeapFree ( GetProcessHeap ( ) , 0 , className ) ;
}
// for backward compatibility (2.29 had CreateItem)
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) CreateItem ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
CreateControl ( hwndParent , string_size , variables , stacktop , extra ) ;
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) SetUserData ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
HWND hwCtl ;
struct nsControl * ctl ;
// get info from stack
2013-09-06 23:48:59 +00:00
hwCtl = ( HWND ) popintptr ( ) ;
2008-11-29 17:56:54 +00:00
if ( ! IsWindow ( hwCtl ) )
{
2013-09-06 23:48:59 +00:00
popintptr ( ) ; // remove user data from stack
2008-11-29 17:56:54 +00:00
return ;
}
// get descriptor
ctl = GetControl ( hwCtl ) ;
if ( ctl = = NULL )
return ;
// set user data
2008-12-12 17:39:35 +00:00
popstringn ( ctl - > userData , USERDATA_SIZE ) ;
2008-11-29 17:56:54 +00:00
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) GetUserData ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
HWND hwCtl ;
struct nsControl * ctl ;
// get info from stack
2013-09-06 23:48:59 +00:00
hwCtl = ( HWND ) popintptr ( ) ;
2008-11-29 17:56:54 +00:00
if ( ! IsWindow ( hwCtl ) )
{
2010-03-24 17:22:56 +00:00
pushstring ( _T ( " " ) ) ;
2008-11-29 17:56:54 +00:00
return ;
}
// get descriptor
ctl = GetControl ( hwCtl ) ;
if ( ctl = = NULL )
{
2010-03-24 17:22:56 +00:00
pushstring ( _T ( " " ) ) ;
2008-11-29 17:56:54 +00:00
return ;
}
// return user data
pushstring ( ctl - > userData ) ;
}
void CALLBACK TimerProc ( HWND hwnd , UINT uMsg , UINT_PTR idEvent , DWORD dwTime )
{
// we use a timer proc instead of WM_TIMER to make sure no one messes with the ids but us
2014-02-08 00:13:52 +00:00
g_pluginParms - > ExecuteCodeSegment ( ( int ) ( idEvent - 1 ) , 0 ) ;
2008-11-29 17:56:54 +00:00
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) CreateTimer ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
UINT callback ;
UINT interval ;
// get info from stack
callback = popint ( ) ;
interval = popint ( ) ;
if ( ! callback | | ! interval )
return ;
// create timer
SetTimer (
g_dialog . hwDialog ,
callback ,
interval ,
TimerProc ) ;
}
2010-03-24 17:22:56 +00:00
void nsdKillTimer ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
UINT id ;
// get timer id from stack
id = popint ( ) ;
// kill timer
KillTimer ( g_dialog . hwDialog , id ) ;
}
void NSDFUNC SetControlCallback ( size_t callbackIdx )
{
HWND hwCtl ;
nsFunction callback ;
nsFunction * callbacks ;
struct nsControl * ctl ;
// get info from stack
2013-09-06 23:48:59 +00:00
hwCtl = ( HWND ) popintptr ( ) ;
2008-11-29 17:56:54 +00:00
callback = ( nsFunction ) popint ( ) ;
if ( ! IsWindow ( hwCtl ) )
return ;
// get descriptor
ctl = GetControl ( hwCtl ) ;
if ( ctl = = NULL )
return ;
// set callback
callbacks = ( nsFunction * ) & ctl - > callbacks ;
callbacks [ callbackIdx ] = callback ;
}
void NSDFUNC SetDialogCallback ( size_t callbackIdx )
{
nsFunction callback ;
nsFunction * callbacks ;
// get info from stack
callback = ( nsFunction ) popint ( ) ;
// set callback
callbacks = ( nsFunction * ) & g_dialog . callbacks ;
callbacks [ callbackIdx ] = callback ;
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) OnClick ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
SetControlCallback ( CTL_CALLBACK_IDX ( onClick ) ) ;
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) OnChange ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
SetControlCallback ( CTL_CALLBACK_IDX ( onChange ) ) ;
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) OnNotify ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
SetControlCallback ( CTL_CALLBACK_IDX ( onNotify ) ) ;
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) OnBack ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
SetDialogCallback ( DLG_CALLBACK_IDX ( onBack ) ) ;
}
2010-03-24 17:22:56 +00:00
void __declspec ( dllexport ) Show ( HWND hwndParent , int string_size , TCHAR * variables , stack_t * * stacktop , extra_parameters * extra )
2008-11-29 17:56:54 +00:00
{
// tell NSIS to remove old inner dialog and pass handle of the new inner dialog
SendMessage ( hwndParent , WM_NOTIFY_CUSTOM_READY , ( WPARAM ) g_dialog . hwDialog , 0 ) ;
ShowWindow ( g_dialog . hwDialog , SW_SHOWNA ) ;
// message loop
while ( g_dialog . hwDialog )
{
MSG msg ;
GetMessage ( & msg , NULL , 0 , 0 ) ;
if ( ! IsDialogMessage ( g_dialog . hwDialog , & msg ) & & ! IsDialogMessage ( g_dialog . hwParent , & msg ) )
{
TranslateMessage ( & msg ) ;
DispatchMessage ( & msg ) ;
}
}
// reset wndproc
2011-11-19 15:41:45 +00:00
SetWindowLongPtr ( hwndParent , DWLP_DLGPROC , ( LONG_PTR ) g_dialog . parentOriginalWndproc ) ;
2008-11-29 17:56:54 +00:00
}
2012-10-13 01:47:50 +00:00
BOOL WINAPI DllMain ( HINSTANCE hInst , ULONG ul_reason_for_call , LPVOID lpReserved )
2008-11-29 17:56:54 +00:00
{
2012-10-13 01:47:50 +00:00
g_hInstance = hInst ;
2008-11-29 17:56:54 +00:00
return TRUE ;
}