亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? btnst.cpp

?? 一個功能挺多的
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//
//Modify by 徐景周 2000.10
//功能:平面按鈕顯示及鼠標捕捉不到按鈕郊果

#include "stdafx.h"
#include "BtnST.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CButtonST

CButtonST::CButtonST()
{
    m_nJumpDistance = 10; //按鈕不讓鼠標碰到的自移動距離

	m_MouseOnButton = FALSE;

	m_hIconIn = NULL;
	m_hIconOut = NULL;
	m_cxIcon = 0;
	m_cyIcon = 0;
	m_hCursor = NULL;
  
	m_bTrickButton=false; //按鈕自移動默認值為假

	// Default type is "flat" button
	m_bIsFlat = TRUE; 
  
	// By default draw border in "flat" button 
	m_bDrawBorder = TRUE; 
  
	// By default icon is aligned horizontally
	m_nAlign = ST_ALIGN_HORIZ; 
  
	// By default show the text button
	m_bShowText = TRUE; 
  
	// By default, for "flat" button, don't draw the focus rect
	m_bDrawFlatFocus = FALSE;

	// By default the button is not the default button
	m_bIsDefault = FALSE;

	SetDefaultInactiveBgColor();
	SetDefaultInactiveFgColor();
	SetDefaultActiveBgColor();
	SetDefaultActiveFgColor();

	// No tooltip created
	m_ToolTip.m_hWnd = NULL;

	// Do not draw as a transparent button
	m_bDrawTransparent = FALSE;
	m_pbmpOldBk = NULL;
} // End of CButtonST


CButtonST::~CButtonST()
{
	// Restore old bitmap (if any)
	if (m_dcBk.m_hDC != NULL && m_pbmpOldBk != NULL)
	{
		m_dcBk.SelectObject(m_pbmpOldBk);
	}

	// Destroy the icons (if any)
	// Note: the following two lines MUST be here! even if
	// BoundChecker says they are unnecessary!
	if (m_hIconIn != NULL) ::DestroyIcon(m_hIconIn);
	if (m_hIconOut != NULL) ::DestroyIcon(m_hIconOut);
	// Destroy the cursor (if any)
	if (m_hCursor != NULL) ::DestroyCursor(m_hCursor);
} // End of ~CButtonST


BEGIN_MESSAGE_MAP(CButtonST, CButton)
    //{{AFX_MSG_MAP(CButtonST)
	ON_WM_CAPTURECHANGED()
	ON_WM_SETCURSOR()
	ON_WM_KILLFOCUS()
	ON_WM_MOUSEMOVE()
	ON_WM_CTLCOLOR_REFLECT()
	ON_WM_SYSCOLORCHANGE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


void CButtonST::SetIcon(int nIconInId, int nIconOutId)
{
	HICON hIconIn;
	HICON hIconOut;
	HINSTANCE hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(nIconInId), RT_GROUP_ICON);

	// Set icon when the mouse is IN the button
	hIconIn = (HICON)::LoadImage(hInstResource/*AfxGetApp()->m_hInstance*/, MAKEINTRESOURCE(nIconInId), IMAGE_ICON, 0, 0, 0);
  	// Set icon when the mouse is OUT the button
	hIconOut = (nIconOutId == NULL) ? NULL : (HICON)::LoadImage(hInstResource/*AfxGetApp()->m_hInstance*/, MAKEINTRESOURCE(nIconOutId), IMAGE_ICON, 0, 0, 0);

	SetIcon(hIconIn, hIconOut);
/*
	// Note: the following two lines MUST be here! even if
	// BoundChecker says they are unnecessary!
	if (m_hIconIn != NULL) ::DestroyIcon(m_hIconIn);
	if (m_hIconOut != NULL) ::DestroyIcon(m_hIconOut);

	// Set icon when the mouse is IN the button
	m_hIconIn = (HICON)::LoadImage(hInstResource, MAKEINTRESOURCE(nIconInId), IMAGE_ICON, 0, 0, 0);
  	// Set icon when the mouse is OUT the button
	m_hIconOut = (nIconOutId == NULL) ? m_hIconIn : (HICON)::LoadImage(hInstResource, MAKEINTRESOURCE(nIconOutId), IMAGE_ICON, 0, 0, 0);
  
	ICONINFO ii;

	// Get icon dimension
	ZeroMemory(&ii, sizeof(ICONINFO));
	::GetIconInfo(m_hIconIn, &ii);

	m_cxIcon = (BYTE)(ii.xHotspot * 2);
	m_cyIcon = (BYTE)(ii.yHotspot * 2);
    ::DeleteObject(ii.hbmMask);
	::DeleteObject(ii.hbmColor);

	RedrawWindow();
*/
} // End of SetIcon

