TEMPLATE void CDialogMinTrayBtn<BASE>::MinTrayBtnDraw()
{
if (!MinTrayBtnIsVisible())
return;
CDC *pDC= GetWindowDC();
if (!pDC)
return; // panic!
if (IsWindowsClassicStyle())
{
CBrush black(GetSysColor(COLOR_BTNTEXT));
CBrush gray(GetSysColor(COLOR_GRAYTEXT));
CBrush gray2(GetSysColor(COLOR_BTNHILIGHT));
// button
if (m_bMinTrayBtnUp)
pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH);
else
pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED);
// dot
CRect btn = MinTrayBtnGetRect();
btn.DeflateRect(2,2);
UINT caption = MinTrayBtnGetSize().cy + (CAPTION_BUTTONSPACE * 2);
UINT pixratio = (caption >= 14) ? ((caption >= 20) ? 2 + ((caption - 20) / 8) : 2) : 1;
UINT pixratio2 = (caption >= 12) ? 1 + (caption - 12) / 8: 0;
UINT dotwidth = (1 + pixratio * 3) >> 1;
UINT dotheight = pixratio;
CRect dot(CPoint(0,0), CPoint(dotwidth, dotheight));
CSize spc((1 + pixratio2 * 3) >> 1, pixratio2);
dot -= dot.Size();
dot += btn.BottomRight();
dot -= spc;
if (!m_bMinTrayBtnUp)
dot += CPoint(1,1);
if (m_bMinTrayBtnEnabled)
{
pDC->FillRect(dot, &black);
}
else
{
pDC->FillRect(dot + CPoint(1,1), &gray2);
pDC->FillRect(dot, &gray);
}
}
else
{
// VisualStylesXP
CRect btn = MinTrayBtnGetRect();
int iState;
if (!m_bMinTrayBtnEnabled)
iState = TRAYBS_DISABLED;
else if (GetStyle() & WS_DISABLED)
iState = MINBS_NORMAL;
else if (m_bMinTrayBtnHitTest)
iState = (m_bMinTrayBtnCapture) ? MINBS_PUSHED : MINBS_HOT;
else
iState = MINBS_NORMAL;
// inactive
if (!m_bMinTrayBtnActive)
iState += 4; // inactive state TRAYBS_Ixxx
if (m_bmMinTrayBtnBitmap.m_hObject && _TransparentBlt)
{
// known theme (bitmap)
CBitmap *pBmpOld;
CDC dcMem;
if (dcMem.CreateCompatibleDC(pDC) && (pBmpOld = dcMem.SelectObject(&m_bmMinTrayBtnBitmap)) != NULL)
{
_TransparentBlt(pDC->m_hDC, btn.left, btn.top, btn.Width(), btn.Height(), dcMem.m_hDC, 0, BMP_TRAYBTN_HEIGHT * (iState - 1), BMP_TRAYBTN_WIDTH, BMP_TRAYBTN_HEIGHT, BMP_TRAYBTN_TRANSCOLOR);
dcMem.SelectObject(pBmpOld);
}
}
else
{
// unknown theme (ThemeData)
HTHEME hTheme = g_xpStyle.OpenThemeData(m_hWnd, L"Window");
if (hTheme)
{
btn.top += btn.Height() / 8;
g_xpStyle.DrawThemeBackground(hTheme, pDC->m_hDC, WP_TRAYBUTTON, iState, &btn, NULL);
g_xpStyle.CloseThemeData(hTheme);
}
}
}
ReleaseDC(pDC);
}
METHOD Paint() CLASS QButton
DrawQBBackground(::hWnd, ::hDc)
RETURN NIL
#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>
#ifdef __FLAT__
#include <ShellApi.h>
#endif
#ifdef __HARBOUR__
#include <hbapiitm.h>
#include <hbdate.h>
#include <hbset.h>
#endif
#include "uxtheme.h"
HB_FUNC( DRAWQBBACKGROUND )
{
HTHEME hTheme;
HDC hDc;
HWND hWnd;
RECT rcWnd;
int iStateId = 1;
hWnd = ( HWND ) _parnl( 1 );
hDc = ( HDC ) _parl(2);
GetClientRect( hWnd, &rcWnd );
hTheme = OpenThemeData(hWnd, L"BUTTON");
if ( hTheme)
{
DrawThemeBackground(hTheme,
hDc,
0,
0,
&rcWnd,
NULL);
_retni(1);
}
else
{
_retni(0);
}
}
AlexSchaft wrote:
- Code: Select all Expand view
hDc = ( HDC ) _parl(2);
hDc = ( HDC ) _parnl(2);
METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS QButton
// Super:MouseMove( nRow, nCol, nKeyFlags )
if IsOverWnd( ::hWnd, nRow, nCol )
::nState := 2
else
::nState := 1
endif
::Refresh()
return nil
//---------------------------------------------------------------------------------------------//
METHOD Paint() CLASS QButton
// 1 Regular
// 2 Mouse over
// 3 Down
// 4 Disabled
DrawQBBackground(::hWnd, ::hDc, ::nState)
RETURN NIL
METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS QButton
if ::lDrag .or. ! Empty( ::oDragCursor )
return Super:MouseMove( nRow, nCol, nKeyFlags )
endif
Super:MouseMove( nRow, nCol, nKeyFlags )
if IsOverWnd( ::hWnd, nRow, nCol )
if !::lCaptured
::Capture()
if ::nState != 2
::nState := 2
::Refresh()
endif
else
::Refresh()
endif
else
if !::lCaptured
ReleaseCapture()
if ::nState != 1
::nState := 1
::Refresh()
endif
else
::Refresh()
endif
endif
::oWnd:SetMsg( ::cMsg )
return 0
//---------------------------------------------------------------------------------------------//
METHOD Paint() CLASS QButton
// 1 Regular
// 2 Mouse over
// 3 Down
// 4 Disabled
DrawQBBackground(::hWnd, ::hDc, ::nState)
RETURN NIL
#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>
#ifdef __FLAT__
#include <ShellApi.h>
#endif
#ifdef __HARBOUR__
#include <hbapiitm.h>
#include <hbdate.h>
#include <hbset.h>
#endif
#include "uxtheme.h"
HB_FUNC( DRAWQBBACKGROUND )
{
HTHEME hTheme;
HDC hDc;
HWND hWnd;
RECT rcWnd;
int iStateId = 1;
hWnd = ( HWND ) _parnl( 1 );
hDc = ( HDC ) _parnl(2);
GetClientRect( hWnd, &rcWnd );
hTheme = OpenThemeData(hWnd, L"COMBOBOX");
if ( hTheme)
{
DrawThemeBackground(hTheme,
hDc,
1,
( ISNUM(3) ? _parni( 3 ) : 1 ),
&rcWnd,
NULL);
CloseThemeData(hTheme);
_retni(1);
}
else
{
_retni(0);
}
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 73 guests