Click here to Skip to main content
15,921,840 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: HHEELLPP!!! Pin
noksi1-Jul-03 4:59
noksi1-Jul-03 4:59 
GeneralRe: HHEELLPP!!! Pin
Terry O'Nolley10-Jul-03 11:36
Terry O'Nolley10-Jul-03 11:36 
Generalresizing an array to the size of another array Pin
johnstonsk1-Jul-03 3:50
johnstonsk1-Jul-03 3:50 
GeneralRe: resizing an array to the size of another array Pin
John M. Drescher1-Jul-03 4:21
John M. Drescher1-Jul-03 4:21 
GeneralRe: resizing an array to the size of another array Pin
David Crow1-Jul-03 6:27
David Crow1-Jul-03 6:27 
GeneralSetWindowRgn With CButton Pin
nlecren1-Jul-03 3:47
nlecren1-Jul-03 3:47 
GeneralRe: SetWindowRgn With CButton Pin
basementman1-Jul-03 4:53
basementman1-Jul-03 4:53 
GeneralRe: SetWindowRgn With CButton Pin
nlecren1-Jul-03 10:57
nlecren1-Jul-03 10:57 
Here is the code

BOOL CSkinButton::CreateSkinButton(int nID, CWnd *pWnd)
{
if( pWnd == NULL )
return FALSE;

m_nID = nID;
m_pSkinDrawing = new CSkinDrawing;

if( m_bSkinned )
{
m_hBack = (HBITMAP)LoadImage(NULL,m_strBackImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );
m_hMask = (HBITMAP)LoadImage(NULL,m_strMaskImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );
m_hHover = (HBITMAP)LoadImage(NULL,m_strHoverImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );
m_hDown = (HBITMAP)LoadImage(NULL,m_strDownImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );

if( (m_hBack == NULL) || (m_hMask == NULL) || (m_hHover == NULL) || (m_hDown == NULL) )
return FALSE;

// Get the main window region using background bitmap

m_hRgn = m_pSkinDrawing->BitmapToRegion(m_hMask,m_clrMaskColor);
}

if( !Create(m_strCaption,BS_OWNERDRAW,CRect(0,0,0,0),pWnd,m_nID) )
return FALSE;

SetWindowPos(NULL,m_ptTopLeft.x,m_ptTopLeft.y,m_nWidth,m_nHeight,SWP_SHOWWINDOW);

return TRUE;
}

void CSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item

UINT uStyle = lpDrawItemStruct->itemState;
CDC *pDC = NULL;
CRect rcMain;

pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

if( !m_bSkinned )
{
rcMain.CopyRect(&lpDrawItemStruct->rcItem);

m_pSkinDrawing->DrawFilledRect(pDC,rcMain,m_clrBackColor);
m_pSkinDrawing->DrawFrame(pDC,rcMain,1);

// Draw the button and label using caption

m_pSkinDrawing->DrawButtonText(pDC,m_strCaption,rcMain,m_clrForeColor);

// Now, depending upon the state, redraw the button (down image) if it is selected,
// place a focus rectangle on it, or redisplay the caption if it is disabled

if( uStyle & ODS_FOCUS )
{
if( uStyle & ODS_SELECTED )
{
m_pSkinDrawing->DrawFilledRect(pDC,rcMain,m_clrBackColor);
m_pSkinDrawing->DrawFrame(pDC,rcMain,-2);
m_pSkinDrawing->DrawButtonText(pDC,m_strCaption,rcMain,m_clrForeColor);
}
}
else if(uStyle & ODS_DISABLED)
{
m_pSkinDrawing->DrawButtonText(pDC,m_strCaption,rcMain,m_clrForeColor);
}
}
else
{
CDC *pMemDC = NULL;
HRGN hRgn;
HBRUSH hBrush;
CBitmap *pBitmap = NULL;

hRgn = CreateRectRgn(0,0,0,0);

GetClientRect(&rcMain);
GetWindowRgn(hRgn);

pMemDC = new CDC;
pMemDC->CreateCompatibleDC(pDC);

if( uStyle & ODS_SELECTED )
pBitmap = (CBitmap *)pMemDC->SelectObject(m_hDown);
else
pBitmap = (CBitmap *)pMemDC->SelectObject(m_hBack);

hBrush = CreateSolidBrush(m_clrMaskColor);

FillSolidRect(pMemDC->GetSafeHdc(),rcMain,RGB(0,0,0));
FillRgn(pMemDC->GetSafeHdc(),hRgn,hBrush);

::SelectClipRgn(pMemDC->GetSafeHdc(),hRgn);
pDC->BitBlt(0,0,rcMain.Width(),rcMain.Height(),pMemDC,0,0,SRCCOPY);
::SelectClipRgn(pMemDC->GetSafeHdc(),NULL);

dcMain.SelectObject(pBitmap);
DeleteObject(hRgn);
DeleteObject(hBrush);
}
}

