Solved

CHtmlView::OnPrint crashes under Windows 2000

Posted on 2001-06-15
7
333 Views
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
0
Comment
Question by:jrc
  • 3
  • 3
7 Comments
 
LVL 49

Expert Comment

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

Author Comment

by:jrc
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.
0
 
LVL 49

Accepted Solution

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

-- Dan
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jrc
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


0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6200992
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
 

Author Comment

by:jrc
ID: 6208464
OK, after updating to Windows 2000 service back 2 and every other Windows update available for Windows 2000 it now works OK.
0
 
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now