Open and Close external window

I am trying to open a help window, keep a handle on the window, so I can 
navigate to certain topics, then close it again later. I have the following 
code sitting behind a menu option:

if (!m_wndHelp)
{
 m_wndHelp = ::HtmlHelp(GetSafeHwnd(), cHelpFile, HH_DISPLAY_TOC , NULL);
}
else
{
 if (IsWindow(m_wndHelp)) // make sure window is still valid
 {
  BOOL answer = ::DestroyWindow(m_wndHelp);
  DWORD words = GetLastError();
  ::CloseWindow(m_wndHelp);
  m_wndHelp = NULL;
 }
}

The help window opens just fine, but the DestroyWindow call returns error 
code 5 - access denied. Is there an easier way to do this? Can someone help 
me?

Even better fix would be if I could get the CHM file shown inside a CView 
derived class? I can open a CHM file inside a CHtmlView by adding "ms-its:" 
before the filename, but the index section on the left of the CHM file 
doesn't open - just blank space. 


0
contactGT (36)
11/16/2006 3:06:47 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
560 Views

Similar Articles

[PageSpeed] 21

"GT" <ContactGT@hotmail.com> wrote in message 
news:455c7e89$0$319$9a6e19ea@unlimited.newshosting.com...
>I am trying to open a help window, keep a handle on the window, so I can 
>navigate to certain topics, then close it again later. I have the following 
>code sitting behind a menu option:
>
> if (!m_wndHelp)
> {
> m_wndHelp = ::HtmlHelp(GetSafeHwnd(), cHelpFile, HH_DISPLAY_TOC , NULL);
> }
> else
> {
> if (IsWindow(m_wndHelp)) // make sure window is still valid
> {
>  BOOL answer = ::DestroyWindow(m_wndHelp);
>  DWORD words = GetLastError();
>  ::CloseWindow(m_wndHelp);
>  m_wndHelp = NULL;
> }
> }
>
> The help window opens just fine, but the DestroyWindow call returns error 
> code 5 - access denied. Is there an easier way to do this? Can someone 
> help me?
>
> Even better fix would be if I could get the CHM file shown inside a CView 
> derived class? I can open a CHM file inside a CHtmlView by adding 
> "ms-its:" before the filename, but the index section on the left of the 
> CHM file doesn't open - just blank space.
> 


0
tserface (3861)
11/16/2006 3:30:56 PM
You could Attach to the window with a CWnd object and then send a message to 
the window with a WM_CLOSE to do this more elegantly.

Tom

"GT" <ContactGT@hotmail.com> wrote in message 
news:455c7e89$0$319$9a6e19ea@unlimited.newshosting.com...
>I am trying to open a help window, keep a handle on the window, so I can 
>navigate to certain topics, then close it again later. I have the following 
>code sitting behind a menu option:
>
> if (!m_wndHelp)
> {
> m_wndHelp = ::HtmlHelp(GetSafeHwnd(), cHelpFile, HH_DISPLAY_TOC , NULL);
> }
> else
> {
> if (IsWindow(m_wndHelp)) // make sure window is still valid
> {
>  BOOL answer = ::DestroyWindow(m_wndHelp);
>  DWORD words = GetLastError();
>  ::CloseWindow(m_wndHelp);
>  m_wndHelp = NULL;
> }
> }
>
> The help window opens just fine, but the DestroyWindow call returns error 
> code 5 - access denied. Is there an easier way to do this? Can someone 
> help me?
>
> Even better fix would be if I could get the CHM file shown inside a CView 
> derived class? I can open a CHM file inside a CHtmlView by adding 
> "ms-its:" before the filename, but the index section on the left of the 
> CHM file doesn't open - just blank space.
> 


0
tserface (3861)
11/16/2006 3:31:28 PM
"Tom Serface" <tserface@msn.com> wrote in message 
news:uUx%23KRZCHHA.1300@TK2MSFTNGP03.phx.gbl...
> You could Attach to the window with a CWnd object and then send a message 
> to the window with a WM_CLOSE to do this more elegantly.
>
> Tom

Fantastic. Thanks - worked a treat! 


0
contactGT (36)
11/16/2006 5:14:45 PM
According to the DestroyWindow documentation, "DestroyWindow cannot be used to destroy a
window created by another thread"  Sounds like the return code is reasonable.

PostMessage(m_wndHelp, WM_CLOSE,0,0)

should handle it correctly.
						joe

