Product : Engine, Version : 5.0.0.1033, ArticleID : 41023586

HowTo : Gradient image as backround.

Article41023586
TypeHowTo
ProductEngine
Version5.0.0.1033
Date Added5/27/2004
Submitted byDamon CNC Developer
Keywords

Subject

Gradient image as backround.

Summary

Some of our users also use other design software which allows the user to choose DirectX for graphics and set a gradient drawing background, as trivial as this may seem many users want this, if you could add this to your wishlist that would be great.

Solution

In 5.0.0.1033 you can use the DrawBackground event as follow:

void CVdView::OnDrawBackgroundvdrawctrl2(LPDISPATCH Render, short FAR* Cancel)
{
 CPicture pic = m_Vdraw.GetUtility().GetFilePicture(_T("C:\\_TRAMBA\\A71\\0513_humornanet_com_an.jpg"));
 CvdRender rend;
 rend.AttachDispatch(Render,FALSE);
 HDC hdc = (HDC)rend.GetHdc();
 HDC hScreen = ::GetDC(NULL);
 HDC hDC  = ::CreateCompatibleDC(hScreen);
 CSize size(pic.GetWidth(),pic.GetHeight());
 CDC::FromHandle(hdc)->HIMETRICtoLP (&size);

 ::ReleaseDC(NULL,hScreen);
 HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hDC,(HBITMAP)pic.GetHandle());
 StretchBlt(hdc,0, 0, rend.GetWidth(), rend.GetHeight(),
    hDC,0,0, size.cx,size.cy,SRCCOPY);
 ::SelectObject(hDC,hOldBitmap);
 DeleteDC(hDC);
 
 *Cancel = 1;
 
}