Home > Software engineering >  AlphaBlend function in the mousemove function how to remove the last FillSolidRect set translucent
AlphaBlend function in the mousemove function how to remove the last FillSolidRect set translucent

Time:09-20



CRect dstrect;
M_picture. GetWindowRect (& amp; Dstrect);
The ScreenToClient (& amp; Dstrect);

The CDC * ppicdc=m_picture. GetDC ();

BLENDFUNCTION bf;
Bf. BlendOp=AC_SRC_OVER;//AC_SRC_ALPHA;
Bf. BlendFlags=0;
Bf. SourceConstantAlpha=30;//translucent

The CDC * pmemdc=new CDC ();
CBitmap BMP, * poldbitmap;
Pmemdc - & gt; CreateCompatibleDC (ppicdc);
BMP. CreateCompatibleBitmap (ppicdc dstrect), Width (), dstrect. Height ());
Poldbitmap=pmemdc - & gt; SelectObject (& amp; BMP);

Pmemdc - & gt; Selectrt FillSolidRect (selectrt. Left, top, selectrt. The Width (), selectrt. Height (), RGB (0, 0, 255));//blue
: : AlphaBlend function (ppicdc - & gt; GetSafeHdc (), selectrt left, selectrt. Top, selectrt. The Width (), selectrt. Height (), pmemdc - & gt; GetSafeHdc (), selectrt left, selectrt. Top, selectrt. The Width (), selectrt. Height (), bf);

Pmemdc - & gt; SelectObject (poldbitmap);
If (pmemdc!=NULL)
{
The ReleaseDC (pmemdc);
The delete pmemdc pmemdc=NULL;
}

Mousemove selectrt a piece of code is the rectangular area of the mouse after selected, always call mousemove translucent will deepen, how can I keep the rectangle at the start of the translucent?

CodePudding user response:

With a tag, effective for the first time, after is invalid,

CodePudding user response:

reference 1st floor schlafenhamster response:
set a tag, effective for the first time, after is invalid,


Can refresh without picture control area, through partial erase or partial redraw the way after you remove the mouse returned to the gratification of transparent?

CodePudding user response:

Try SetROP2 (HDC, R2_NOTXORPEN); drawing similar to the rubber band



CodePudding user response:

refer to the second floor Mana777 response:
Quote: refer to 1st floor schlafenhamster response:

A mark, and effective for the first time, after the invalid,


Can refresh without picture control area, through partial erase or partial redraw the way after you remove the mouse returned to the gratification of transparent?


It is need to do labeling,,,

CodePudding user response:

Also can put the PIC of the background to make a PatternBrush
Use it to draw the background when the paint

CodePudding user response:

PIC derivation processing

//CMyStatic message handlers

Void CMyStatic: : OnPaint ()
{
CPaintDC dc (this);//device context for painting
//TODO: Add your message handler code here
CRect rc;
GetClientRect (& amp; Rc);

The CDC memdc;
Memdc. CreateCompatibleDC (& amp; Dc);

CBitmap BMP, * poldbitmap;
BMP. CreateCompatibleBitmap (& amp; Dc, rc. Width (), the rc Height ());

Poldbitmap=memdc. SelectObject (& amp; BMP);
//mouse in the PIC and add a layer of translucent blue
If (m_hover)
{
//AC_SRC_ALPHA=1
Memdc. FillSolidRect (rc, RGB (0, 0, 255));//blue
BLENDFUNCTION bf={AC_SRC_OVER, 0, 30, 0};//constant alpha 0.5
AlphaBlend function (dc GetSafeHdc (), 0, 0, rc. The Width (), rc, Height (),
Memdc. GetSafeHdc (), 0, 0, rc. The Width (), rc, Height (), bf);
}
The else
{//the mouse not on the PIC to redraw the original background; Use patBr
if(! M_pPatBr)
{
CCrayonDlg * pDlg=(CCrayonDlg *) GetParent ();
M_pPatBr=pDlg - & gt; GetPicPatBr ();
}
Memdc. FillRect (rc, m_pPatBr);//
Dc. BitBlt (0, 0, rc Width (), rc, Height (), & amp; Memdc, 0, 0, SRCCOPY);
}
//
Memdc. SelectObject (poldbitmap);
//the Do not call CStatic: : OnPaint () for painting the messages
}

Void CMyStatic: : onm ouseMove (UINT nFlags, CPoint point)
{
//TODO: Add your message handler code here and/or call the default
if(! M_hover)
{//only 1
M_hover=TRUE;
TRACKMOUSEEVENT tme.
Tme. CbSize=sizeof (tme);
Tme. HwndTrack=m_hWnd;
Tme. DwFlags=TME_LEAVE | TME_HOVER;
Tme. DwHoverTime=20;
_TrackMouseEvent (& amp; Tme);
}
//
CStatic: onm ouseMove (nFlags, point);
}

LRESULT CMyStatic: : onm ouseHover (WPARAM WPARAM, LPARAM LPARAM)
{
//afxDump & lt; <"Hover \ n";
Invalidate ().
return 0;
}

LRESULT CMyStatic: : onm ouseLeave (WPARAM WPARAM, LPARAM LPARAM)
{
//afxDump & lt; <"Leave \ n";
If (m_hover)
{
M_hover=FALSE;
Invalidate ().
}
return 0;
}

CodePudding user response:

  • Related