⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fopopupcolorpalettewnd.cpp

📁 visual c++ 实例编程
💻 CPP
字号:
// Copyright UCanCode Software Technology Inc, All Rights Reserved
// You can contact us.
// Support@UCanCode.net
// http://www.ucancode.net
/********************************************************************/
// FOPopupColorPaletteWnd.cpp : implementation file
//

#include "stdafx.h"
#include "FOPopupColorPaletteWnd.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFOPopupColorPaletteWnd


CFOPopupColorPaletteWnd::CFOPopupColorPaletteWnd()
{
}

CFOPopupColorPaletteWnd::~CFOPopupColorPaletteWnd()
{
}


BEGIN_MESSAGE_MAP(CFOPopupColorPaletteWnd, CFODropColorPaletteWnd)
//{{AFX_MSG_MAP(CFOPopupColorPaletteWnd)
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFOPopupColorPaletteWnd message handlers

void CFOPopupColorPaletteWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
	CFODropColorPaletteWnd::OnActivate(nState, pWndOther, bMinimized);
	if ( nState == WA_INACTIVE )
    {
		m_pColorControl->OnSelectOK(UINT(m_pColorControl->GetRGB()),0L);   
    }
}

BOOL CFOPopupColorPaletteWnd::Create(DWORD dwStyle,
								 CRect& buttonRect,
								 CWnd* pParentWnd,COLORREF crDefault,CSize szPopup,
								 CCreateContext* pContext) 
{
    // We need to calculate where to place the popup, but first we have to
    // calculate it's size.  First, create an appropriately-sized rect.
    CRect r;
	r.BottomRight() = r.TopLeft()+szPopup;
    
    // Next, move it to the origin.  We'll later move it from there.
    r.OffsetRect(-r.TopLeft());
    
    // Now adjust the rectangle to include the non-client space
    ::AdjustWindowRectEx(&r, dwStyle | WS_POPUP, NULL, 0);
    r.OffsetRect(-r.left, -r.top);
    
    // Support info for placing the popup so it doesn't go off-screen.
    CRect rectWorkArea;
    
#ifdef WIN32
    SystemParametersInfo(SPI_GETWORKAREA, 0, &rectWorkArea, 0); 
#else 
    int cxScreen = ::GetSystemMetrics(SM_CXSCREEN);
    int cyScreen = ::GetSystemMetrics(SM_CYSCREEN);
    
    rectWorkArea.SetRect(0,0,cxScreen,cyScreen);
#endif
    
    CPoint offset;
    
    if(dwStyle & FO_ALIGNBOTTOMLEFT)
    {
        // Position below the supplied rectangle if possible, otherwise
        // above
        if((buttonRect.bottom + r.Height()) >= rectWorkArea.bottom)
            offset.y = buttonRect.top - r.Height();
        else
            offset.y = buttonRect.bottom;
        
        if((buttonRect.left + r.Width()) >= rectWorkArea.right)
            offset.x = buttonRect.right - r.Width();
        else
            offset.x = buttonRect.left;
    }
    else
    {
		// We'd like below and right, if possible.  If not, then above 
		// and/or left is the second choice.
		BOOL bAbove = ((buttonRect.bottom+r.Height()) >= rectWorkArea.bottom);
		BOOL bLeft  = ((buttonRect.right  +r.Width() ) >= rectWorkArea.right);
		
		// Compute an offset from the origin for the top left corner of the rect.
		offset.x = bLeft ?(buttonRect.left-r.Width()):buttonRect.right;
		offset.y = bAbove?(buttonRect.top-r.Height()):buttonRect.bottom;
    }
    // Apply the offset...
    r.OffsetRect(offset);
    
    // ...and create the popup.
    if(CFODropColorPaletteWnd::Create(dwStyle|WS_POPUP, 
        r, 
        pParentWnd, 
        NULL,crDefault,TRUE) == TRUE)
    {
        // Successful creation.
        ASSERT(m_hWnd);
        SetFocus();
        return TRUE;
    }
    else
    {
        // Programmer info...
        TRACE0("Failed to create popup color palette\n");
        return FALSE;
    }
    pContext; // unused
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -