Install Options DLL 2.0
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1948 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
20592c5e43
commit
6f600e4485
4 changed files with 74 additions and 44 deletions
|
@ -22,24 +22,27 @@ href="http://www.nullsoft.com/free/nsis/">NSIS</A> installer. Installer Options
|
|||
dialog box which will be displayed inside of the NSIS window. The dialog box is
|
||||
defined by an INI file, which allows you to define the layout of controls by
|
||||
changing the INI file.
|
||||
<P>To use the DLL, you should include it as part of your installation.
|
||||
Extract it to known location (probably $TEMP), and then load it using CallInstDLL, passing one parameter on the stack.
|
||||
The one parameter is a name of an .ini file that defines the window.
|
||||
<P>Using the new NSIS 2 plugin system, you don't have to worry about extracting and removing
|
||||
the DLL anymore. You can also use the Plugins directory to store the INI files. The contents
|
||||
of the directory will be removed when the installer is being closed.
|
||||
|
||||
Example: <PRE>
|
||||
GetTempFileName $R0
|
||||
File /oname=$R0 inst.ini
|
||||
InstallOptions::dialog $R0
|
||||
;Extract INI File to Plugins directory
|
||||
InitPluginsDir
|
||||
File /oname=$PLUGINSDIR\test.ini test.ini
|
||||
|
||||
InstallOptions::dialog $PLUGINSDIR\test.ini
|
||||
Pop $0
|
||||
; ($0 would be "success" "cancel" "back" or some other value on error.
|
||||
; ($0 would be "success" "cancel" "back" or some other value on error)
|
||||
|
||||
ReadINIStr $1 $R0 "Field 1" State ; $1 = field #1's state
|
||||
|
||||
Delete $R0
|
||||
ReadINIStr $1 $R0 "Field 1" State ; $1 = Field #1's state
|
||||
</PRE>
|
||||
It is often very useful to call InstallOptions from a NSIS custom page callback function.
|
||||
<HR>
|
||||
<A name=ini><B>INI File Settings:</B>
|
||||
<P>The INI file has one required section. This section includes the number of controls to be created as well as general window attributes. The INI file also includes a variable number of Field sections which are used to create the controls to be displayed.
|
||||
<P>The INI file has one required section. This section includes the number of controls to
|
||||
be created as well as general window attributes. The INI file also includes a variable number
|
||||
of Field sections which are used to create the controls to be displayed.
|
||||
<P>The required section is named "<I>Settings</I>". It will contain the
|
||||
following values:
|
||||
<UL>
|
||||
|
@ -117,7 +120,8 @@ numbers from 1 to NumFields. Each Field section contains the following values:
|
|||
<TR>
|
||||
<TD vAlign=top bgColor=#cccccc><B>Text</B></TD>
|
||||
<TD vAlign=top bgColor=#cccccc><I>(optional)</I></TD>
|
||||
<TD vAlign=top bgColor=#eeeeee>Specifies the caption of a label, checkbox, or radio button control. For icon and bitmaps control this specifies the path to the image.
|
||||
<TD vAlign=top bgColor=#eeeeee>Specifies the caption of a label, checkbox, or radio button control.
|
||||
For icon and bitmaps control this specifies the path to the image.
|
||||
</TD></TR>
|
||||
<TR>
|
||||
<TD vAlign=top bgColor=#cccccc><B>State</B></TD>
|
||||
|
@ -175,7 +179,8 @@ numbers from 1 to NumFields. Each Field section contains the following values:
|
|||
the bottom value and ensure it is large enough. <BR>NOTE (2):
|
||||
FileRequest and DirRequest controls will allocate 20 pixels to the
|
||||
browse button. Make this control wide enough the contents of the textbox
|
||||
can be seen. Note that you can specify negative coordinates to specify the distance from the right or bottom edge.</FONT></TD></TR>
|
||||
can be seen. Note that you can specify negative coordinates to specify the
|
||||
distance from the right or bottom edge.</FONT></TD></TR>
|
||||
<TR>
|
||||
<TD vAlign=top bgColor=#cccccc><B>Filter</B></TD>
|
||||
<TD vAlign=top bgColor=#cccccc><I>(optional)</I></TD>
|
||||
|
@ -256,7 +261,10 @@ numbers from 1 to NumFields. Each Field section contains the following values:
|
|||
list.</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></UL>
|
||||
<HR>
|
||||
<A name="ui"><B>Fonts and colors:</B>
|
||||
<P>InstallOptions supports the new UI enhancements in the new NSIS 2. To support them, InstallOptions now has two new functions, initDialog, and show. The first creates the dialog but doesn't show it. It pushes the HWND of the custom dialog to the stack. To get the HWND of any of the controls use:<BR><BR>
|
||||
<P>InstallOptions supports the new UI enhancements in the new NSIS 2. To support them,
|
||||
InstallOptions now has two new functions, initDialog, and show.
|
||||
The first creates the dialog but doesn't show it. It pushes the HWND of the custom dialog to the stack.
|
||||
To get the HWND of any of the controls use:<BR><BR>
|
||||
<PRE> GetDlgItem (output var) (hwnd of the custom dialog) (1200 + field number - 1)</PRE>
|
||||
To finally show the tweaked dialog use the show function.
|
||||
|
||||
|
@ -286,6 +294,11 @@ Here is a little example:
|
|||
<A name=history><A name=top><B>History:</B>
|
||||
<P>
|
||||
<UL>
|
||||
<LI><a name=DLL2.0>DLL version 2.0 (12/14/2002) Changes by Joost Verburg
|
||||
<UL>
|
||||
<li>Works with custom font and DPI settings
|
||||
<li>INI files should contain dialog units now, no pixels
|
||||
</UL>
|
||||
<LI><a name=DLL1.7>DLL version 1.7 beta (11/2/2002)
|
||||
<UL>
|
||||
<li>Added initDialog and show DLL functions
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*********************************************************************************
|
||||
*
|
||||
* InstallerOptions by Michael Bishop:
|
||||
* InstallerOptions/DLL Version 1.2 beta
|
||||
* Original version by Michael Bishop:
|
||||
* InstallerOptions/DLL version 2.0
|
||||
*
|
||||
* highly modified by justin frankel to go in as dll, subclass, be sexy, and whatnot.
|
||||
*
|
||||
|
@ -46,6 +46,12 @@
|
|||
*
|
||||
* - Added initDialog and show for support with NSIS's new CreateFont and SetStaticBkColor
|
||||
*
|
||||
* Version 2.0 - Changes by Joost Verburg
|
||||
*
|
||||
* - Works with custom font and DPI settings
|
||||
*
|
||||
* - INI files should contain dialog units now, no pixels
|
||||
*
|
||||
* Copyright (C) 2001 Michael Bishop
|
||||
* Portions Copyright (C) 2001 Nullsoft, Inc.
|
||||
*
|
||||
|
@ -806,8 +812,22 @@ int createCfgDlg()
|
|||
return 1;
|
||||
}
|
||||
|
||||
// by ORTIM: 14-August-2002
|
||||
DWORD dwBaseUnits = GetDialogBaseUnits();
|
||||
// By Joost Verburg 14th December 2002
|
||||
// Works with custom font & DPI settings
|
||||
// INI files should contain dialog units now
|
||||
|
||||
HDC memDC = CreateCompatibleDC(GetDC(hConfigWindow));
|
||||
SelectObject(memDC, hFont);
|
||||
|
||||
TEXTMETRIC tm;
|
||||
GetTextMetrics(memDC, &tm);
|
||||
int baseUnitY = tm.tmHeight;
|
||||
|
||||
SIZE size;
|
||||
GetTextExtentPoint32(memDC,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &size);
|
||||
int baseUnitX = (size.cx / 26 + 1) / 2;
|
||||
|
||||
DeleteDC(memDC);
|
||||
|
||||
#define DEFAULT_STYLES (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS)
|
||||
|
||||
|
@ -860,21 +880,18 @@ int createCfgDlg()
|
|||
DWORD dwStyle = ClassTable[pFields[nIdx].nType - 1].dwStyle;
|
||||
DWORD dwExStyle = ClassTable[pFields[nIdx].nType - 1].dwExStyle;
|
||||
|
||||
// by ORTIM: 14-August-2002
|
||||
// transform the pixel sizes of the widget with dialog units
|
||||
// used example code from MS SDK
|
||||
|
||||
// Changed by Dave Laundon 9th September 2002
|
||||
// Scale to pixels /before/ adjusting for negative positions
|
||||
// NB - scaling /could/ turn a -1 into 0, so use the original rect for the -ve tests
|
||||
// NB - original rect used later on too
|
||||
// By Joost Verburg 14th December 2002
|
||||
// Works with custom font & DPI settings
|
||||
// INI files should contain dialog units now
|
||||
|
||||
RECT rect;
|
||||
rect.left = (pFields[nIdx].rect.left * LOWORD(dwBaseUnits)) / 8;
|
||||
rect.right = (pFields[nIdx].rect.right * LOWORD(dwBaseUnits)) / 8;
|
||||
rect.top = (pFields[nIdx].rect.top * HIWORD(dwBaseUnits)) / 16;
|
||||
rect.bottom = (pFields[nIdx].rect.bottom * HIWORD(dwBaseUnits)) / 16;
|
||||
if (pFields[nIdx].rect.left < 0)
|
||||
|
||||
rect.left = MulDiv(pFields[nIdx].rect.left, baseUnitX, 4);
|
||||
rect.right = MulDiv(pFields[nIdx].rect.right, baseUnitX, 4);
|
||||
rect.top = MulDiv(pFields[nIdx].rect.top, baseUnitY, 8);
|
||||
rect.bottom = MulDiv(pFields[nIdx].rect.bottom, baseUnitY, 8);
|
||||
|
||||
if (pFields[nIdx].rect.left < 0)
|
||||
rect.left += dialog_r.right - dialog_r.left;
|
||||
if (pFields[nIdx].rect.right < 0)
|
||||
rect.right += dialog_r.right - dialog_r.left;
|
||||
|
|
|
@ -7,25 +7,25 @@ text=Install support for X
|
|||
left=0
|
||||
right=300
|
||||
top=0
|
||||
bottom=15
|
||||
bottom=10
|
||||
state=0
|
||||
|
||||
[Field 2]
|
||||
Type=checkbox
|
||||
text=Install support for Y
|
||||
left=0
|
||||
right=300
|
||||
top=15
|
||||
bottom=30
|
||||
right=-1
|
||||
top=13
|
||||
bottom=23
|
||||
state=1
|
||||
|
||||
[Field 3]
|
||||
Type=checkbox
|
||||
text=Install support for Z
|
||||
left=0
|
||||
right=300
|
||||
top=30
|
||||
bottom=45
|
||||
right=-1
|
||||
top=26
|
||||
bottom=36
|
||||
state=0
|
||||
|
||||
[Field 4]
|
||||
|
@ -33,8 +33,8 @@ Type=FileRequest
|
|||
State=C:\poop.poop
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=45
|
||||
Bottom=64
|
||||
Top=46
|
||||
Bottom=59
|
||||
Filter=Poop Files|*.poop|All files|*.*
|
||||
Flags=FILE_MUST_EXIST|OFN_EXPLORER|OFN_HIDEREADONLY
|
||||
|
||||
|
@ -42,13 +42,13 @@ Flags=FILE_MUST_EXIST|OFN_EXPLORER|OFN_HIDEREADONLY
|
|||
Type=DirRequest
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=65
|
||||
Bottom=84
|
||||
Top=64
|
||||
Bottom=77
|
||||
|
||||
[Field 6]
|
||||
Type=Label
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=85
|
||||
Bottom=104
|
||||
Top=87
|
||||
Bottom=97
|
||||
Text=This is a label...
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue