// CheckBoxExt.cpp: implementation of the CGroupBoxExt class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "GroupBoxExt.h"
#include "library.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
WNDPROC	CGroupBoxExt::m_cWndProc = NULL;
int	CGroupBoxExt::pos =0;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
 LRESULT CGroupBoxExt::DefWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
	{
		CPoint	point;
		LRESULT lReturn;
   
		switch( message )
		{
         case WM_ERASEBKGND:
			return 1;
	/*	case WM_SIZE:
			CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
			OnPaint( hWnd );
			return 1;*/
 	    case WM_PAINT:

			CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
			OnPaint( hWnd );
			return 1;
		case WM_SETTEXT:	// ���ô����ı�
			lReturn = (LONG) CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
			OnPaint( hWnd );
			return lReturn;
		 default:
			break;
		}
		return CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
	}
	 
  void CGroupBoxExt::OnPaint( HWND hWnd )
  {
	RECT Rect;
	char szTemp[256];
	HANDLE hHandle,hBrush;
    DWORD dwStyle;
//ȡ���þ��
	MEMDCXP Mdcxp;
	HDC hDC ;
  // ��ȡ�ڴ�����豸����
	Mdcxp.hWnd = hWnd;
	Mdcxp.bTransfer = FALSE;
    Mdcxp.hBitmap = NULL;
    g_bDrawBk=1;
    GetMemDCXP(&Mdcxp);
    hDC = Mdcxp.hMemDC;
// ��ȡ���ڴ�С
	GetWindowRect(hWnd, &Rect);
	Rect.right -= Rect.left;
	Rect.bottom -= Rect.top;
	Rect.left = Rect.top = 0;

 
	
//	DeleteObject(hHandle);
//	::SetBkColor (hDC, g_crDialogbkColor );
// ��������Ŀ���ɫ��ϵͳ��ť��ɫһֱ
	hBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH));
    hHandle=SelectObject(hDC, g_frameedgepen);
	RoundRect(hDC, Rect.left,Rect.top+6,Rect.right,Rect.bottom,6,6);
	SelectObject(hDC, hBrush);
	SelectObject(hDC, hHandle);
// ���
	dwStyle = (DWORD)GetWindowLong(hWnd, GWL_STYLE);
	if (GetWindowText(hWnd, szTemp, sizeof(szTemp)))
	{
		SetTextColor(hDC,
			((g_wndstatelist.ElementAt (pos) & CXPS_INDETERMINATE) || (g_wndstatelist.ElementAt (pos) & CXPS_DISABLED)) ?
			0x0094A2A5: 0x00000000);

		hHandle = (HANDLE) SelectObject(hDC,
			(HGDIOBJ) SendMessage(hWnd, WM_GETFONT, 0, 0));
		Rect.left+=5;
		DrawText(hDC, szTemp, -1, &Rect, DT_LEFT);
		SelectObject(hDC, (HGDIOBJ) hHandle);
	}
        Mdcxp.bTransfer = TRUE;
        ReleaseMemDCXP(&Mdcxp);
    }