CHtmlView::OnPrint crashes under Windows 2000

at this line >>>  lpTarget->Exec(NULL, OLECMDID_PRINT, 0, NULL, NULL);

yet if I create a appwizzard app under w98 using CHtmlView it works fine?
Also is a try and access a web page on the Internet it crashes as well but works fine for local files.

Any ideas how to fix this?

My system and OS are:
OS:           W2000 SP1
VC++:       6.0, SP5
jrcAsked:
Who is Participating?
 
DanRollinsConnect With a Mentor Commented:
Check the Debug trace window.  Are there any messages there that could lend a clue?

-- Dan
0
 
DanRollinsCommented:
Yes,
Don't use Exec(...)

Just let CHtmlView's default printing do it's thing.  It handles printing internally (by splitting off a thread with a new hiddne browser).

Aside from that, you can get crashing in some cases when Execing some commands when document is not fully download.  So mkae certain that the page is fully loaded.

Also, you don't show where you got the value for lpTarget, so there may be a problem there.

-- Dan
0
 
jrcAuthor Commented:
I am using the default print function from CHtmlView. I just built an MDI application using the appwizzard vith the view class derived from CHtmlView. Then changed navigate2 to point to a local HTML file in the view class created for me by the wizzard since it could not access a file on the net. Which is yet another problem.

The file appears to load fine but when I try and print it crashed in NTDLL. It seems odd that it calls it a user break point??? It never gets to posting the print dialog like it does
under win98.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
jrcAuthor Commented:
It looks to me like the NT DLL is actually intentionally exiting the program for some reason. The only reason I can think of is that there is some sort of permission problem under Windows 2000. I have had problems running programs under Windows 2000 due to permissions. On more than one occasion I have had to first run the program as administrator before I could run as a user with full administration privileges. Without doing this first the program would crash. I have tried running this as administrator and it still crashes.

Debug line that it stops on:
-------------------------------------
77F9EEA9   int         3

Call stack during load of document:
-------------------------------------------------
Warning: constructing COleException, scode = DISP_E_MEMBERNOTFOUND ($80020003).
First-chance exception in HtmlApp.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Warning: constructing COleException, scode = DISP_E_MEMBERNOTFOUND ($80020003).
First-chance exception in HtmlApp.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

Call stack after trying to print:
----------------------------------------
The thread 0x5E8 has exited with code 0 (0x0).
Loaded 'C:\WINNT\system32\msrating.dll', no matching symbolic information found.
Loaded 'C:\WINNT\system32\printui.dll', no matching symbolic information found.
Loaded 'C:\WINNT\system32\WINSPOOL.DRV', no matching symbolic information found.
Loaded 'C:\WINNT\system32\activeds.dll', no matching symbolic information found.
Loaded 'C:\WINNT\system32\adsldpc.dll', no matching symbolic information found.
Loaded 'C:\WINNT\system32\mscms.dll', no matching symbolic information found.
Loaded 'C:\WINNT\system32\cfgmgr32.dll', no matching symbolic information found.
Loaded 'C:\WINNT\system32\SETUPAPI.DLL', no matching symbolic information found.
HEAP[HtmlApp.exe]: Heap block at 0017B170 modified at 0017B3D2 past requested size of 25a

Trace back window:
----------------------------
NTDLL! 77f9eea9()
NTDLL! 77fcd942()
NTDLL! 77fb54c9()
NTDLL! 77fb4316()
NTDLL! 77fab4ab()
SETUPAPI! 778834e2()
SETUPAPI! 77883019()
SETUPAPI! 77882ce7()
SETUPAPI! 77882b69()
NTDLL! 77f8bfcc()
NTDLL! 77f8c618()
NTDLL! 77f889c0()
KERNEL32! 77e8723d()
COMDLG32! 76b4ed57()
SHDOCVW! 76cca703()
SHDOCVW! 76cc9687()
SHDOCVW! 76cbf1dd()
SHDOCVW! 76c93e34()
MSHTML! 75be4565()
MSHTML! 75be857d()
MSHTML! 75c12187()
CHtmlView::OnFilePrint() line 104


0
 
DanRollinsCommented:
Here's a snippete of VB code that checks to see if printing is enabled.  I found it at:
  http://msdn.microsoft.com/workshop/browser/webbrowser/WebBrowser.asp

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Private Sub BtnPrint_Click()
Dim eQuery As OLECMDF 'return value type for QueryStatusWB
On Error Resume Next
eQuery = WebBrowser1.QueryStatusWB(OLECMDID_PRINT)  'get print command status
If Err.Number = 0 Then
    If eQuery And OLECMDF_ENABLED Then
        WebBrowser1.ExecWB OLECMDID_PRINT,
          OLECMDEXECOPT_PROMPTUSER, "", ""    'Ok to Print?
    Else
      MsgBox "The Print command is currently disabled."
    End If
End If
If Err.Number <> 0 Then MsgBox "Print command Error: " & Err.Description
End Sub
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Without testing, I'd guess that you could use the QueryStatusWB() member of CHtmlView to learn whether printing was allowed and display a messagebox.  Even if this is not a satisfactory overall solution, I suggest that you try it to help identify the problem and see if it leads to that solution.

-- Dan
0
 
jrcAuthor Commented:
OK, after updating to Windows 2000 service back 2 and every other Windows update available for Windows 2000 it now works OK.
0
 
Roshan DavisCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : DanRollins

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.