- CVI 정보나눔(www.cvi.kr)
- 스터디
- 질문답변
질문,답변
글 수 1,629
김충영님께서 남기신 글입니다.
> 아직도 Table Control은 약간의 에러가지고 있는 것 같습니다.
> 전혀 함수에 오류가 없는데도 에러가 날때가 가끔 있읍니다.
>
> void FillTable (int panel, int control)
> {
> char *_TESTBENCH[44][6]={
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//2
> {"OFF","OFF","OFF","OFF","ON", "OFF"},
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//4
> {"OFF","OFF","OFF","OFF","ON", "OFF"},
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//6
> {"OFF","OFF","OFF","OFF","ON", "ON" },
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//8
> {"OFF","OFF","OFF","OFF","ON", "ON" },
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//10
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//12
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"ON", "OFF","OFF","OFF","OFF","OFF"},//14
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"ON", "OFF","OFF","OFF","OFF","OFF"},//16
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"OFF","ON", "OFF","OFF","OFF","OFF"},//18
> {"OFF","ON", "OFF","OFF","OFF","OFF"},
> {"OFF","ON", "OFF","OFF","OFF","OFF"},//20
> {"OFF","ON", "OFF","OFF","OFF","OFF"},
> {"OFF","ON", "OFF","OFF","OFF","OFF"},//22
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"ON", "OFF","OFF","OFF","OFF","OFF"},//24
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//26
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//28
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","ON", "OFF","OFF"},//30
> {"OFF","OFF","OFF","ON", "OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//32
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//34
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//36
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//38
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//40
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//42
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"}};//44
> int nCol, nRow;
> int Column, Row;
> int cellColor[] = {VAL_LT_GRAY, VAL_YELLOW};
> int i;
>
> Row = 44;
> Column = 6;
>
> GetNumTableRows (panel, control, &nRow);
> GetNumTableColumns (panel, control, &nCol);
>
> if (nCol>Column)
> DeleteTableColumns (panel, control, Column, nCol-Column);
> if (nRow>Row)
> DeleteTableRows (panel, control, Row, nRow-Row);
>
> if (nCol<Column)
> InsertTableColumns (panel, control, (!nCol ? 1 : nCol),
> Column-nCol, VAL_CELL_STRING);
> if (nRow<Row)
> InsertTableRows (panel, control, (!nRow ? 1 : nRow), Row-nRow,
> VAL_CELL_STRING);
> // 보통은 현재 있는 셀들을 모두 지우고 다시 만드는 것이 편리한데
> 그렇게 하면 에러가 발생합니다. 제가 찾은 방법이 위 처럼 하는
> 것인데 내용을 보면 이해할수 있으리라 생각 됩니다.
>
> SetTableColumnAttribute (panel, control, -1, ATTR_LABEL_BOLD, 1);
> SetTableRowAttribute (panel, control, -1, ATTR_LABEL_BOLD, 1);
> SetTableCellRangeAttribute (panel, control, ABLE_ENTIRE_RANGE,
> ATTR_CELL_JUSTIFY, VAL_CENTER_CENTER_JUSTIFIED);
> // 위의 함수들은 Column,Row의 글자를 Bold로 만들고 셀에서
> 값의 위치를 정 중앙으로 만듭니다.
>
> SetTableCellRangeVals (panel, control, MakeRect (1, 1, Row,
> Column), (char **)_TESTBENCH, VAL_ROW_MAJOR);
> // 이 함수에서는 셀에 데이타를 입력하는데 변수가 3차원 포인터인데
> 2차원 포인터로 Type Casting을 하였기 때문에 Direction값이
> VAL_COLUMN_MAJOR이 아니고 VAL_ROW_MAJOR로 하여야
> 됩니다. 직접 해보시면 데이타 배열이 이상한 것을 알수 있읍니다.
>
> for (i=1; i<45; i++) {
> //SetTableCellRangeVals (panel, control, MakeRect (i, 1, 1,
> //Column), (char **)_TESTBENCH[i-1],
> //VAL_COLUMN_MAJOR);
> // 데이타를 한 줄별로 입력할때는 위와 같이 하면 됩니다.
>
> SetTableCellRangeAttribute (panel, control, MakeRect (i, 1, 1,
> Column), ATTR_TEXT_BGCOLOR, cellColor[i%2]);
> }
> }
>
> 그럼 많은 도움이 되시길 바라며...
>
하하...테이블에 잘 들어갑니다... 감사합니다...
야린...딴 거..다..빼구...
데이터 선언할때에....3차 배열(char _TESTBENCH[44][6][3])을 안하고
충영님 갈켜주신 대로.. 2차원 배열 포인터(char *_TESTBENCH[44][6])를 사용했습니다...
즉..결론은 데이터 선언할때에...3차배열은 안되는군요...포인터를 사용해야
한다는 건지....
그리고 일단 TABLE속성은 UIR만들때..해놓아서...그래서 뺐습니다..
그리고 VAL_ROW_MAJOR은..쩝...야리가...HELP를 잘못봤는지...
ROW방향으로 하는게 원래 야리가 의도했던것과 맞더군요..^^;;
그래서..아래의 한줄만 사용했습니다...
SetTableCellRangeVals (panel, control, MakeRect (1, 1, 44,6), (char **)_TESTBENCH, VAL_ROW_MAJOR);
감사합니다...
그런데...하나의 어려운점이 또 있군요....
위의 데이터에서 "ON"과 "OFF"의 색깔을 구분해서 TABLE에 넣고 싶은데..
쩝...그럴려면...
데이터를 셀별로 일일이 하나하나씩..검사해서... 셀 속성을 따로 줘야 겠군요....아구..이거..장난 아닌데...속도도..그렇고...(사실 테이블에 하나하나씩..넣을때...속도가 그다지 안빠르더라구요...데이터가 채워지는게..눈에보여서리.....--;)
그리고...데이터를 검사할려면 위의 CHAR의 "ON","OFF"보다는
데이터를 아예..
short int _TESTBENCH[44][6]={{0,0,0,0,0},{0,1,0,0,1,0},,,,};
이렇게 넣고서...아래와 같이 검사를 하면 더 쉬울것 같기도하네요..
일일이 문자 비교를 하는것 보다는...
if(TESTBENCH[i][j]==1)
{
SetTableCellVal(panel,control,MakePoint(i,j),"ON");
SetTableCellAttribute (panel,control ,MakePoint(i,j) , ATTR_TEXT_COLOR,VAL_YELLOW );
}
else
{
SetTableCellVal(panel,control,MakePoint(i,j),"OFF");
SetTableCellAttribute (panel,control ,MakePoint(i,j) , ATTR_TEXT_COLOR,VAL_RED );
}
혹....TABLE을 엑셀 처럼....한꺼번에 왕창 바꿔주는 뭐...그런거를...
요구하면...안되겠지요...^^;
아님...좀더 좋은 방법이라던가.....^^
> 아직도 Table Control은 약간의 에러가지고 있는 것 같습니다.
> 전혀 함수에 오류가 없는데도 에러가 날때가 가끔 있읍니다.
>
> void FillTable (int panel, int control)
> {
> char *_TESTBENCH[44][6]={
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//2
> {"OFF","OFF","OFF","OFF","ON", "OFF"},
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//4
> {"OFF","OFF","OFF","OFF","ON", "OFF"},
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//6
> {"OFF","OFF","OFF","OFF","ON", "ON" },
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//8
> {"OFF","OFF","OFF","OFF","ON", "ON" },
> {"OFF","OFF","OFF","OFF","ON", "OFF"},//10
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//12
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"ON", "OFF","OFF","OFF","OFF","OFF"},//14
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"ON", "OFF","OFF","OFF","OFF","OFF"},//16
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"OFF","ON", "OFF","OFF","OFF","OFF"},//18
> {"OFF","ON", "OFF","OFF","OFF","OFF"},
> {"OFF","ON", "OFF","OFF","OFF","OFF"},//20
> {"OFF","ON", "OFF","OFF","OFF","OFF"},
> {"OFF","ON", "OFF","OFF","OFF","OFF"},//22
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"ON", "OFF","OFF","OFF","OFF","OFF"},//24
> {"ON", "OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//26
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//28
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","ON", "OFF","OFF"},//30
> {"OFF","OFF","OFF","ON", "OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//32
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//34
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//36
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//38
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//40
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"},//42
> {"OFF","OFF","OFF","OFF","OFF","OFF"},
> {"OFF","OFF","OFF","OFF","OFF","OFF"}};//44
> int nCol, nRow;
> int Column, Row;
> int cellColor[] = {VAL_LT_GRAY, VAL_YELLOW};
> int i;
>
> Row = 44;
> Column = 6;
>
> GetNumTableRows (panel, control, &nRow);
> GetNumTableColumns (panel, control, &nCol);
>
> if (nCol>Column)
> DeleteTableColumns (panel, control, Column, nCol-Column);
> if (nRow>Row)
> DeleteTableRows (panel, control, Row, nRow-Row);
>
> if (nCol<Column)
> InsertTableColumns (panel, control, (!nCol ? 1 : nCol),
> Column-nCol, VAL_CELL_STRING);
> if (nRow<Row)
> InsertTableRows (panel, control, (!nRow ? 1 : nRow), Row-nRow,
> VAL_CELL_STRING);
> // 보통은 현재 있는 셀들을 모두 지우고 다시 만드는 것이 편리한데
> 그렇게 하면 에러가 발생합니다. 제가 찾은 방법이 위 처럼 하는
> 것인데 내용을 보면 이해할수 있으리라 생각 됩니다.
>
> SetTableColumnAttribute (panel, control, -1, ATTR_LABEL_BOLD, 1);
> SetTableRowAttribute (panel, control, -1, ATTR_LABEL_BOLD, 1);
> SetTableCellRangeAttribute (panel, control, ABLE_ENTIRE_RANGE,
> ATTR_CELL_JUSTIFY, VAL_CENTER_CENTER_JUSTIFIED);
> // 위의 함수들은 Column,Row의 글자를 Bold로 만들고 셀에서
> 값의 위치를 정 중앙으로 만듭니다.
>
> SetTableCellRangeVals (panel, control, MakeRect (1, 1, Row,
> Column), (char **)_TESTBENCH, VAL_ROW_MAJOR);
> // 이 함수에서는 셀에 데이타를 입력하는데 변수가 3차원 포인터인데
> 2차원 포인터로 Type Casting을 하였기 때문에 Direction값이
> VAL_COLUMN_MAJOR이 아니고 VAL_ROW_MAJOR로 하여야
> 됩니다. 직접 해보시면 데이타 배열이 이상한 것을 알수 있읍니다.
>
> for (i=1; i<45; i++) {
> //SetTableCellRangeVals (panel, control, MakeRect (i, 1, 1,
> //Column), (char **)_TESTBENCH[i-1],
> //VAL_COLUMN_MAJOR);
> // 데이타를 한 줄별로 입력할때는 위와 같이 하면 됩니다.
>
> SetTableCellRangeAttribute (panel, control, MakeRect (i, 1, 1,
> Column), ATTR_TEXT_BGCOLOR, cellColor[i%2]);
> }
> }
>
> 그럼 많은 도움이 되시길 바라며...
>
하하...테이블에 잘 들어갑니다... 감사합니다...
야린...딴 거..다..빼구...
데이터 선언할때에....3차 배열(char _TESTBENCH[44][6][3])을 안하고
충영님 갈켜주신 대로.. 2차원 배열 포인터(char *_TESTBENCH[44][6])를 사용했습니다...
즉..결론은 데이터 선언할때에...3차배열은 안되는군요...포인터를 사용해야
한다는 건지....
그리고 일단 TABLE속성은 UIR만들때..해놓아서...그래서 뺐습니다..
그리고 VAL_ROW_MAJOR은..쩝...야리가...HELP를 잘못봤는지...
ROW방향으로 하는게 원래 야리가 의도했던것과 맞더군요..^^;;
그래서..아래의 한줄만 사용했습니다...
SetTableCellRangeVals (panel, control, MakeRect (1, 1, 44,6), (char **)_TESTBENCH, VAL_ROW_MAJOR);
감사합니다...
그런데...하나의 어려운점이 또 있군요....
위의 데이터에서 "ON"과 "OFF"의 색깔을 구분해서 TABLE에 넣고 싶은데..
쩝...그럴려면...
데이터를 셀별로 일일이 하나하나씩..검사해서... 셀 속성을 따로 줘야 겠군요....아구..이거..장난 아닌데...속도도..그렇고...(사실 테이블에 하나하나씩..넣을때...속도가 그다지 안빠르더라구요...데이터가 채워지는게..눈에보여서리.....--;)
그리고...데이터를 검사할려면 위의 CHAR의 "ON","OFF"보다는
데이터를 아예..
short int _TESTBENCH[44][6]={{0,0,0,0,0},{0,1,0,0,1,0},,,,};
이렇게 넣고서...아래와 같이 검사를 하면 더 쉬울것 같기도하네요..
일일이 문자 비교를 하는것 보다는...
if(TESTBENCH[i][j]==1)
{
SetTableCellVal(panel,control,MakePoint(i,j),"ON");
SetTableCellAttribute (panel,control ,MakePoint(i,j) , ATTR_TEXT_COLOR,VAL_YELLOW );
}
else
{
SetTableCellVal(panel,control,MakePoint(i,j),"OFF");
SetTableCellAttribute (panel,control ,MakePoint(i,j) , ATTR_TEXT_COLOR,VAL_RED );
}
혹....TABLE을 엑셀 처럼....한꺼번에 왕창 바꿔주는 뭐...그런거를...
요구하면...안되겠지요...^^;
아님...좀더 좋은 방법이라던가.....^^