void CButtonST::SetIcon(HICON hIconIn, HICON hIconOut)
{
	// Note: the following two lines MUST be here! even if
	// BoundChecker says they are unnecessary!
	if (m_hIconIn != NULL) ::DestroyIcon(m_hIconIn);
	if (m_hIconOut != NULL) ::DestroyIcon(m_hIconOut);

	// Set icon when the mouse is IN the button
	m_hIconIn = hIconIn;
	// Set icon when the mouse is OUT the button
	m_hIconOut = (hIconOut == NULL) ? m_hIconIn : hIconOut;
  
	ICONINFO ii;

	// Get icon dimension
	ZeroMemory(&ii, sizeof(ICONINFO));
	::GetIconInfo(m_hIconIn, &ii);

	m_cxIcon = (BYTE)(ii.xHotspot * 2);
	m_cyIcon = (BYTE)(ii.yHotspot * 2);
    ::DeleteObject(ii.hbmMask);
	::DeleteObject(ii.hbmColor);

	RedrawWindow();
} // End of SetIcon

BOOL CButtonST::SetBtnCursor(int nCursorId)
{
	HINSTANCE hInstResource;
	// Destroy any previous cursor
	if (m_hCursor != NULL) ::DestroyCursor(m_hCursor);
	m_hCursor = NULL;

	// If we want a cursor
	if (nCursorId != -1)
	{
		hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(nCursorId),
											RT_GROUP_CURSOR);
		// Load icon resource
		m_hCursor = (HCURSOR)::LoadImage(hInstResource/*AfxGetApp()->m_hInstance*/, MAKEINTRESOURCE(nCursorId), IMAGE_CURSOR, 0, 0, 0);
		// If something wrong then return FALSE
		if (m_hCursor == NULL) return FALSE;
	}

	return TRUE;
} // End of SetBtnCursor

//在此新增加按鈕自移動設置和判斷涵數
void CButtonST::SetTrickButton(BOOL bTrick)
{
  m_bTrickButton = bTrick;
}

BOOL CButtonST::GetTrickButton()
{
  return m_bTrickButton;
}

void CButtonST::SetFlat(BOOL bState)
{
  m_bIsFlat = bState;
  Invalidate();
} // End of SetFlat


BOOL CButtonST::GetFlat()
{
  return m_bIsFlat;
} // End of GetFlat



void CButtonST::SetAlign(int nAlign)
{
  switch (nAlign)
  {    
    case ST_ALIGN_HORIZ:
         m_nAlign = ST_ALIGN_HORIZ;
         break;
    case ST_ALIGN_HORIZ_RIGHT:
         m_nAlign = ST_ALIGN_HORIZ_RIGHT;
         break;
    case ST_ALIGN_VERT:
         m_nAlign = ST_ALIGN_VERT;
         break;
  }
  Invalidate();
} // End of SetAlign


int CButtonST::GetAlign()
{
  return m_nAlign;
} // End of GetAlign


void CButtonST::DrawBorder(BOOL bEnable)
{
  m_bDrawBorder = bEnable;
} // End of DrawBorder


const char* CButtonST::GetVersionC()
{
  return "2.6";
} // End of GetVersionC


const short CButtonST::GetVersionI()
{
  return 26; // Divide by 10 to get actual version
} // End of GetVersionI


void CButtonST::SetShowText(BOOL bShow)
{
  m_bShowText = bShow;
  Invalidate();
} // End of SetShowText


BOOL CButtonST::GetShowText()
{
  return m_bShowText;
} // End of GetShowText


