IUP矩阵刷新

时间:2013-04-09 20:44:37

标签: iup

我正在尝试使用C中的IUP矩阵,就像我使用VB中的DataGrid一样 直到现在我来到这里:

int refreshl(Ihandle *mat, int from)  
{  
struct lotstruct lot;   

FILE *fol;
fol = fopen("C:/myfolder/myfile", "rb+");

int b;
int temp = 1;
for (b=from; b<(from+31); b++)
{
    int rec = sizeof(lot) * (b - 1);
    fseek(fol, rec, SEEK_SET);

    int fr;
    fr = fread(&lot, sizeof(lot), 1, fol);
    //------------------------------------
    char k1[36] = {0};
    strncpy(k1, lot.str1, 35);
    char* tp = ibm852_to_cp1250(k1);

    char row[6] = {0};
    sprintf(row, "%d", temp);
    char* ro = ibm852_to_cp1250(row);

    char cel1[10] = {0};
    sprintf(cel1, "%d%s", temp, ":0");
    IupSetAttribute(mat, cel1, ro);

    char cel2[10] = {0};
    sprintf(cel2, "%d%s", temp, ":1");
    IupSetAttribute(mat, cel2, tp);
    temp += 1;
}
fclose(fol);
IupSetAttribute(mat, "REDRAW", "ALL");

return 0;
}

有了这个,我从二进制文件中读取数据,我可以在控制台上看到数据。 但mytrix不会通过更改数据来刷新。通过增加“from”整数,k_any + case K_DOWN函数改变数据 所以我称之为“REDRAW”“ALL”但也没有结果,起始数据保持在矩阵中。

由于我是初学者,请回答几个问题。

1)使用像常见的Windows网格一样的IUP矩阵是个好主意吗? 2)如何在不降低速度的情况下调用刷新矩阵来更改其中的数据? 3)IUP可以在像gtk这样的Windows上使用UTF-8字符串吗? (我尝试但没有结果)。

1 个答案:

答案 0 :(得分:1)

1)像普通的Windows Grid一样使用IUP矩阵是个好主意吗?

是。 IupMatrix就是为了这个。

2)如何在不降低速度的情况下调用刷新矩阵来更改数据?

您的代码是正确的。也许你正在更新IupMatrix中错误的单元格。 L = 0或C = 0是标题单元格,并且如果某些条件为真则存在。也许你想要的是设置L = 1或C = 1.

建议,而不是:

char row[6] = {0};
sprintf(row, "%d", temp);
char* ro = ibm852_to_cp1250(row);
char cel1[10] = {0};
sprintf(cel1, "%d%s", temp, ":0");
IupSetAttribute(mat, cel1, ro);

试试这个:

IupMatSetfAttribute(mat, "", temp, 0, "%d", temp);

和     IupMatStoreAttribute(mat,“”,temp,1,tp);

您只需要第二部分的字符串转换。

另外,如果临时变量具有有效索引,您是否检查了它?

3)IUP可以在像gtk这样的Windows上使用UTF-8字符串吗? (我尝试但没有结果)。

还没有。它将在(近)未来版本中。