cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

InstallScript Project and InstallScript MSI Project: CtrlGetMultCurSel InstallScript Function Not Selecting All Items in a Loop in UI

InstallScript Project and InstallScript MSI Project: CtrlGetMultCurSel InstallScript Function Not Selecting All Items in a Loop in UI

Summary

This article discusses what to do if the CtrlGetMultCurSel InstallScript function is not selecting all items.

Project Type

InstallScript
InstallScript MSI

Symptoms

CtrlGetMultCurSel.PNG

As CUSTOMERCARE1 is already part of CUSTOMERCARE1SBOX the CtrlSetMultCurSel always highlights first one, not select all.

Diagnosis

case SELECT_ALL_BAD_BUTTON:
nResult = ListGetFirstString(lBad, szSelectAllBad);
// Loop while not at end of list.
while (nResult != END_OF_LIST)
CtrlSetMultCurSel(szDlg, LIST_BAD, szSelectAllBad, TRUE);
// Get the next string in the list.
nResult = ListGetNextString(lBad, szSelectAllBad);
endwhile;

ListDestroy(lBad_Selected);
lBad_Selected = ListCreate(STRINGLIST);
CtrlGetMultCurSel(szDlg, LIST_BAD, lBad_Selected);
nCountBadSelected = ListCount(lBad_Selected);
if (nCountBad != nCountBadSelected) then
MessageBox("Select All did not properly select all systems in the list. Please manually select the missing.", WARNING);
endif;

LB_FINDSTRING finds the first string in a list box that begins with the specified string and it finds first substring
szBadList = "CUSTOMERCARE1SBOX,CUSTOMERCARE1,CUSTOMERCARE2SBOX,CUSTOMERCARE2";

As CUSTOMERCARE1 is already part of CUSTOMERCARE1SBOX the CtrlSetMultCurSel always highlights the first one instead of selecting all.

Solution

// Included header files ----------------------------------------------------
#include "ifx.h"
#define EXIT_BUTTON 1305
#define SELECT_ALL_GOOD_BUTTON 1303
#define SELECT_ALL_BAD_BUTTON 1304

prototype dlg_GetCPSystemNames();

function NUMBER dlg_GetCPSystemNames()

STRING szDlg, szMsg;
STRING szFirstSystem, szSelectAllGood, szSelectAllBad;
BOOL bDone, bAbort;
NUMBER nReturn, nResult, nCmdValue, nCountCPSystemNames, nCountCPSelectedSystemNames, nId;
NUMBER nCountGood, nCountBad, nCountGoodSelected, nCountBadSelected;
HWND hInstance, hwndParent, hwndDlg;
LIST lGood, lBad, lGood_Selected, lBad_Selected;
STRING szGoodList, szBadList;
begin

szDlg = "_dlg_SelectAll";
nResult = EzDefineDialog(szDlg, "", "", DLG_ID_SELECTALL);

case SELECT_ALL_BAD_BUTTON:
                nResult = ListGetFirstString(lBad, szSelectAllBad);
                hwndDlg = CmdGetHwndDlg(szDlg);
                hwndCntrl = CtrlGetDlgItem("", hwndDlg, LIST_BAD);
                SendMessage(hwndCntrl, LB_SETSEL, TRUE, -1);
               
                ListDestroy(lBad_Selected);
                lBad_Selected = ListCreate(STRINGLIST);
                CtrlGetMultCurSel(szDlg, LIST_BAD, lBad_Selected);
                nCountBadSelected = ListCount(lBad_Selected);
                if (nCountBad != nCountBadSelected) then
                    MessageBox("Select All did not properly select all systems in the list. Please manually select the missing system(s) by holding the CTRL key on your keyboard and clicking with your mouse.", WARNING);
                endif;
 
end;

CtrlSetMultCurSel function uses LB_FINDSTRING message finds the first string in a list box that begins with the specified string and it finds first substring
szBadList = "CUSTOMERCARE1SBOX,CUSTOMERCARE1,CUSTOMERCARE2SBOX,CUSTOMERCARE2";

CUSTOMERCARE1 is already part of CUSTOMERCARE1SBOX the CtrlSetMultCurSel always highlights first one

hwndDlg = CmdGetHwndDlg(szDlg);
hwndCntrl = CtrlGetDlgItem("", hwndDlg, LIST_BAD);
SendMessage(hwndCntrl, LB_SETSEL, TRUE, -1);

Adding the code, referenced above, should fix the problem.

Also, hwndCntrl needs to be defined at the top:

HWND hInstance, hwndParent, hwndDlg, hwndCntrl;

No ratings
Version history
Last update:
‎Feb 25, 2021 08:22 AM
Updated by: