05-20-2008 10:08 AM
05-20-2008 10:17 AM
You cannot obtain exact alignment with in a textbox if you use a proportional font, since character lenght is not a fixed value but depends on the character being displayed.
If you want to continue using a textbox you must use a fixed font like for example NIEditor. One alternative can be to switch to a listbox and use escape codes ( \033pxxxc ) to align your texts; with a listbox you can additionally modify foreground and background colors so to add some relevance to pass and fail evidences. Another alternative could be to use a table instead of a listbox, with additional possiblities like using different fonts from cell to cell or bold characters and so on.
05-20-2008 10:18 AM - edited 05-20-2008 10:20 AM
The easiest way is just to use a fixed width font, such as Courier. If you have enough time, you might consider using a ListBox control instead, which allows you to embed formatting characters for pixel alignment, colour settings, column separators etc.
JR
EDIT: Must type quicker.. Must type quicker.. Must type quicker... ![]()
05-20-2008 12:39 PM
Thanks for the quick response. The font changed fixed the problem even though it is a kind of an ugly font. I will also try the listbox option.
04-07-2009 03:42 AM
I am new in CVI. I have a simpl question around textbox.
- any time i need to find out what is the last char in the TEXTBOX. I know the technick copy from
textbox to the string. But can any getctrlval gives the pointer to the text in the textbox ? any other
simpl trick to get last char in the textbox ?
regards smile
04-07-2009 04:09 AM
I'm not aware of a way to directly getting the last character in a textbox.
If you want to reduce the amount of text read from the control, you can use GetNumTextBoxLines to get the number of lines in the textbox and GetTextBoxLine to retrieve the last one.
If you only want to append text to the control, please note that you can use SetCtrlVal to obtain it, while ResetTextBox replaces all the contents of the control with the text passed to the function.
04-08-2009 07:32 AM
Hello ) new problem ,
nt CVICALLBACK Key (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int numBytes;
int numLines=0;
char a[1024];
char msg[1024];
char sg2[1024];
switch (event)
{
case EVENT_VAL_CHANGED :
GetCtrlAttribute (panel1, PANEL1_TEXTBOX, ATTR_STRING_TEXT_LENGTH, &numBytes);
GetCtrlVal(panel1, PANEL1_TEXTBOX, &a[0]);
GetNumTextBoxLines (panel1, PANEL1_TEXTBOX, &numLines);
Fmt (msg, "bytes = %d, Lines = %d", numBytes, numLines);
GetTextBoxLine (panel1, PANEL1_TEXTBOX, numLines, sg2); // line 494
MessagePopup ("The key entered", a);
MessagePopup ("Bytes in the text: ", msg);
MessagePopup ("Last line content: ", sg2);
break;
}
return 0;
}
NON-FATAL RUN-TIME ERROR: "test.c", line 494, col 9, thread id 0x000003BC: Library function error (return value == -55 [0xffffffc9]). The index passed is out of range.
Why this error ? Please tell me ...
regards Smile_
04-08-2009 08:46 AM
If there are 10 lines in a text box and you want the last one, you need to ask for line number 9. (The indexing is 0-based.) So just change your code to ask for numLines - 1.
JR
04-09-2009 07:56 AM
hi, me again ).
tnx jr_
new trouble:
CODE:
InstallComCallback (comport_R, LWRS_RXCHAR, 0, EventChar_Right[0], Event_Char_Right_Fun, NULL); // line 230
void CVICALLBACK Event_Char_Right_Fun (int portNo,int eventMask,void *callbackData)
{
char outMessage[256];
char readBuf[20] = {0};
int strLen;
return;
}
& Errors:
230, 81 Undeclared identifier 'Event_Char_Right_Fun'.
230, 101 Type error in argument 5 to `InstallComCallback'; found 'int' expected 'ComCallbackPtr'.
QUESTION:
Why it found int, I copied from example, what is wrong ??
regards Smile_
04-09-2009 08:31 AM
Probably because, at the time the compiler found the first reference to Event_Char_Right_Fun it hadn't yet seen your definition of it. Simply provide the compiler with a function prototype first. Like this:
// This next line pre-warns the compiler about Event_Char_Right_Fun before you have fully defined it
void CVICALLBACK Event_Char_Right_Fun (int portNo,int eventMask,void *callbackData) ;
InstallComCallback (comport_R, LWRS_RXCHAR, 0, EventChar_Right[0], Event_Char_Right_Fun, NULL);
void CVICALLBACK Event_Char_Right_Fun (int portNo,int eventMask,void *callbackData)
{
char outMessage[256];
char readBuf[20] = {0};
int strLen;
return;
}
JR