BOOL SetWindowText( HWND hDlg, // handle to your dialog LPCTSTR lpString // title or text );
HWND GetDlgItem( HWND hDlg, // handle to dialog box int nIDDlgItem // control identifier );BOOL SetWindowText( HWND hWnd, // handle to window or control LPCTSTR lpString // title or text );你应该知道如何实现了吧!
HWND hDlg, // handle to your dialog
LPCTSTR lpString // title or text
);
HWND hDlg, // handle to dialog box
int nIDDlgItem // control identifier
);BOOL SetWindowText(
HWND hWnd, // handle to window or control
LPCTSTR lpString // title or text
);你应该知道如何实现了吧!
CStationDlg StationDlg;
StationDlg.SetWindowText("ABC");
StationDlg.DoModal();
何时何地任意改变。(注:当前的窗口)
CStationDlg StationDlg;
::SetWindowText(StationDlg.m_hWnd, "ABC");
StationDlg.DoModal();
所至的不是id
这个函数调用时必须指定其需要操作的窗口,然后指定标题。 CStationDlg StationDlg;
StationDlg.SetWindowText("ABC");
StationDlg.DoModal();你这样作的话,该函数缺少句柄参数,当然不行啦!
> CStationDlg StationDlg;
> ::SetWindowText(StationDlg.m_hWnd, "ABC");
> StationDlg.DoModal();
你指定的不是窗口ID值,该函数改变的是该窗口的资源!
> CStationDlg StationDlg;
> ::SetWindowText(StationDlg.m_hWnd, "ABC");
> StationDlg.DoModal();
你指定的不是窗口ID值,该函数改变的是该窗口的资源!
StationDlg.SetWindowText("ABC");
StationDlg.DoModal();
上面编译通过,运行出错
dlg.SetWindowText("ABC"); // 不能改变吧。dlg并没有创建出来呀。
StationDlg.DoModal();我觉的可以这样。在CStationdlg中加一个m_strTitle的变量。用一个函数
SetTitle(CString str);来设置caption.在showwindow的时候在CStationDlg内部SetWindowText。应该没有问题。
StationDlg.SetWindowText("ABC");
//::SetWindowText(StationDlg.m_hWnd, "ABC");
StationDlg.DoModal();
当然不行!
此时窗口还没有创建,窗口句柄还是空的,不信你调试一下。
此时执行StationDlg.SetWindowText("ABC");会出错,因为窗口还没有创建,
而::SetWindowText(StationDlg.m_hWnd, "ABC");是没有效果的,因为此时
StationDlg.m_hWnd 为NULL。
然后在CStationDlg::OnInitDialog(...)中使用
SetwindowText(m_strTitle)来改变窗口标题。
(此时窗口已经创建,但是还没有显示。)