如何关闭从类到另一个类的无模式窗口 [英] How to close a modeless window from class to another class

查看:82
本文介绍了如何关闭从类到另一个类的无模式窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过WM_TIMER函数中的另一个对话框创建了无模式对话框.我的对话框已经完成,我想通过代码自动销毁它,所以我按照以下方式完成了


I have created Modeless dialog through another dialog in the WM_TIMER function.And my work is done with the dialog i want to distroy it automatically through code.So i have done in the following way


OnTimer:
{
 ClsWindow *m_pWindow = new ClsWindow;
if(Aflag == true)

 m_pWindow ->Create(ClsWindow::IDD)
 m_pWindow->ShowWindow(SW_SHOW)
}

else
{

 m_pWindow->DestroyWindow()
}



这里的问题是我能够创建无模式对话框,但我无法破坏窗口.如果我不使用计时器,并且如果在任何按钮单击事件中使用此代码,则此代码有效,它可以正常工作.正在连续运行,无法破坏窗户.请建议我解决此问题.

在此先感谢.

[edit]代码块已添加[/edit]



The problem here is iam able to create the modeless dialog,but iam not able to destroy the window.This code works if i dont use the timer and if i use this in any button click event it works properly.I feel that as the timer is running continously its not able to destroy the window.Please suggest me to solve this.

Thanks in Advance.

[edit]code block added[/edit]

推荐答案

每次输入OnTimer时,都会创建一个新的ClsWindow,以防万一标志==假的,你摧毁它.离开OnTimer处理程序后,要关闭的窗口的指针在创建后已经丢失.
ClsWindow *m_pWindow的属性需要在类级别定义,并且在进入OnTimer时不仅要覆盖它.

Every time you enter OnTimer you create a new ClsWindow and in case flag == false you destroy it. The pointer to the window you want to close was already lost after creation when leaving the OnTimer handler.
A property for ClsWindow *m_pWindow needs to be defined at class level and don''t just overwrite it when entering the OnTimer.

OnTimer:
{ 
  if(Aflag == true)
  {
    m_pWindow = new ClsWindow;
    m_pWindow ->Create(ClsWindow::IDD)
    m_pWindow->ShowWindow(SW_SHOW)
  } else
  {
    m_pWindow->DestroyWindow()
  }
}



祝你好运!



Good luck!


这篇关于如何关闭从类到另一个类的无模式窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