void CButtonST::OnMouseMove(UINT nFlags, CPoint point)
{
  if(GetTrickButton()) //當按鈕設置為自移動,不讓鼠標碰到時
  {
	//新增功能,加入隨鼠標按鈕不斷移動,不讓鼠標碰上按鈕郊果
	CWnd* pParent = GetParent();
    if (!pParent) pParent = GetDesktopWindow();

    CRect ParentRect;                                   // Parent client area (Parent coords)
    pParent->GetClientRect(ParentRect);

    ClientToScreen(&point);                             // Convert point to parent coords
    pParent->ScreenToClient(&point);

    CRect ButtonRect;                                   // Button Dimensions (Parent coords)
    GetWindowRect(ButtonRect);  
    pParent->ScreenToClient(ButtonRect);
    CPoint Center = ButtonRect.CenterPoint();           // Center of button (parent coords)

    CSize CriticalSize(ButtonRect.Width()/6, ButtonRect.Height()/6);


    CRect NewButtonRect = ButtonRect;                    // New position (parent coords)

    if (point.x - CriticalSize.cx > Center.x)            // Mouse is right of center
    {
        if (ButtonRect.left > ParentRect.left + ButtonRect.Width() + m_nJumpDistance)
            NewButtonRect -= CSize(ButtonRect.right - point.x + m_nJumpDistance, 0);
        else
            NewButtonRect += CSize(point.x - ButtonRect.left + m_nJumpDistance, 0);
    }
    else if (point.x + CriticalSize.cx < Center.x)      // Mouse is left of center
    {
        if (ButtonRect.right < ParentRect.right - ButtonRect.Width() - m_nJumpDistance)
            NewButtonRect += CSize(point.x - ButtonRect.left + m_nJumpDistance, 0);
        else
            NewButtonRect -= CSize(ButtonRect.right - point.x + m_nJumpDistance, 0);
    }

    if (point.y - CriticalSize.cy > Center.y)           // Mouse is below center
    {
        if (ButtonRect.top > ParentRect.top + ButtonRect.Height() + m_nJumpDistance)
            NewButtonRect -= CSize(0, ButtonRect.bottom - point.y + m_nJumpDistance);
        else
            NewButtonRect += CSize(0, point.y - ButtonRect.top + m_nJumpDistance);
    }
    else if (point.y + CriticalSize.cy < Center.y)      // Mouse is above center
    {
        if (ButtonRect.bottom < ParentRect.bottom - ButtonRect.Height() - m_nJumpDistance)
            NewButtonRect += CSize(0, point.y - ButtonRect.top + m_nJumpDistance);
        else
            NewButtonRect -= CSize(0, ButtonRect.bottom - point.y + m_nJumpDistance);
    }

    MoveWindow(NewButtonRect);
    RedrawWindow();
  }

	CButton::OnMouseMove(nFlags, point);

	//原函數功能,捕捉鼠標
    CWnd* pWnd;  // Finestra attiva
	CWnd* pParent; // Finestra che contiene il bottone

	// If the mouse enter the button with the left button pressed
	// then do nothing
	if (nFlags & MK_LBUTTON && m_MouseOnButton == FALSE) return;

	// If our button is not flat then do nothing
	if (m_bIsFlat == FALSE) return;

	pWnd = GetActiveWindow();
	pParent = GetOwner();

	if ((GetCapture() != this) && 
		(
#ifndef ST_LIKEIE
		pWnd != NULL && 
#endif
		pParent != NULL)) 
	{
		m_MouseOnButton = TRUE;
		//SetFocus();	// Thanks Ralph!
		SetCapture();
		Invalidate();
	}
	else
	{
		/*
		CRect rc;
		GetClientRect(&rc);
		if (!rc.PtInRect(point))
		{
		*/

		POINT p2 = point;
		ClientToScreen(&p2);
		CWnd* wndUnderMouse = WindowFromPoint(p2);
//		if (wndUnderMouse != this)
		if (wndUnderMouse && wndUnderMouse->m_hWnd != this->m_hWnd)
		{
			// Redraw only if mouse goes out
			if (m_MouseOnButton == TRUE)
			{
				m_MouseOnButton = FALSE;
				Invalidate();
			}
			// If user is NOT pressing left button then release capture!
			if (!(nFlags & MK_LBUTTON)) ReleaseCapture();
		}
	}
} // End of OnMouseMove


void CButtonST::OnKillFocus(CWnd * pNewWnd)
{
  CButton::OnKillFocus(pNewWnd);

  // If our button is not flat then do nothing
  if (m_bIsFlat == FALSE) return;

  if (m_MouseOnButton == TRUE)
  {
    m_MouseOnButton = FALSE;
    Invalidate();
  }
} // End of OnKillFocus


void CButtonST::OnCaptureChanged(CWnd *pWnd) 
{
	if (m_MouseOnButton == TRUE)
	{
		ReleaseCapture();
		Invalidate();
	}

	// Call base message handler
	CButton::OnCaptureChanged(pWnd);
} // End of OnCaptureChanged


void CButtonST::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
#ifdef ST_USE_MEMDC
  CDC  *pdrawDC = CDC::FromHandle(lpDIS->hDC);
  CMemDC memDC(pdrawDC);
  CDC  *pDC = &memDC;
#else	
  CDC* pDC = CDC::FromHandle(lpDIS->hDC);
