How to initialize checkbox value in installshield - installshield

How to set initial value of a check box (Checked/NotChecked) in InstallShield 2010.
I added CheckBox to the Form, during adding I let for creation of custom property (I named it ISCHECKED). I set Value to 1, so when checbox is checked then this property has value equal to 1.
When I run installer I CheckBox is always checked and I want to have it unchecked, what should I do. I tried to modify this custom property and set value to different values in property manager but without luck. I know that when I click on the CheckBox it modifies this property value (I enable / disable other UI elements).

A checkbox is checked when its property is set and unchecked when the property is empty.
To make it unchecked by default, make sure that its property is not initialized to a value. Only associate the property to your checkbox, but do not set its value to "1".

I worked around this by creating a CheckBoxGroup with two checkboxes. One "Yes" and one "No" where "Yes" had the value 1 and "No" was value 0.

As I said in my comment this is still an issue in InstallShield 2018. Here's the workaround I came up with. I created two custom action scripts. One for translating from "0" and "1" to empty "" and "1" and another script for translating back to "0" and "1". I created custom actions TranslateChkBoxesZeroToEmptyAction and TranslateChkBoxesEmptyToZeroAction that call functions TranslateChkBoxesZeroToEmpty and TranslateChkBoxesEmptyToZero respectively.
I call TranslateChkBoxesZeroToEmptyAction In Behavior and Logic:Custom Actions and Sequences:Sequences:Installation:User Interface just after SetupCompleteSuccess and before AppSearch. I call TranslateChkBoxesEmptyToZeroAction just after MaintenanceWelcome and before SetupProgress.
So the affect is to convert "0" strings to empty"" before the dialog is opened and to convert empty "" to "0" after the dialog closes
===setup.rul====
export prototype ForceEmptyToZero(HWND, STRING);
export prototype ForceZeroToEmpty(HWND, STRING);
export prototype TranslateChkBoxesEmptyToZero(HWND);
export prototype TranslateChkBoxesZeroToEmpty(HWND);
// **********************************************************************
// function ForceEmptyToZero -- Convert "" to "0"
//
// This function must be called on each CheckBox property after closing
// the dialog that contains the checkbox. It converts empty "" string
// to "0" in order to be compatible with InstallShield logic for checkboxes.
//
// 2018Aug02jdn Created by Jon D. Newbill / www.bitworkssystems.com
// **********************************************************************
function ForceEmptyToZero(hMSI, propStr)
STRING valStr;
NUMBER strLen;
begin
strLen = 100;
MsiGetProperty(hMSI, propStr, valStr, strLen);
// If not "1" then assume false and force to "0"
if (valStr != "1") then
valStr = "0";
MsiSetProperty(hMSI, propStr, valStr);
endif;
end;
// **********************************************************************
// function ForceZeroToEmpty- Convert "0" to ""
//
// This function must be called on each CheckBox property before opening
// the dialog that contains the checkbox. It converts "0" string to
// empty "" in order to be compatible with InstallShield logic for
// checkboxes.
//
// 2018Aug02jdn Created by Jon D. Newbill / www.bitworkssystems.com
// **********************************************************************
function ForceZeroToEmpty(hMSI, propStr)
STRING valStr;
NUMBER strLen;
begin
strLen = 100;
MsiGetProperty(hMSI, propStr, valStr, strLen);
// If not "1" then assume false and force to empty string ""
if (valStr != "1") then
valStr = "";
MsiSetProperty(hMSI, propStr, valStr);
endif;
end;
// **********************************************************************
// function TranslateChkBoxesZeroToEmpty -- Convert "0" to ""
//
// This function must be called before the OptionSelection dialog is
// run. This function converts all CheckBox properties from values of
// "0" or "1" to empty string "" or "1" respectively. This is done to
// deal with an anomaly in the way InstallShield handles CheckBoxes
// assigned to properties. Checkboxes are unchecked only when
// associated property is an empty string "" and checked for any other
// non-empty string.
//
// https://stackoverflow.com/questions/6877011/how-to-initialize-checkbox-value-in-installshield
//
// So we must convert all "0" strings to "" empty string before the
// OptionSelection dialog runs and then convert all "" to "0" after the
// dialog closes.
//
// 2018Aug02jdn Created by Jon D. Newbill / www.bitworkssystems.com
// **********************************************************************
function TranslateChkBoxesZeroToEmpty(hMSI)
STRING valStr;
NUMBER strLen;
begin
ForceZeroToEmpty(hMSI,"TIMESTAMP");
ForceZeroToEmpty(hMSI,"HIDECAPWIN");
ForceZeroToEmpty(hMSI,"FINDVCP");
ForceZeroToEmpty(hMSI,"LCDACCEPT");
ForceZeroToEmpty(hMSI,"SERNUM");
ForceZeroToEmpty(hMSI,"TOPWIN");
ForceZeroToEmpty(hMSI,"ZOOM");
ForceZeroToEmpty(hMSI,"ACCEPTCLOSE");
end;
// **********************************************************************
// function TranslateChkBoxesEmptyToZero -- Convert "" to "0"
//
// This function must be called after the OptionSelection dialog closes.
// This function converts all CheckBox properties from values of empty
// string "" or "1" to "0" or "1" respectively. This is done to deal
// with an anomaly in the way InstallShield handles CheckBoxes assigned
// to properties. Checkboxes are unchecked only when associated
// property is an empty string "" and checked for any other non-empty
// string.
//
// https://stackoverflow.com/questions/6877011/how-to-initialize-checkbox-value-in-installshield
//
// So we must convert all "0" strings to "" empty string before the
// OptionSelection dialog runs and then convert all "" to "0" after the
// dialog closes.
//
// 2018Aug02jdn Created by Jon D. Newbill / www.bitworkssystems.com
// **********************************************************************
function TranslateChkBoxesEmptyToZero(hMSI)
STRING valStr;
NUMBER strLen;
begin
ForceEmptyToZero(hMSI,"TIMESTAMP");
ForceEmptyToZero(hMSI,"HIDECAPWIN");
ForceEmptyToZero(hMSI,"FINDVCP");
ForceEmptyToZero(hMSI,"LCDACCEPT");
ForceEmptyToZero(hMSI,"SERNUM");
ForceEmptyToZero(hMSI,"TOPWIN");
ForceEmptyToZero(hMSI,"ZOOM");
ForceEmptyToZero(hMSI,"ACCEPTCLOSE");
end;
FROM MICROSOFT LINK:
"This CheckBox_control is a two-state check box. To associate an integer or string property with this control, enter the property name into the Property column of the Control table. The selected state of the box sets the property either to the value specified in the Value column of the CheckBox table or to the initial value of the property specified in the Property table. If the property has no initial value, the checked state sets it to 1. The unselected state sets the property to null."
The terminology is confusing. What do they mean by "The selected state"? Do they mean the "Checked state"? And then it says it sets to EITHER the Value column or the initial [default] property value. Well which is it? It can't be both. From my experience the CHECKED state sets to the Value field of the CheckBox properties table and the UNCHECKED state always sets property to empty string "". The above text also fails to describe how the initial display state of the CHECKBOX is defined from the associated property by non-empty string = CHECKED and empty string = UNCHECKED. It only describes the action of setting the property on closing of dialog window.

