求救!如何在后台取得TOP窗口所打开的文件路径 ?
cimu 2005-05-27 10:19:49 假设后台有一个DIALOG,代码如下:
CWnd* pwnd = GetForegroundWindow();
CString strTitle ;
pwnd->GetWindowTitle (strTitle);
if (-1 == strTitle.Find("Microsoft Word") )
return ;
// 取当前WORD所打开文档的路径
// 我是这样做的 ,但是不行
CFrameWnd* frmWnd = (CFrameWnd*)pwnd;
CDocument* pDoc = frmWnd->GetActiveDocument();
CString curfilepath = pDoc->GetPathName();
以上代码在处理到CFrameWnd* frmWnd = (CFrameWnd*)pwnd; 时等到主框架的指针为空,请教各位什么原因,如何才能取得文档路径。多谢! 本人初学,请多关照,晚上回来后一定给分结贴