Home > Software engineering >  ATL control in the Office Word display abnormal (BitBlt)
ATL control in the Office Word display abnormal (BitBlt)

Time:11-20

I use VS2008 has built a ATL project, add the OnCreate method (modified extended window style only for transparent)
LRESULT OnCreate (UINT uMsg *//* and WPARAM WPARAM/* */, LPARAM LPARAM *//* and BOOL&/* bHandled */)
{
Const LONG_PTR exStyle=GetWindowLongPtr (GWL_EXSTYLE);
SetWindowLongPtr (GWL_EXSTYLE, exStyle | WS_EX_TRANSPARENT);
return 0;
}
And modify OnDrawAdvanced for loading images from disk and map to the window (by BitBlt SRCAND)
HRESULT OnDrawAdvanced (ATL_DRAWINFO & amp; Di)
{
RECT& Rc=* (the RECT *) di prcBounds;

CImage imgx;
Imgx. Load (_T (" C: \ \ image JPG "));
Imgx. StretchBlt (di hdcDraw, rc, left, rc, top, rc. Right, rc. Bottom, 0, 0, imgx. GetWidth (), imgx. GetHeight (), SRCAND);

Return S_OK.
}
Load JPG image is as follows:


The above code compiled in Word2007 whatever embed mode can be set to normal, according to



But in Word2013, met a strange phenomenon:
When set to the embedded type, like 2007, all normal

When set to the embedded type other than any other way, the image into a black and white,


When changing the StretchBlt to TransparentBlt, completely unable to display picture, but drag word scroll bar or click when a flash

What is this? How to solve,

CodePudding user response:

Must be embedded control? No direct pictures?

CodePudding user response:

Have the results? Hope to be able to reply,
  • Related