我想得到一个对话框的ID,代码如下:
void CTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
long nID = GetWindowLong(m_hWnd, GWL_ID);
DWORD dwError = GetLastError();
CString str;
str.Format("对话框ID为 %d",nID);
AfxMessageBox(str);
}调试时发现nID值为0;dwError 的值也为0。
什么意思?
还有就是他返回的ID应该是IDD_DIALOG1被预定义的数吧?
新手,望赐教!
void CTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
long nID = GetWindowLong(m_hWnd, GWL_ID);
DWORD dwError = GetLastError();
CString str;
str.Format("对话框ID为 %d",nID);
AfxMessageBox(str);
}调试时发现nID值为0;dwError 的值也为0。
什么意思?
还有就是他返回的ID应该是IDD_DIALOG1被预定义的数吧?
新手,望赐教!
Return Values
The requested 32-bit value indicates success. Zero indicates failure. To get extended error information, call GetLastErrorGetWindowLong返回0表示失败,那么GetLastError肯定不会返回0啊
GWL_STYLE Retrieves the window styles.
GWL_WNDPROC Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure.
GWL_ID Not supported. GWL_USERDATA Not supported.
Return Values
The requested 32-bit value indicates success. Zero indicates failure. To get extended error information, call GetLastErrorGetWindowLong返回0表示失败,那么GetLastError肯定不会返回0啊的问题
至于这个为何会出现,可能是Vs2008默认使用最新的函数(旧的就转换)
GetWindowLong->GetWindowLongPtr以上仅是本人的猜测
在VC6.0下如何得到窗口ID呢?
最好有相关代码。。
试试
error C2065: 'GetWindowLongPtr' : undeclared identifier
由于两个对话框的控件不一样,因此想在初始化中addtool之前进行对话框判断。
不用ID有没有其他更好的办法区分不同的对话框?
或者将ToolTipCtl.AddTool放到其他某个我不知道的地方?
就一定要窗体ID吗?
我的m_pDockDlg在视图中定义的;比较起来很麻烦,还要包含视图头文件。。还有没其他方法啦??
(再问一下,所谓的窗口ID是IDD_DIALOG...之类的吗?)
当然,我也试过用窗口指针区分,是可以的,有点麻烦。还有能不能把ToolTipCtl.AddTool放到不用区分对话框的别的地方呢?