Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: FindWindow

Started 1 month, 1 week ago by Msm
Hi All I am trying to find excel file is open or not through FindWindow function. Code: CWnd *pExal; pExal = CWnd::FindWindow(NULL, _T("C:\test.xls")); if(pExal == NULL){ AfxMessageBox("Couldn't find Excel file"); } else { AfxMessageBox("Excel file is open"); } In this code if file is open then show Code: pExal == NULL nad if not open then also...
Site: CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions  CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions - site profile
Forum: Visual C++ Programming  Visual C++ Programming - forum profile
Total authors: 5 authors
Total thread posts: 8 posts
Thread activity: no new posts during last week
Domain info for: codeguru.com

Other posts in this thread:

Joeman replied 1 month, 1 week ago
does excel state the file that is opened in the window's title? if so, you sure it doesn't contain anything else in the title? like - Microsoft - Excel. Also does it state the directory of the file opened? In short this isn't reliable enough

HanneSThEGreaT replied 1 month, 1 week ago
A quick glance. I really don't think you have to include C:\ in the window title to search for, so change it to : Code: CWnd *pExal; pExal = CWnd::FindWindow(NULL, _T("Microsoft Excel - test.xls")); if(pExal == NULL){ AfxMessageBox("Couldn't find Excel file"); } else { AfxMessageBox("Excel file is open"); } BTW, I think you need to supply Microsoft Excel in the ...

Msm replied 1 month, 1 week ago
Quote: Originally Posted by HanneSThEGreaT A quick glance. I really don't think you have to include C:\ in the window title to search for, so change it to : Code: CWnd *pExal; pExal = CWnd::FindWindow(NULL, _T("Microsoft Excel - test.xls")); if(pExal == NULL){ AfxMessageBox("Couldn't find Excel file"); } else {...

Arjay replied 1 month, 1 week ago
What version of Excel are you working with?

Msm replied 1 month, 1 week ago
Quote: Originally Posted by Arjay What version of Excel are you working with? 2007 version.

Arjay replied 1 month, 1 week ago
A good rule to follow when using FindWindow is to include the class name whenever possible. This allows the api to only look for windows matching the class name (and title if specified). When you supply the class name, you increase the chance of finding the correct window. Sure, it's unlikely that any other window will have 'Microsoft Excell' in the title, but it's a good practice to get into....

Msm replied 1 month, 1 week ago
Quote: Originally Posted by Arjay Code: HWND hWnd = ::FindWindow( _T("XLMAIN"), _T("Microsoft Excell - MySheet.xls [Compatibility Mode]") ); Thanks for reply How can i use that.

 

Top contributing authors

Name
Posts
Msm
4
user's latest post:
FindWindow
Published (2009-11-16 04:23:00)
Quote: Originally Posted by Arjay Code: HWND hWnd = ::FindWindow( _T("XLMAIN"), _T("Microsoft Excell - MySheet.xls [Compatibility Mode]") ); Thanks for reply How can i use that.
Arjay
2
user's latest post:
FindWindow
Published (2009-11-16 00:07:00)
A good rule to follow when using FindWindow is to include the class name whenever possible. This allows the api to only look for windows matching the class name (and title if specified). When you supply the class name, you increase the chance of finding the correct window. Sure, it's unlikely that any other window will have 'Microsoft Excell' in the title, but it's a good practice to get into. For Excell 2007, the top level...
Joeman
1
user's latest post:
FindWindow
Published (2009-11-14 03:33:00)
does excel state the file that is opened in the window's title? if so, you sure it doesn't contain anything else in the title? like - Microsoft - Excel. Also does it state the directory of the file opened? In short this isn't reliable enough
HanneSThEGreaT
1
user's latest post:
FindWindow
Published (2009-11-14 03:36:00)
A quick glance. I really don't think you have to include C:\ in the window title to search for, so change it to : Code: CWnd *pExal; pExal = CWnd::FindWindow(NULL, _T("Microsoft Excel - test.xls")); if(pExal == NULL){ AfxMessageBox("Couldn't find Excel file"); } else { AfxMessageBox("Excel file is open"); } BTW, I think you need to supply Microsoft Excel in the string as well. Try...
Msm Member
1
user's latest post:
FindWindow
Published (2009-11-16 04:23:00)
Quote: Originally Posted by Arjay Code: HWND hWnd = ::FindWindow( _T("XLMAIN"), _T("Microsoft Excell - MySheet.xls [Compatibility Mode]") ); Thanks for reply How can i use that.

Related threads on "CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions":

Related threads on other sites:

Thread profile page for "FindWindow" on http://www.codeguru.com. This report page is a snippet summary view from a single thread "FindWindow", located on the Message Board at http://www.codeguru.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity