diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp index f6818e70..dc837b2e 100644 --- a/Contrib/InstallOptions/InstallerOptions.cpp +++ b/Contrib/InstallOptions/InstallerOptions.cpp @@ -156,6 +156,9 @@ struct FieldType { int nParentIdx; // this is used to store original windowproc for LINK HANDLE hImage; // this is used by image/icon field to save the handle to the image + + int nField; // field number in INI file + char *pszHwndEntry; // "HWND" or "HWND2" }; // initial buffer size. buffers will grow as required. @@ -482,6 +485,9 @@ int WINAPI ReadSettings(void) { }; FieldType *pField = pFields + nIdx; + pField->nField = nCtrlIdx + 1; + pField->pszHwndEntry = "HWND"; + wsprintf(szField, "Field %d", nCtrlIdx + 1); pszAppName = szField; @@ -565,6 +571,8 @@ int WINAPI ReadSettings(void) { pNewField->rect.bottom = pField->rect.bottom; pNewField->rect.top = pField->rect.top; pField->rect.right = pNewField->rect.left - 3; + pNewField->nField = nCtrlIdx + 1; + pNewField->pszHwndEntry = "HWND2"; nNumFields++; nIdx++; } @@ -1114,6 +1122,14 @@ int WINAPI createCfgDlg() NULL ); + { + char szField[64]; + char szHwnd[64]; + wsprintf(szField, "Field %d", pField->nField); + wsprintf(szHwnd, "%d", hwCtrl); + WritePrivateProfileString(szField, pField->pszHwndEntry, szHwnd, pszFilename); + } + if (hwCtrl) { // Sets the font of IO window to be the same as the main window mySendMessage(hwCtrl, WM_SETFONT, (WPARAM)hFont, TRUE); diff --git a/Contrib/InstallOptions/Readme.html b/Contrib/InstallOptions/Readme.html index 8ba4b220..52ba41bc 100644 --- a/Contrib/InstallOptions/Readme.html +++ b/Contrib/InstallOptions/Readme.html @@ -581,6 +581,14 @@ used. specify the foreground color of the text. Format: 0xBBRRGG (hexadecimal). + +HWND
HWND2
+(output) +After initDialog returns, this will contain +the HWND of the control created by this field. It can be used +instead of FindWindow and GetDlgItem. HWND2 contains the HWND of +an additional control, such as the browse button. +

How to use

@@ -801,11 +809,9 @@ dialogs, you should use the initDialog and show functions. initDialog creates the dialog in memory, but does not show it. After calling initDialog, you can set the fonts and colors, and call show to show the dialog. initDialog pushes the HWND of the -custom dialog to the stack. To get the HWND of the controls -use:

-
-GetDlgItem (output var) (hwnd of the custom dialog) (1200 + Field number - 1)
-
+custom dialog to the stack. Control HWND's are available for each +control in the HWND entry of the corresponding field in the INI +file.

Example of using a custom font:

 Function FunctionName ;FunctionName defined with Page command
@@ -819,7 +825,7 @@ Function FunctionName ;FunctionName defined with Page command
     InstallOptions::initDialog /NOUNLOAD $PLUGINSDIR\test.ini
     Pop $R0
 
-    GetDlgItem $R1 $R0 1200 ;1200 + Field number - 1
+    ReadINIStr $R1 $PLUGINSDIR\test.ini "Field 1" "HWND"
 
     ;$R1 contains the HWND of the first field
     CreateFont $R2 "Tahoma" 10 700
diff --git a/Contrib/InstallOptions/testnotify.nsi b/Contrib/InstallOptions/testnotify.nsi
index 1f0dd690..9d421886 100644
--- a/Contrib/InstallOptions/testnotify.nsi
+++ b/Contrib/InstallOptions/testnotify.nsi
@@ -3,8 +3,6 @@
 
 !include WinMessages.nsh
 
-Var hwnd ; Window handle of the custom page
-
 ; The name of the installer
 Name "InstallOptions Test"
 
@@ -34,7 +32,7 @@ Function ShowCustom
     WriteINIStr "$PLUGINSDIR\test.ini" "Settings" "RTL" "1"
   InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\test.ini"
   ; In this mode InstallOptions returns the window handle so we can use it
-  Pop $hwnd
+  Pop $0
   ; Now show the dialog and wait for it to finish
   InstallOptions::show
   ; Finally fetch the InstallOptions status value (we don't care what it is though)
@@ -56,9 +54,9 @@ Function LeaveCustom
 supportx:
   ; Make the FileRequest field depend on the first checkbox
   ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 2" "State"
-  GetDlgItem $1 $hwnd 1204 ; PathRequest control (1200 + field 5 - 1)
+  ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 5" "HWND"
   EnableWindow $1 $0
-  GetDlgItem $1 $hwnd 1205 ; ... button (the following control)
+  ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 5" "HWND2"
   EnableWindow $1 $0
   ; Add the disabled flag too so when we return to this page it's disabled again
   StrCmp $0 0 0 +3
@@ -71,11 +69,11 @@ supportx:
 
 clearbtn:
   ; Clear all text fields
-  GetDlgItem $1 $hwnd 1204 ; PathRequest control (1200 + field 5 - 1)
+  ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 5" "HWND"
   SendMessage $1 ${WM_SETTEXT} 0 "STR:"
-  GetDlgItem $1 $hwnd 1206 ; DirRequest control (1200 + field 6 - 1 + 1 browse button)
+  ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 6" "HWND"
   SendMessage $1 ${WM_SETTEXT} 0 "STR:"
-  GetDlgItem $1 $hwnd 1209 ; Multiline control (1200 + field 8 - 1 + 2 browse buttons)
+  ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 8" "HWND"
   SendMessage $1 ${WM_SETTEXT} 0 "STR:"
   Abort ; Return to the page
 
@@ -86,9 +84,9 @@ droplist:
     StrCpy $0 0
   Goto +2
     StrCpy $0 1
-  GetDlgItem $1 $hwnd 1206 ; DirRequest control (1200 + field 6 - 1 + 1 browse button)
+  ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 6" "HWND"
   EnableWindow $1 $0
-  GetDlgItem $1 $hwnd 1207 ; ... button (the following control)
+  ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 6" "HWND2"
   EnableWindow $1 $0
   ; Add the disabled flag too so when we return to this page it's disabled again
   StrCmp $0 0 0 +3