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

CtrlGetText problem

Hi all,

I have problem with getting value from dialog. I would like to get text from Customer Information dialog, but I always get empty value. Does CtrlGetText only works with user created dialogs? Here is my code (temp1 is string):

Dlg_SdCustomerInformationEx:
nResult = SdCustomerInformationEx(szTitle, svName, svCustomer, szSerial, nUser );
if (nResult = NEXT) then
CtrlGetText("SdCustomerInformationEx", 302, temp1);
MessageBox(temp, INFORMATION);
endif;

Can anyone help me how to read values from edit box?
Labels (1)
0 Kudos
(7) Replies
RobertDickau
Flexera Alumni

Right, CtrlGetText and the like work only while the dialog function is running (before EndDialog and ReleaseDialog are called). What value are you trying to get? The variables passed in as arguments (svName, etc.) should give you access to what the user types at run time...
0 Kudos
_Peter_
Level 4

I have a custom dialog where user inserts server name, database name, olap server, olap catalog. I succeeded to create this dialog and to pass values. But I have another problem. MsiGetProperty returns only half value. Example

Property Value
MyProp1 OLAP_Server


returns me only OLAP_S. I get property with:
MsiGetProperty(ISMSI_HANDLE, "SERVERNAME", sServer, size);

changing value size also doesn't help. Any idea?
0 Kudos
RobertDickau
Flexera Alumni

Does the return value from MsiGetProperty tell you anything? Could you post more of the code surrounding your MsiGetProperty call?
0 Kudos
_Peter_
Level 4

Ok, here is more of the code. I don't know why i get only half of strings back.

Dlg_SdCustomerInformationEx:
size = 256;
MsiGetProperty(ISMSI_HANDLE, "SERVERNAME", sServer, size);
MsiGetProperty(ISMSI_HANDLE, "DATABASENAME", sDB, size);
MsiGetProperty(ISMSI_HANDLE, "OLAPSERVERNAME", sOlap, size);
MsiGetProperty(ISMSI_HANDLE, "OLAPDATABASENAME", sCatalog, size);
nResult = PeterDialog(sServer, sDB, sOlap, sCatalog);
if (nResult = BACK) goto Dlg_SdRegisterUserEx;

In property manager i have values:
SERVERNAME: Main_Server
DATABASENAME: GSSDB
OLAPSERVERNAME: OLAP_Server
OLAPDATABASENAME: GSSDB_OLAP

What I get back with reading is:
SERVERNAME: Main_Server
DATABASENAME: GSSDB
OLAPSERVERNAME: OLAP_S
OLAPDATABASENAME: GSSDB

And one funny thing. If I click on this dialog Next and then back, values are changes, like:
SERVERNAME: Main_Server
DATABASENAME: GSSDB
OLAPSERVERNAME: OLAP
OLAPDATABASENAME: GSS

??:(
0 Kudos
_Peter_
Level 4

I fixed the problem. You have to declare size for every MsiGetProperty call, like this:

size = 256;
MsiGetProperty(ISMSI_HANDLE, "SERVERNAME", sServer, size);
size = 256;
MsiGetProperty(ISMSI_HANDLE, "DATABASENAME", sDB, size);
size = 256;
MsiGetProperty(ISMSI_HANDLE, "OLAPSERVERNAME", sOlap, size);
size = 256;
MsiGetProperty(ISMSI_HANDLE, "OLAPDATABASENAME", sCatalog, size);


🙂
0 Kudos
RobertDickau
Flexera Alumni

Exactly right; on successful return, the buffer-size variable is set to the size of the data in the property value, meaning that reading a short property value followed by reading a long property value (without resetting the buffer size) will cause the second value to be cut off.
0 Kudos
charlieantao
Level 6

This is the model I follow when calling MsiGetProperty:

szInstSource = "";
nvBufferSize = 0;

// Make first call to get the actual buffer size
// required for the SourceDir property
MsiGetProperty( ISMSI_HANDLE, "SourceDir", szInstSource, nvBufferSize );

// Increment size to account for the NULL terminator
// and then resize the string buffer
nvBufferSize++;
Resize( szInstSource, nvBufferSize );

// Make a second call to get the actual value
// of the SourceDir property
MsiGetProperty( ISMSI_HANDLE, "SourceDir", szInstSource, nvBufferSize );
0 Kudos