等待提示框如何写,谢谢指点

cmf1944 2002-03-15 09:35:41
在对话框中,当响应时间后,要把一些数据写入数据库,在写入的时候用户需要等待,
这时如何作一个简单的提示框如"正在写入数据,请等待",等写完后提示框也自动消失!
...全文
66 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
nuaawyd 2002-03-15
  • 打赏
  • 举报
回复
void CWaitDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
KillTimer(NULL);
EndWaitCursor();

CDialog::OnClose();
}

BOOL CWaitDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
m_LightReturn = FALSE;
BeginWaitCursor();
m_Progress.SetRange(0,10);
m_Progress.SetPos(0);
SetTimer(NULL,100,NULL);
count = 0;
hIcon = AfxGetApp()->LoadIcon(IDI_LIGHT2);
m_FrmIco.SetIcon(hIcon);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

void CWaitDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_Progress.SetPos(step);
count++;
if(count % 4 == 0)
{
m_LightReturn = ! m_LightReturn;
if(m_LightReturn)
{
hIcon = AfxGetApp()->LoadIcon(IDI_LIGHT2);
m_FrmIco.SetIcon(hIcon);
}
else
{
hIcon = AfxGetApp()->LoadIcon(IDI_LIGHT1);
m_FrmIco.SetIcon(hIcon);
}
}
CDialog::OnTimer(nIDEvent);
}

BOOL CWaitDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
switch (pMsg->message)
{
case WM_KEYDOWN:
{
switch (pMsg->wParam)
{
case VK_ESCAPE:
return FALSE;
default:
break;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}

void CWaitDlg::KillMyTimer()
{
KillTimer(NULL);
}

CWaitDlg *pDlg;
CStatic *pStr = (CStatic *)pDlg->GetDlgItem(IDC_TEXT);
//先在对话框上加一个文本框写入“正在写入数据,请等待”
pStr->SetWindowText("数据库连接成功!");
pDlg->KillMyTimer();
HICON hIcon = AfxGetApp()->LoadIcon(IDI_LIGHT3);
pDlg->m_FrmIco.SetIcon(hIcon);
pDlg->m_Progress.SetPos(210);
pDlg->m_Progress.SetStep(0);
Sleep(1500);

pDlg->SendMessage(WM_CLOSE);
return 1;

1,649

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 非技术类
社区管理员
  • 非技术类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