CHtmlView::OnPrint crashes under Windows 2000

Posted on 2001-06-15
Last Modified: 2013-11-20
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
Question by:jrc
  • 3
  • 3
LVL 49

Expert Comment

ID: 6197768
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

Author Comment

ID: 6198514
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.
LVL 49

Accepted Solution

DanRollins earned 100 total points
ID: 6199444
Check the Debug trace window.  Are there any messages there that could lend a clue?

-- Dan
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!


Author Comment

ID: 6199862
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

LVL 49

Expert Comment

ID: 6200992
Here's a snippete of VB code that checks to see if printing is enabled.  I found it at:

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?
      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

Author Comment

ID: 6208464
OK, after updating to Windows 2000 service back 2 and every other Windows update available for Windows 2000 it now works OK.
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490004
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.


Roshan Davis
EE Cleanup Volunteer

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASCII Non-Printable characters/codes and their HTML equivalents 6 115
either24  challenge 19 97
ShiftLeft challenge 21 80
Use of condition with 'serial' in ansible 2 59
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question