I found the answer on:
https://resources.flexera.com/web/pdf/archive/check.pdf
For any type of control, the initial value or state of the control is
defined by the corresponding property's value. The value can be set in
the Property table. In the case of a check box control, the initial
state can be checked (selected) or unchecked (cleared): To have the
check box initially checked, use the Property Manager view of the
InstallShield environment to set the property (CHECKBOXPROP) to the
same value you defined in the check box control's Value setting (1, in
this example). To have the check box initially unchecked, delete the
property (CHECKBOXPROP) from the Property Manager view.
This helped me at least for the VIEW.

In the View List under Behavior and Logic, click Property Manager.
Set the Value to 1 which property you want.

Related

Matlab - Display trailing edge of a long strings in a listbox by hovering the mouse over the string

I have a Matlab listbox on which some strings are very long. I do not want to make listbox too wide just only because of these few long strings.
Is there anyway to display trailing edge of these long strings in my listbox by simply hovering the mouse over those strings without using scroll pane?
Perhaps, you can set the TooltipString property of your listbox. This is what is displayed when you hover the cursor on some object. It will not be a nice or user friendly but is better than nothing.
%Create a listbox
myListbox = uicontrol('Style','listbox');
set(myListbox,'TooltipString','','Callback',#listboxCB);
%Callback function called each time the listbox value is changed
%It should also be called whenever the 'String' property is updated
function listboxCB(obj,evt)
%Get the value
v=get(obj,'Value');
if isempty(v)
set(myListbox,'TooltipString','');
return;
end
%Get the string corresponding to that line
str = get(obj,'String');
str = str{v(1)}; %Show the first one (if 'multiselect' = 'on')
set(myListbox,'TooltipString',str);
end
There may be some clever way by interacting directly with the underlying Java objects.
See Jan's answer using Java objects. Worked great.
% Prepare the Matlab listbox uicontrol
hFig = figure;
listItems = {'apple','orange','banana','lemon','cherry','pear','melon'};
hListbox = uicontrol(hFig, 'style','listbox', 'pos',[20,20,60,60], 'string',listItems);
% Get the listbox's underlying Java control
jScrollPane = findjobj(hListbox);
% We got the scrollpane container - get its actual contained listbox control
jListbox = jScrollPane.getViewport.getComponent(0);
% Convert to a callback-able reference handle
jListbox = handle(jListbox, 'CallbackProperties');
% Set the mouse-movement event callback
set(jListbox, 'MouseMovedCallback', {#mouseMovedCallback,hListbox});
% Mouse-movement callback
function mouseMovedCallback(jListbox, jEventData, hListbox)
% Get the currently-hovered list-item
mousePos = java.awt.Point(jEventData.getX, jEventData.getY);
hoverIndex = jListbox.locationToIndex(mousePos) + 1;
listValues = get(hListbox,'string');
hoverValue = listValues{hoverIndex};
% Modify the tooltip based on the hovered item
msgStr = sprintf('<html>item #%d: <b>%s</b></html>', hoverIndex, hoverValue);
set(hListbox, 'Tooltip',msgStr);
end % mouseMovedCallback
https://www.mathworks.com/matlabcentral/answers/436048-display-trailing-edge-of-a-long-strings-of-a-listbox-by-hovering-the-mouse-over-the-string#answer_352806

Powerapps Visible function

For some reason the Visible function in my Powerapps won't work I just wrote in OnSelect() Mail.Visible = false
The Mail is in this case a Textinput/ TextBox.
When I click on the button nothing happens. I can't find a documentation about it on the MS Website but I have in Powerapps a fuction called "Visible"
You need to create a variable in the button's (or another control) OnSelect property:
UpdateContext({ mailVisible: false })
And set the Visible property of the Mail control to mailVisible. You may need to initialize that variable to true, for example, in the screen's OnVisible property:
UpdateContext({ mailVisible: true })
PowerApps works similarly to Excel - you cannot, by an action, change directly the value of a cell (e.g., A1 = 42). But you can make the A1 cell reference another cell (say, =A4), so when you change the value of the cell A4, A1 will be updated as well. The same principle applies in PowerApps - you cannot change the value of a property from an action, but you can update the value that the property references.
Credit #SeaDude
This worked perfectly for me toggling the variable back and forth to show/hide a few layers.
Set(mailVisible, !mailVisible)
So I have a few items like this. I'm not sure if this is the BEST way but I know it works.
Set a variable on the app start:
App = Set(variable_visable, "");
Button code:
Onselect = Set(variable_visable.,"1");
Item that you want visible:
Visibility = If(variable_visable="1", true, false);
Edit: You can reset your variable at any point to hide that section.
Sometimes power apps fights you on things that seem correct.
The Visible will the condition that is true to make it show.
For example
If I have one TextBox named TextInput1 and I want a control to be visible when the Text entered = true it will be. For this example use a label.
Label1's visible function will be TextInput1.Text = "true"
This will show when the input text will be true. if it's false or anything else the label won't show. This is a very basic use of the visible but can be used in many ways.
In On select property of button you can't set any other control property directly.
you need to follow the steps as:
1- you need to set a boolean type variable on OnSelect of button e.g.
Set(varShowMail,false)
2- go to TextInput Mail and select its Visible property and assign the variable "varShowMail"
It will work 100%.
Set on visible of screen property UpdateContext({ Var_Visible: false})
set a variable on control "select" or "change" to true"UpdateContext({ Var_Visible: true})" and use the variable in other control visible property that you want to show or hide, if required you can use condition to set a variable to true or false

How to wait for user input inside function using c#

I have One Window application by Which User Can Print Their Product Barcode Value And Also Can Scan it,
Now i am searching for some threading or some other way,
If user Enter 5 value for Print after Printing First value, Function wait for user input in text box (i call textbox up event for capturing scanning value)
and if value is correct so, my function continue its execution or wait until user Scan Proper barcode,
so how can i make method or function which can wait for user input and then continue executions.
private void myFunction1()
{
for (i = 0; i < intPrintNo; i++) // Number Of Print
{
// here I write Code For Print My Barcode
// Now I want to wait For user Input in my text box
jumphere :
txtBarcode.Text = "";
txtBarcode.Enabled = true;
txtBarcode.Visible = true;
txtBarcode.Focus();
if (keyUp()== false)
{
txtBarcode.Text = "";
txtBarcode.Enabled = true;
goto jumphere;
}
// If return True than for loop Continue for next Printing
}
}
From what i've understood from your question, you want to print the barcode of value specified by the user and then user can scan the same to verify if printed properly or not.
You can achieve this functionality in Windows forms using following steps
User enters the value (to print barcode) in txtInput
Presses print button (btnPrint)
The print button event handler will first disable itself and the input textbox (btnPrint.Enabled = txtInput.Enabled = false; Application.DoEvents();) and then print the barcode and set focus on textbox txtVerify.
User will scan the barcode in textbox txtVerify.
User will click on verify button (btnVerify) which will compare the value in txtInput and txtVerify.
If everything fine, clear the txtInput, txtVerify, enable txtInput and btnPrint, set focus to txtInput for next value
If error, do the needful.
EDIT: As per OPs comment (minimum user effort)
You can change the setting of barcode scanner to suffix newline (Enter) after every scan (you can find how to do this setting in the manual provided with the barcode)...... so now,
step 4. User will scan the barcode in textbox txtVerify (the scanning will provide Enter press at the end of scan). txtVerify.TextChanged event handler will check if key pressed in Enter, if so, call the code to verify (compare the values in txtInput and txtVerify)
step 5. Remove this step from above
step 6. If everything fine, clear the txtInput, txtVerify, enable txtInput and btnPrint, set focus to txtInput for next value
step 7. If error, do the needful.
Also, you can modify the first textbox to print the barcode when user presses enter key (so, no need to click on Print button)
So, after above modifications, the user will enter the text press enter (this will print barcode) then scan (as focus is already in txtVerify). If everything is fine, new value can be entered.
To reset the screen, you can provide a 'Reset' button.
Glad to help! Please remember to accept the answer if you found it helpful.

Using multiple values field in Lotus Notes

I am trying to write a logging system for a form in Lotus Notes but I am at the part where I am not sure how I can append the information about the fields that are changed in the log fields. There are 3 fields that I use Log_Date (date), Log_User and Log_Actions (Text, allow multiple values).
I thought if I add comma to the log field it will create a new line when displaying the form but I am still getting a type mismatch on the case 2 line.
How can I append the new values to the log fields?
Sub Querysave(Source As Notesuidocument, Continue As Variant)
' Compare the values in the form after it is saved with its original values when the document is not a new document.
Dim doc As NotesDocument
Set doc = Source.Document
Dim session As New NotesSession
Dim user As String
user = session.CommonUserName
If newDoc Then
doc.Log_Date = Now()
doc.Log_User = user
doc.Log_Actions = "New document created."
Else
' Load fields value to the array
lastValues(0) = doc.QCR_No(0)
lastValues(1) = doc.QCR_Mobile_Item_No(0)
lastValues(2) = doc.QCR_Qty(0)
' Compared each value in the array to see if there is any difference
Dim i As Integer
For i = 0 To 2
If lastValues(i) <> originalValues(i) Then
Select Case i
Case 2 : doc.Log_Actions = doc.Log_Actions & "," & "Field QCR_Qty is changed"
End Select
End If
Next
End If
End Sub
doc.Log_Actions returns the notesitem. To access the value you need to use doc.Log_Actions(0)
In LotusScript back-end classes (e.g. NotesDocument, NotesItem), a multi-valued field is represented by an array with one value per element of the array. For setting the value of a field, doc.Log_Actions is shorthand (they call it 'extended syntax' in the Domino Designer help) for assigning the first (i.e., zero subscript) element of the array, but that does not work for getting the value. To get the first value, you have to use doc.Log_Actions(0). To get or set the second value, you have to use doc.Log_Actions(1).
So, your Case 2 code could look like this:
doc.Log_Actions(1) = "Field QCR_Qty is changed"
My guess, however, is that you really want to be able to continually append to the end of the list of values each time this code runs. You are also going to want your code to be robust and not blow up on you if (for any reason!) the Log_Actions item does not exist in the document. For that, you are going to want to do this:
dim actionsItem as NotesItem
if doc.hasItem("Log_Actions") then
set actionsItem = doc.getFirstItem("Log_Actions")
call actionsItem.AppendToTextList("Field QCR_Qty is changed")
end if
Or,
If (Not doc.HasItem("LogActions")) Then
doc.LogActions = "Field QCR_Qty is changed"
Else
doc.LogActions = ArrayAppend(doc.LogActions,"Field QCR_Qty is changed")
End If
This is equivalent to the NotesItem method by rhsatrhs, which you use is matter of preference.

how to save null value in subsonic

Dim xbg As Rm
xbg.LobId = cmb_lob.SelectedValue
xbg.Mobile = mobno.Text
xbg.BusinessFax = faxno.Text
xbg.BusinessPhone = phno.Text
xbg.Save()
I have a combo box, which is not mandatory while input in the module. therefore user can select blank value in combo cox for which i want to save null in Oracle Database for that record. I had trid with following condition but fails to get result. you are requested to please help
if cmb_lob.selectedindex=-1 then
xbg.lob=dbnull
else
xbg.LobId = cmb_lob.SelectedValue
Actual Problem arises when first user save record with selection in Combo box then user edit that record and select blank from Combo box. now i have to replace value of combox box with null at database.
Set it to null or whatever VB considers null - it will be set in the DB that way.
try:
if cmb_lob.selectedindex <> -1 then
xbg.LobId = cmb_lob.SelectedValue
else
xbg.LobId = Nothing 'suggested by John Shean (see comments)
So that if the value is selected only then assign it to field else leave it as it is (null)
Try xbg.LobId = Nothing instead –
By John Sheehan

Resources