#endif

  CPen *pOldPen;
  BOOL bIsPressed  = (lpDIS->itemState & ODS_SELECTED);
  BOOL bIsFocused  = (lpDIS->itemState & ODS_FOCUS);
  BOOL bIsDisabled = (lpDIS->itemState & ODS_DISABLED);

  CRect itemRect = lpDIS->rcItem;

  pDC->SetBkMode(TRANSPARENT);

  if (m_bIsFlat == FALSE)
  {
    if (bIsFocused || (GetDefault() == TRUE))
    {
      CBrush br(RGB(0,0,0));  
      pDC->FrameRect(&itemRect, &br);
      itemRect.DeflateRect(1, 1);
    }
  }

  // Prepare draw... paint button's area with background color
  COLORREF bgColor;
  if ((m_MouseOnButton == TRUE) || (bIsPressed))
    bgColor = GetActiveBgColor();
  else
    bgColor = GetInactiveBgColor();

	CBrush br(bgColor);
	// Draw transparent?
	if (m_bDrawTransparent == TRUE)
	{
		PaintBk(pDC);
	}
	else
	{
		pDC->FillRect(&itemRect, &br);
	}

	// Disegno lo sfondo del bottone
//CBrush br(GetSysColor(COLOR_BTNFACE));  
//pDC->FillRect(&itemRect, &br);

  // Draw pressed button
  if (bIsPressed)
  {
    if (m_bIsFlat == TRUE)
    {
      if (m_bDrawBorder == TRUE)
      {
		  pDC->Draw3dRect(itemRect, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHILIGHT));
/*
	    CPen penBtnHiLight(PS_SOLID, 0, GetSysColor(COLOR_BTNHILIGHT)); // Bianco
        CPen penBtnShadow(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW));   // Grigio scuro

        // Disegno i bordi a sinistra e in alto
        // Dark gray line
        pOldPen = pDC->SelectObject(&penBtnShadow);
        pDC->MoveTo(itemRect.left, itemRect.bottom-1);
        pDC->LineTo(itemRect.left, itemRect.top);
        pDC->LineTo(itemRect.right, itemRect.top);
        // Disegno i bordi a destra e in basso
        // White line
        pDC->SelectObject(penBtnHiLight);
        pDC->MoveTo(itemRect.left, itemRect.bottom-1);
        pDC->LineTo(itemRect.right-1, itemRect.bottom-1);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国产免费观看| 精品成人一区二区| 日韩欧美一级二级| 亚洲天堂网中文字| 韩国成人在线视频| 欧美日韩在线一区二区| 1024国产精品| 丁香五精品蜜臀久久久久99网站 | 欧美性极品少妇| 亚洲国产精品国自产拍av| 久久精品国产亚洲一区二区三区| 91久久精品网| 一区二区在线观看视频| 成人白浆超碰人人人人| 久久久精品tv| 精品一区二区国语对白| 91精品国产乱码久久蜜臀| 亚洲va国产va欧美va观看| 色哟哟欧美精品| 国产精品日日摸夜夜摸av| 国内一区二区视频| wwwwxxxxx欧美| 国精产品一区一区三区mba视频| 91久久精品一区二区二区| 亚洲精品视频在线观看网站| 97精品电影院| 亚洲人成亚洲人成在线观看图片| 国产精品夜夜嗨| 久久久精品国产免大香伊| 国产精品1区二区.| 中文字幕av免费专区久久| 国产精品亚洲专一区二区三区| 精品伦理精品一区| 国产精品白丝jk白祙喷水网站| 欧美精品一区二区精品网| 国产一区免费电影| 国产精品乱码一区二三区小蝌蚪| 成人av在线资源网| 亚洲精品日韩综合观看成人91| 色噜噜狠狠成人中文综合| 亚洲精品亚洲人成人网在线播放| 欧美最新大片在线看| 亚洲成人手机在线| 精品久久久久久无| 99视频一区二区| 夜色激情一区二区| 91精品国产综合久久精品| 理论片日本一区| 欧美激情一区二区三区| 91在线你懂得| 香蕉乱码成人久久天堂爱免费| 日韩亚洲欧美一区| 国产二区国产一区在线观看| 亚洲欧美日韩综合aⅴ视频| 欧美性极品少妇| 国产一区二区三区四区五区入口 | 不卡的av网站| 成人欧美一区二区三区小说| 欧美中文一区二区三区| 奇米777欧美一区二区| 久久久久国产精品人| 色菇凉天天综合网| 国产在线精品一区二区| 亚洲精品视频在线观看网站| 日韩一卡二卡三卡四卡| 成人av一区二区三区| 日韩影视精彩在线| 国产精品人人做人人爽人人添| 欧美日韩激情一区二区| 国产白丝网站精品污在线入口| 亚洲一区二区精品视频| 国产欧美综合在线| 欧美丰满嫩嫩电影| 成人晚上爱看视频| 日本vs亚洲vs韩国一区三区二区| 国产精品欧美综合在线| 91精品中文字幕一区二区三区| 成人国产免费视频| 麻豆国产一区二区| 一区二区三区在线免费视频| 久久嫩草精品久久久久| 51久久夜色精品国产麻豆| 91免费观看在线| 国产剧情一区在线| 免费成人美女在线观看| 亚洲国产精品影院| 欧美国产亚洲另类动漫| www国产成人| 日韩欧美一区二区久久婷婷| 欧美视频精品在线观看| 成人性生交大片免费看在线播放| 老司机精品视频一区二区三区| 亚洲国产中文字幕在线视频综合| 国产精品美日韩| 国产日韩欧美一区二区三区综合| 日韩视频国产视频| 日韩一区二区免费高清| 欧美福利视频一区| 欧美日韩精品欧美日韩精品一| 成人免费视频播放| 国产成人精品免费网站| 国产精品一色哟哟哟| 久久精品国产久精国产爱| 婷婷成人激情在线网| 亚洲国产一区二区三区青草影视| 综合av第一页| 亚洲另类一区二区| 亚洲精品国产第一综合99久久| 1024国产精品| 亚洲激情av在线| 亚洲久草在线视频| 亚洲福利视频一区二区| 亚洲午夜在线视频| 三级成人在线视频| 麻豆久久久久久久| 国产精一区二区三区| 国产精品影视天天线| 成人v精品蜜桃久久一区| 国产成人在线免费观看| 欧美日韩在线直播| 欧美日韩一区中文字幕| 欧美日韩国产一二三| 欧美日韩精品电影| 日韩一区二区三区高清免费看看| 欧美成人aa大片| 国产偷国产偷精品高清尤物| 欧美高清在线一区| 亚洲摸摸操操av| 五月天丁香久久| 国产美女精品在线| 国产91富婆露脸刺激对白| 91老司机福利 在线| 欧美日韩精品是欧美日韩精品| 欧美一卡二卡在线观看| 久久久777精品电影网影网| 国产精品伦一区| 亚洲成人免费在线| 国产剧情一区二区| 一本色道综合亚洲| 日韩欧美www| 中文字幕av一区二区三区 | 91麻豆精品国产自产在线观看一区| 在线成人av网站| 久久你懂得1024| 亚洲自拍偷拍综合| 久久99精品久久久久久国产越南| 成人在线综合网| 欧美亚洲综合另类| 国产日韩欧美综合在线| 亚洲成人先锋电影| 风流少妇一区二区| 欧美精品第1页| 中文字幕在线不卡一区| 日本不卡一二三区黄网| 91婷婷韩国欧美一区二区| 91麻豆精品国产91久久久 | 精品国产一区二区三区av性色| 国产欧美一区二区三区沐欲| 亚洲一区免费在线观看| 国产精品18久久久久久久网站| 欧洲av一区二区嗯嗯嗯啊| 国产欧美日韩精品在线| 日韩精品一区第一页| 91在线视频观看| 久久综合狠狠综合久久综合88| 亚洲愉拍自拍另类高清精品| 国产精品影视在线| 91精品一区二区三区在线观看| 成人免费在线播放视频| 久草在线在线精品观看| 欧美日韩一区二区在线观看视频| 国产午夜精品久久| 日韩激情一区二区| 色综合天天综合网国产成人综合天 | 日韩一级欧美一级| 亚洲欧美激情小说另类| 国产毛片精品视频| 日韩一区二区精品| 日韩中文欧美在线| 欧美色偷偷大香| 亚洲精选视频免费看| 成人aaaa免费全部观看| 亚洲精品在线免费观看视频| 日韩激情视频在线观看| 欧美日韩三级在线| 亚洲国产一区二区视频| 91蜜桃在线观看| 综合久久久久久| 94-欧美-setu| 国产精品高潮呻吟| 成人免费看视频| 久久亚洲综合色| 国产成人免费av在线| 欧美va亚洲va在线观看蝴蝶网| 日韩国产在线一| 717成人午夜免费福利电影| 亚洲成a人片综合在线| 欧美日韩精品一区二区| 视频一区二区不卡| 日韩欧美国产wwwww|