On Thu, 16 Nov 2006 15:06:47 -0000, "GT" <ContactGT@hotmail.com> wrote:

>I am trying to open a help window, keep a handle on the window, so I can 
>navigate to certain topics, then close it again later. I have the following 
>code sitting behind a menu option:
>
>if (!m_wndHelp)
>{
> m_wndHelp = ::HtmlHelp(GetSafeHwnd(), cHelpFile, HH_DISPLAY_TOC , NULL);
>}
>else
>{
> if (IsWindow(m_wndHelp)) // make sure window is still valid
> {
>  BOOL answer = ::DestroyWindow(m_wndHelp);
>  DWORD words = GetLastError();
>  ::CloseWindow(m_wndHelp);
>  m_wndHelp = NULL;
> }
>}
>
>The help window opens just fine, but the DestroyWindow call returns error 
>code 5 - access denied. Is there an easier way to do this? Can someone help 
>me?
>
>Even better fix would be if I could get the CHM file shown inside a CView 
>derived class? I can open a CHM file inside a CHtmlView by adding "ms-its:" 
>before the filename, but the index section on the left of the CHM file 
>doesn't open - just blank space. 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
11/16/2006 5:28:25 PM
Reply:

Similar Artilces:

EXCEL.EXE Process Open even though Quit method issued
I'm opening a workbook using the Task Scheduler built-in Windows2000 and when the workbook is done doing what it's supposed to do, I issue an Application.Quit method in the VBA code to close Excel. In the Task Manager, the Excel application (I'm using Excel2000) and the workbook that was opened is not seen in the Application tab, yet there is an EXCEL.EXE in the Processes tab. Also, going in the Task Scheduler, the task itself is still running even though I issued the Quit to get out of Excel. Either stopping the task or ending the process gives me a dump in the Dr.Wat...

FFFE files in C:\windows
Situation: I use Windows 98SE and Office 2000. I understand that every time I open Outlook it creates an fffe*.tmp file in C:\windows. How do I make it stop doing that? Thank you. ...

Can't Open the Database
I create a database in Access 2003 and I tried to email it to someone else but they could not open it. I notice when I closed the data base and the folder where this data base is there was this quick icon that appear quickly underneath the Access icon and it reads Micro Access Recording Locking and it disappears. Can someone explain this to me? Does this mean the reason she could not open this data base was because it was lock. I never done anything to lock it. If so how can I correct this so that she can have access to this. I have tried to save it on a CD but when we open it, its ...

Unable to open Excel files sent to me by email.
When I receive an e-mail with an Excel file attached, I am no longer able to double click on the file to open it. Depending on the file type, I can save a copy to the desktop and open it. How can I correct this issue? I am using Excel 07 and Windows 7. I would strongly recommend that you DON'T try to open the file straight from the e-mail. It is when people change a file opened that way that they may subsequently find that the revised file has disappeared because it has been stored in a temporary directory and lost. Much safer to save to disk and then open. [And desk...

how do I set up capital letters to open sentence in outlook 2003
i used to have automatic capital letters at the beginning of a sentence it is not so anymore That's covered on this page: http://www.freeemailtutorials.com/microsoftOutlook2003/outlookSpellingOptions/autoCorrectOptions.cwd "question" <question@discussions.microsoft.com> wrote in message news:58EA0F10-22DF-43CA-B4C3-9BE6C0899985@microsoft.com... > i used to have automatic capital letters at the beginning of a sentence > it is not so anymore ...

How to get a list of opened MDI child windows in MDI main frame?
To active a speciffic child frame by calling void CMDIFrameWnd::MDIActivate( CWnd* pWndActivate ); However, how do I get the pointer of the child frame? Should I create an array variable to keep these pointers? Or there will be more better way? Thank you! CDocument has member functions which you can interate through different views. Here's an example. POSITION pos = GetFirstViewPosition(); while (pos) { CView* pView = GetNextView(pos); if (pView) { // do something with pView } } Check the help file for more information on these two functions in CDocument. Relv &q...

Publisher 2003 files can't be opened by Publisher 2000 users
Even though I save files created in Publisher 2003 as Publisher 2000 files they can't be opened by associates who are using Publisher 2000. What might be the problem? Does it happen every time? I've had it happen to me occasionally but I've found a little perseverance seems to do the trick. -- JoAnn Paules MVP Microsoft [Publisher] "hobnail" <hobnail@discussions.microsoft.com> wrote in message news:267B71A6-55FD-4C7E-97DA-A37FBC9F75FA@microsoft.com... > Even though I save files created in Publisher 2003 as Publisher 2000 files > they can't be ...

Error, Windows Cannot find hcw file
I get this error when I do my build: "Error, Windows Cannot find hcw file". However, I build continues after I press OK and all is okay. I've done some reading about this on Google, but have not been able to resolve it. Maybe the experts on this forum and can help me better. Thanks >I get this error when I do my build: "Error, Windows Cannot find hcw file". It looks like your project is using the old Help Compiler Workshop. http://www.microsoft.com/downloads/details.aspx?FamilyID=34D35502-4DE9-4676-952C-34CC7F64F098&amp;displaylang=en&display...

eml files in windows/temp folder
We had an email issue this morning with our Groupshield not being able to scan messages, due to the version of the file and the dat file. Anyways I was able to get it to work but then I noticed that my C: drive has lost a lot of space, almost 25G. I searched for the files and I found 35 files with eml extensions in the c:\windows\temp folder, each with the size of 706M. They were all created at the time that we were having issue with the email. What are those files and can I just delete them from this folder? Isn't going to corrupt anything if I just delete them? Also, when ...

.msg attachments do not keep right extension
hi there, Just installed my wife's new windows 7 professional pc. no outlook installed here. the old win xp with outlook 2003 still runs beside it. my wife receives email message from a friend. those messages have other messages as attachments. on outlook 2003 (win xp) I can open those messages. on windows live desktop, I see that there are attachments, but I can't open. before you start to mention the extensions and the standard applications, please read on. for example the following: on outlook 2003 (on XP), the attachment name shows as "for you... (813 ...

Worksheets open behind tool bars
Using Office MacX Excel opening worksheets results in the top being behind the tool bars. I have to drag the bottom corner of the worksheet far to the right and up. Then I can reach the top bar of the workbook and drag it below the tool bars and formula bar. This is a real PAIN. Any suggestions? ...

Crashing after closing messages
Hi All, I have a problem (no, not the AA thing). When I print a message from Outlook 2003 from the reading pane it works fine but when I open a message and print and then after closing the message Outlook crashes. No matter which printer i choose it crashes. I have reinstalled and repaired office a few times. Below is the error message. Any ideas? Thanks in advance, Thomas Event Type: Error Event Source: Microsoft Office 11 Event Category: None Event ID: 1000 Date: 12/16/2004 Time: 10:43:03 AM User: N/A Description: Faulting application outlook.exe, version 11.0.6353.0, stamp 408f2937, f...

C:\WINDOWS\system32\winjpg.jpg is missing
I searched the Internet what to do about the problem on the subject, and one forum said that this is caused by removing viruses with McAfee anti-virus (which I did). They suggested to fix that through msconfig but the msconfig doesn't open. I went to a forum that gave solutions for downloading msconfig but they don't work. I started XP in the save mode and Run but still no msconfig. Another forum said to download an alternative msconfig which sits on the control board, but that also didn't work. I tried the suggestion to type in Run sfc /scannow and insert the XP di...

Freezing Window Panes
How do you freeze a column and a row at the same time. I can freeze a row or a column separately but not together. JB, click in the cell one row below and one column to the right of where you want to freeze them and then window ,freeze panes -- Paul B Always backup your data before trying something new Using Excel 97 & 2000 Please post any response to the newsgroups so others can benefit from it ** remove news from my email address to reply by email ** "JB @ DTV" <anonymous@discussions.microsoft.com> wrote in message news:015501c39805$0d448a80$a501280a@phx.gbl... >...

cannot open publisher 97 file
"Publisher cannot load files from a different version" is the message I get when I tried to open a saved publisher 97 file from a floppy disc I made 2 years ago. I have not bought an upgraded version of Publisher and I don't think I upgraded Publisher 97. This is an important file. Help! Copy the file to your hard drive and try again... Publisher balks at removable media. If you have Norton, disable "script blocking." -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.msauer.mvps.org/ news://msnews.microsoft.com "John" <anonymous@discussions...

XL2007: line chart lines disappear when referenced workbook is not open
What we are doing is putting the charts in a separate workbook to the data that they are drawn from. This works fine in Excel 2003. But in Excel 2007 and Excel 2010 it is really weird. Can someone please confirm this. 1. Open a new workbook. 2. On Sheet1:make a range of data 3. On Sheet2:create a chart with "lines and dots" chart type that displays the data from "Sheet 1" 4. Save the workbook. 5. Copy the Sheet2 to a new workbook. Notice that in the new workbook there are lines connecting the dots on the chart. Now close the first workbook with the data. Notice that...

Open a new instance
How do I force Excell to open a new instance when I open more then one spreadsheet, instead of just opening another workbook?? Hi goto 'Tools - Options - View' and check 'Windows in taskbar' -- Regards Frank Kabel Frankfurt, Germany "Roger Settle" <RSettle@klfinancialgroup.com> schrieb im Newsbeitrag news:5a1301c42d58$0007ce20$a501280a@phx.gbl... > How do I force Excell to open a new instance when I open > more then one spreadsheet, instead of just opening > another workbook?? That didn't work. It made it to where I have 2 separate excel i...

associated external account #3
I am running exh2k on a win2k domain. I have noticed that most of my enabled users don’t have associated external account checked in their mailbox rights permissions. Some of the users have it check for an object that is no longer available. I have noticed when doing an exmerge I cant exmerge any disabled users mailboxes unless they have associated external account checked for self .. 1.The most concerning issues is that we are about to upgrade to exch2k3. will their be a problem if users mailboxes don’t have associated external mail account checked for any of the permissions in th...

Receiving all mail in Outlook Exp, but not in Windows Live
I receive mail through a PC on Outlook Express. When I check my mail on my laptop through Windows Live I don't receive all my mail. It is not the same sender. One day I will receive mail from sender X on my laptop, and one day I wont. -- michele If both computers are using the same e-mail address, on both machines: Tools | Accounts | Mail | Properties | Advanced - Check: Leave a copy of messages on the server. On one machine only, check to Delete messages after X days to satisfy your allotted space you get from your server. -- Bruce Hagen MS-...

freezes when opening
Outlook 2002 freezes when opening...been working fine before. CTRL / ALT / DEL shows the program is running. Tried remaning outcmd.dat to .old as suggested in posted reply, but that does not work. Any suggestions? ...

how to create a window from a thread
Hi, When a new thread is created from the main app, how to make the new thread create a new invisible window, this window have no relationship with the app's main window(not the child of it). And this window is to handle a tray icon(to add a tray icon and handle the messages from it). Can I got some MFC sample code for the solution? Thanks in advance. Shineway Zhu Shineway if you are not using MFC in the thread, then create the thread with _beginthreadex function from the CRT lib. in the thread function, register a window class (calling RegisterClass API function with a ptr to a WN...

Cut and paste from Explorer window into Excel spreadsheet
How can I cut and paste several files (hundreds of them) from an Explorer window into an Excel spreadsheet without having to do them one at a time. Thanks, You have another reply to your previous^2 post. david wrote: > > How can I cut and paste several files (hundreds of them) > from an Explorer window into an Excel spreadsheet without > having to do them one at a time. > Thanks, -- Dave Peterson ec35720@msn.com ...

Hotmail, Windows Messenger and WLMail
at 5 - 6 am - this morning - no problems Get to work @ 8:30 this morning - nothing, zero, zippo. Cant use windows mail - messenger - nothing. It wont accept my password - i cant reset the password - and cant use secret question - or send new password to my secondary account. All dead - and my secondary email account - is barely working as i can sometimes sign in - and sometimes cant. Is everything dead? From the Windows Live Solution Center (WLSC) =E2=80=9CWindows Live Hotmail is currently experiencing login issues. A = small amount of users may receive errors when atte...

Can't open hyperlinks to files
I have a Windows Server 2003 R2 Terminal Server, and have a pretty restrictive GPO applied to it. The users are restricted from most system tasks, and I set "Run only allowed Windows applications" under User Configuration\Administrative Templates\System. I have a list of .exe files set that they are able to run, and they are prevented from running anything else. MS Office 2003 is installed on this Terminal Server and the users are able to launch all of those applications. This was working fine for awhile, but after we installed some Microsoft Updates earlier this year, we found that...

Word now opening with cursor at top of page
When I open Word 2003/Windows XP the cursor is at the top of the page rather than a few lines down as it used to be. I have had this problem before and cured it with this forums help but forgot to keep a copy. How do I solve it? "Merryterry" <terryj@fsmail.net> wrote in message news:c7a1f199-429f-4a84-b40d-6b35962775f2@k41g2000yqb.googlegroups.com... > When I open Word 2003/Windows XP the cursor is at the top of the page > rather than a few lines down as it used to be. I have had this problem > before and cured it with this forums help but forgot to keep ...