void CSkinButton::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class

ModifyStyle(0,BS_OWNERDRAW|BS_PUSHBUTTON);
CButton::PreSubclassWindow();
}

int CSkinButton::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CButton::OnCreate(lpCreateStruct) == -1)
return -1;

// TODO: Add your specialized creation code here

if( m_bSkinned )
SetWindowRgn(m_hRgn,TRUE);

return 0;
}

GeneralRe: SetWindowRgn With CButton Pin
basementman1-Jul-03 11:57
basementman1-Jul-03 11:57 
QuestionGetBuffer?? ReleaseBuffer?? Pin
skinnyreptile1-Jul-03 3:30
skinnyreptile1-Jul-03 3:30 
AnswerRe: GetBuffer?? ReleaseBuffer?? Pin
David Crow1-Jul-03 3:48
David Crow1-Jul-03 3:48 
GeneralRe: GetBuffer?? ReleaseBuffer?? Pin
skinnyreptile1-Jul-03 4:28
skinnyreptile1-Jul-03 4:28 
GeneralRe: GetBuffer?? ReleaseBuffer?? Pin
David Crow1-Jul-03 6:03
David Crow1-Jul-03 6:03 
AnswerRe: GetBuffer?? ReleaseBuffer?? Pin
Ryan Binns1-Jul-03 5:13
Ryan Binns1-Jul-03 5:13 
GeneralRe: GetBuffer?? ReleaseBuffer?? Pin
skinnyreptile1-Jul-03 5:34
skinnyreptile1-Jul-03 5:34 
AnswerRe: GetBuffer?? ReleaseBuffer?? Pin
Joan M1-Jul-03 5:44
professionalJoan M1-Jul-03 5:44 
GeneralRe: GetBuffer?? ReleaseBuffer?? Pin
skinnyreptile1-Jul-03 5:51
skinnyreptile1-Jul-03 5:51 
AnswerRe: GetBuffer?? ReleaseBuffer?? Pin
Kelly Herald1-Jul-03 6:43
Kelly Herald1-Jul-03 6:43 
GeneralRe: GetBuffer?? ReleaseBuffer?? Pin
skinnyreptile1-Jul-03 6:45
skinnyreptile1-Jul-03 6:45 
General?? displaying data Pin
shirleyLo1-Jul-03 3:09
shirleyLo1-Jul-03 3:09 
GeneralRe: ?? displaying data Pin
Joan M1-Jul-03 5:49
professionalJoan M1-Jul-03 5:49 
GeneralRe: Window styles Pin
Ravi Bhavnani1-Jul-03 3:15
professionalRavi Bhavnani1-Jul-03 3:15 
GeneralAllocating memory for a multidimensionnal array Pin
Jerome Conus1-Jul-03 1:54
Jerome Conus1-Jul-03 1:54 
GeneralRe: Allocating memory for a multidimensionnal array Pin
Ryan Binns1-Jul-03 2:10
Ryan Binns1-Jul-03 2:10 
GeneralRe: Allocating memory for a multidimensionnal array Pin
Jerome Conus1-Jul-03 2:12
Jerome Conus1-Jul-03 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.