Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6172853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:27:54+00:00 2026-05-23T23:27:54+00:00

I am a beginner in vc++. I am trying to convert an html file

  • 0

I am a beginner in vc++. I am trying to convert an html file to image and save it as png, in vc++. Now I converted the html into bitmap and save using save function of CImage. I want to run this application in windows 2008. It works properly when run the application manually. I need to run it through a schedule task. But when the application runs through schedule task the image is not created.

How can I overcome this problem?

This is my code

BOOL CCreateHtml::CreateImage(IHTMLDocument2 *pDoc,LPCTSTR szDestFilename,CSize srcSize){
IHTMLDocument3* pDocument3 = NULL;
IHTMLDocument2* pDocument  = NULL;
IHTMLElement2* pElement2   = NULL;
IHTMLElement* pElement     = NULL;
IViewObject2* pViewObject  = NULL;
IDispatch* pDispatch       = NULL;
IViewObject* pViewObj = NULL;

HRESULT hr;

long bodyHeight;
long bodyWidth;
long rootHeight;
long rootWidth;
long height;
long width;
CImage img;
    if(FAILED(m_pBrowser->get_Document(&pDispatch)))
    return FALSE;
if(FAILED(pDispatch->QueryInterface(IID_IHTMLDocument2,(void**)&pDocument)))
    return FALSE;
if(FAILED(pDocument->get_body(&pElement)))
    return FALSE;
if(FAILED(pElement->QueryInterface(IID_IHTMLElement2,(void**)&pElement2)))
    return FALSE;
if(FAILED(pElement2->get_scrollHeight(&bodyHeight)))
    return FALSE;
if(FAILED(pElement2->get_scrollWidth(&bodyWidth)))
    return FALSE;
if(FAILED(pDispatch->QueryInterface(IID_IHTMLDocument3,(void**)&pDocument3)))
    return FALSE;
if(FAILED(pDocument3->get_documentElement(&pElement)))
    return FALSE;
if(FAILED(pElement->QueryInterface(IID_IHTMLElement2,(void**)&pElement2)))
    return FALSE;
if(FAILED(pElement2->get_scrollHeight(&rootHeight)))
    return FALSE;   
if(FAILED(pElement2->get_scrollWidth(&rootWidth)))
    return FALSE;

HBITMAP m_hBmp;
width = bodyWidth;
height = rootHeight > bodyHeight ? rootHeight : bodyHeight;

if(width > 2000)
    width = 2000;
if(height > 2000)
    height = 2000;

MoveWindow(0,0,width,height,TRUE);
::MoveWindow(m_hwndWebBrowser,0,0,width,height,TRUE);

if(FAILED(m_pBrowser->QueryInterface(IID_IViewObject2,(void**)&pViewObject)))
    return FALSE;

CDC *cdcMain = GetDC();
HDC hdcMain = *cdcMain;
HDC hdcMem = CreateCompatibleDC(hdcMain);
m_hBmp = CreateCompatibleBitmap(hdcMain,width,height);
SelectObject(hdcMem,m_hBmp);

RECTL rcBounds = { 0, 0, width, height };

hr = pViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL,hdcMain,hdcMem, &rcBounds, NULL, NULL, 0);

img.Attach(m_hBmp);
if(!hr ==img.Save(szDestFilename))
    return FALSE;
img.Detach();
img.Destroy();

pViewObject->Release();
return TRUE;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:27:55+00:00Added an answer on May 23, 2026 at 11:27 pm

    You’re not gonna like the answer but there’s is no build-in support for PNG images, you’ll need to use an external library like pnglib

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a Lisp beginner. I'm trying to memoize a recursive function for calculating the
I am beginner in PHP. I am trying to parse this xml file. <relationship>
I'm trying to move past the beginner stage of Rails and into the intermediate
I am a JS, html beginner and trying to understand how to define/create a
Please forgive me for being a complete beginner: I am trying to log into
I am php beginner and I am trying to make e-commerce by using php.
i'm a beginner in PHP and i'm trying to make a login screen using
I'm a beginner in Andoird, currently trying to write an application using the Camera
I'm a beginner at using Python and I've been trying to code a Minesweeper
This is a very beginner problem. I'm trying to display an image taken with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.