First show dialog Then load data C/C++ • Dec 29, 2017 • Dewey Mao • Words:193 It is more user-friendly to show dialog first before loading data from remote database. //demoDlg.h ... Virtual BOOL OnInitDialog(); afx_msg void OnInitData(); void ProcessMessages(); void LoadData(); //demoDlg.cpp ... const UINT WM_INIT_DATA = WM_APP + 1; BEGIN_MESSAGE_MAP(...) ... ON_MESSAGE_VOID(WM_INIT_DATA, OnInitData) END_MESSAGE_MAP() BOOL OnInitDialog(){ ... PostMessage(WM_INIT_DATA); return TRUE; } void OnInitData(){ ShowWindow(SW_SHOW); ProcessMessages(); LoadData(); } void ProcessMessage(){ MSG msg; while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){ TranslateMessage(&msg); DispatchMessage(&msg); } } void LoadData(){ CWaitCursor wait; //load data from database //show data in dialog UpdateData(FALSE); } ←Previous   |   Next→ Please enable JavaScript to view the comments powered by Disqus.