例如:Class B : public CDialog
{
//do something
}
Class A : public CView
{
void Func()
{
B b;//一个局部变量
b.DoModal();
}
}我在一个View中这样做了个模态对话框,现在模态对话框弹出了,
但是另一个线程发消息把Class A给Destory掉了,
MainFrm切到了其他View,
这时界面上什么控件也找不到焦点了,怎么办?
还能找着焦点么?用什么办法?
如果找不着,除了
1、在编程规范中不允许声明局部变量创建模态对话框,在View被Destroy前发消息kill模态对话框。
2、创建全局CDialog指针,创建模态对话框时做指针副本,Destroy前kill模态对话框。(我不希望全局的东西被这样用)
3、把所有模态的改为非模态的。(工作量有点大,工程中比较多)
这些办法还有辄解决这个问题么,因为找不到焦点程序就只能通过杀进程结束了。
大大们帮忙啊!
{
//do something
}
Class A : public CView
{
void Func()
{
B b;//一个局部变量
b.DoModal();
}
}我在一个View中这样做了个模态对话框,现在模态对话框弹出了,
但是另一个线程发消息把Class A给Destory掉了,
MainFrm切到了其他View,
这时界面上什么控件也找不到焦点了,怎么办?
还能找着焦点么?用什么办法?
如果找不着,除了
1、在编程规范中不允许声明局部变量创建模态对话框,在View被Destroy前发消息kill模态对话框。
2、创建全局CDialog指针,创建模态对话框时做指针副本,Destroy前kill模态对话框。(我不希望全局的东西被这样用)
3、把所有模态的改为非模态的。(工作量有点大,工程中比较多)
这些办法还有辄解决这个问题么,因为找不到焦点程序就只能通过杀进程结束了。
大大们帮忙啊!
有啥办法能kill掉那个模态对话框就美了。
直接只用FindWindow 找到它 然后调用Destroy应该就可以了。用Spy++看那个窗口有什么特征 在FindWindow后判断一下 别杀错了。
static CWnd* PASCAL FindWindow( LPCTSTR lpszClassName, LPCTSTR lpszWindowName );Return ValueIdentifies the window that has the specified class name and window name. It is NULL if no such window is found. The CWnd* may be temporary and should not be stored for later use.ParameterslpszClassNamePoints to a null-terminated string that specifies the window’s class name (a WNDCLASS structure). If lpClassName is NULL, all class names match.lpszWindowNamePoints to a null-terminated string that specifies the window name (the window’s title). If lpWindowName is NULL, all window names match.ResReturns the top-level CWnd whose window class is given by lpszClassName and whose window name, or title, is given by lpszWindowName. This function does not search child windows.