使用SetDlgItemInt函数 [英] using SetDlgItemInt function
本文介绍了使用SetDlgItemInt函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨..
我无法使用此代码
Hi..
I cannot use this code
CMyView::OnLButtonDown(UINT nFlags, CPoint point)
{
dialg.DoModal();
HWND hdlg = FindWindow(NULL,_T("Dialog"));
SetDlgItemInt(hdlg, IDC_EDIT2, 100, true);
if(IDOK)
{
}
}
SetDlgItemInt函数不使用4个参数,并且FindWindow无法将HWND转换为CWnd *.有谁知道如何声明SetDlgItemInt函数以及如何处理对话框窗口?谢谢
SetDlgItemInt function doesnot take 4 arguments and FindWindow cannot convert to HWND to CWnd*. Does anyone know how to declare SetDlgItemInt func and how to handle a dialog window? Thank You
推荐答案
这里发生的事情是您正在尝试调用FindWindow
和SetDlgItemInt
API.
但是这些功能也作为CWnd
类的方法存在.
您的CMyView
类间接继承自CWnd
,因此它正在尝试调用CWnd
成员函数而不是API.
两种版本的参数集略有不同.
您可以执行2件事来解决此问题.
您可以更改参数以使用CWnd
版本.
或者简单地对函数进行作用域,以使其使用全局作用域(API属于全局作用域).
所以你的代码应该看起来像这样-
What is happening here is that you''re trying to call theFindWindow
andSetDlgItemInt
APIs.
But these functions also exist as methods of theCWnd
class.
YourCMyView
class indirectly inherits fromCWnd
and so it is trying to invoke theCWnd
member functions rather than the APIs.
Both versions have slightly different set of parameters.
There are 2 things that you could do to solve this issue.
You could either change the parameters to use theCWnd
version.
Or simply scope the functions so that it uses the global scope (APIs come under global scope).
So you''re code should look like this -
CMyView::OnLButtonDown(UINT nFlags, CPoint point)
{
dialg.DoModal();
HWND hdlg = ::FindWindow(NULL,_T("Dialog"));
::SetDlgItemInt(hdlg, IDC_EDIT2, 100, true);
if(IDOK)
{
}
}
这篇关于使用SetDlgItemInt函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文