block UI控件如果有RetainValue属性,就用这个属性。没有这个属性可以参考下面这种方法。以矢量控件为例:
1.在apply_cb回调中,将控件值保存到文本中
double TopForTextDir[3] = { 0.0,0.0,0.0 }; Vector3d vec = this->vector0->GetProperties()->GetVector("Vector"); TopForTextDir[0] = vec.X; TopForTextDir[1] = vec.Y; TopForTextDir[2] = vec.Z; string strFile = "D:\haha\temp\k_cam_BoosCupFace_vector0.temp"; FILE *fp = NULL; errno_t err = fopen_s(&fp, strFile.c_str(), "w"); fprintf(fp, "%f,%f,%f", TopForTextDir[0], TopForTextDir[1], TopForTextDir[2]); fclose(fp);
2.在initialize_cb回调中,从文本中读取,设置控件值
string strFile = "D:\haha\temp\k_cam_BoosCupFace_vector0.temp"; FILE *fp = NULL; errno_t err = fopen_s(&fp, strFile.c_str(), "r"); if (fp != NULL) { char szLineContentTemp[501] = ""; fgets(szLineContentTemp, 500, fp); if (strlen(szLineContentTemp) > 3) { if (szLineContentTemp[strlen(szLineContentTemp) - 1] == ' ') szLineContentTemp[strlen(szLineContentTemp) - 1] = '