Change the display content in the same position of the window. All the content is displayed on the same component. You can switch the display content.
Demo VC6.0 Project
The demo interface is very simple. Press the change key to switch between different display items. It is blank at the beginning. Click Show salarys, Click Show types, and then click return to the blank interface. A background thread is responsible for refreshing data.
Salarys
Types
Strange problem: refresh some problems in VC6 + fltk1.1.10. For details, refer to the code analysis below. It is normal in VS2008 + FLTK1.3.x.
Thread Functions
void thread_fun(void *pdata) { WndStruct *pWndStruct = (WndStruct *)pdata; int i = 1; int k = 0; srand(time(0)); for (;;) { for(k=0; k<N_SALARY; k++) { if(i%1000==0) ++salarys[k].year; salarys[k].salary = 5000+i; } for(k=0; k<N_TYPES; ++k) { char randNum = (char)(5*rand()/(float)RAND_MAX); typess[k].height = 30+randNum*5.18; typess[k].weight = 5+randNum*0.31; } ++i; if(i>100000) i=0; for(int i=1; i<3; ++i) { if (pWndStruct[i].pWnd && pWndStruct[i].isShow) { pWndStruct[i].pDynFunc(&pWndStruct[i]); // ((CMyWnd *)pWndStruct[i].pWnd)->redraw();//-----1 pWndStruct[i].pWnd->redraw();//-----2 // pWndStruct[i].pWnd->damage(FL_DAMAGE_ALL);//-----3 } }Fl::flush(); //----new 5-1 Sleep(300); } }
Analysis: In the thread refresh function, only one row can be refreshed in VC6. If 2nd rows are used, the data header can be displayed, and the data needs to be refreshed with a mouse or something, there may be a problem with the refresh mechanism. In VS2008, two or three rows of refresh functions can be used. In addition, if you set the rectangle color to red when refreshing row // ----- 1, some data sometimes turns to red when refreshing.
In VC6, we used Row 1st to refresh the fltk source code. The redraw function of fl_widget is not virtual. Implementing redraw in a derived class will hide the implementation of the base class, however, pWnd in wndstruct is the fl_widget pointer. The default value is to call the implementation of the base class fl_widget ??
Ah! Don't understand!
[I just learned the reason. I didn't call the Fl: flush () function. I can call this function once during the refresh process to refresh it. It should be a refresh of all pages. --- Not Sure, add // new 5-1 to refresh the page. ------- 2013.5.1 Note]