[code]// ExecStatic.cpp : implementation file
//
// DATE : September 22, 2006
// CODER : aucd29 (aucd29@gmail.com)
//
// -----------------------------------------------------------------------
// September 22, 2006
// -----------------------------------------------------------------------
// * 프로그램 인스톨을 위해서는 필요한 static 컨트롤을 생성하기 위해서
// 작성한 것
//
#include "stdafx.h"
#include "PressCD.h"
#include "ExecStatic.h"
// CExecStatic
IMPLEMENT_DYNAMIC(CExecStatic, CStatic)
CExecStatic::CExecStatic()
: m_crHoverColor(RGB(46,119,209))
, m_crDefaultColor(RGB(0,0,0))
, m_bMouseOver(false)
, m_szCommand(_T(""))
, m_pParant(NULL)
, m_bClicked(false)
{
}
CExecStatic::~CExecStatic()
{
}
BEGIN_MESSAGE_MAP(CExecStatic, CStatic)
ON_WM_LBUTTONDOWN()
ON_CONTROL_REFLECT(STN_CLICKED, &CExecStatic::OnStnClicked)
ON_WM_MOUSEMOVE()
ON_WM_SETCURSOR()
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
// CExecStatic message handlers
void CExecStatic::SetDefaultColor(COLORREF crColor)
{
m_crDefaultColor = crColor;
}
void CExecStatic::SetHoverColor(COLORREF crColor)
{
m_crHoverColor = crColor;
}
void CExecStatic::OnLButtonDown(UINT nFlags, CPoint point)
{
CStatic::OnLButtonDown(nFlags, point);
}
void CExecStatic::OnStnClicked()
{
m_bClicked = true;
if (m_pParant)
{
if (m_szCommand == _T("close"))
{
exit(1);
// m_pParant->OnCancel();
}
}
// onClick시 생성할 이벤트
if (m_szCommand)
{
// 유니코드와 아스키 간에 차이를 둔다.
#ifdef _UNICODE
int nLen = m_szCommand.GetLength();
char pDest[MAX_PATH+20] = {0,};
WideCharToMultiByte(CP_ACP, 0, m_szCommand, -1, pDest, nLen, NULL, NULL);
WinExec(pDest, SW_SHOW);
#else
WinExec(m_szCommand, SW_SHOW);
#endif
}
}
void CExecStatic::PreSubclassWindow()
{
// 기본적인 스타일 옵션을 가져온 뒤에
DWORD dwStyle = GetStyle();
SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
// 커서를 가져오기 위해서 준비
TCHAR szWindowsDir[MAX_PATH*2]={0,};
GetWindowsDirectory(szWindowsDir ,MAX_PATH*2);
wcscat_s(szWindowsDir,_T("\\Winhlp32.exe"));
HMODULE hModule = LoadLibrary(szWindowsDir);
// 커서를 가져오고
if (hModule){
m_hHyperCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));
}
SetCursor(m_hHyperCursor);
//free the module
if (hModule)
FreeLibrary(hModule);
CStatic::PreSubclassWindow();
}
BOOL CExecStatic::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR* pMsgHeader;
pMsgHeader = (NMHDR*)lParam;
switch(pMsgHeader->code)
{
case NM_RCLICK:
break;
default:;
}
return CStatic::OnNotify(wParam, lParam, pResult);
}
void CExecStatic::OnMouseMove(UINT nFlags, CPoint point)
{
/*if (m_bMouseOver)
{
CRect oRect;
GetClientRect(&oRect);
if (oRect.PtInRect(point) == false)
{
m_bMouseOver = false;
ReleaseCapture();
RedrawWindow();
//return;
}
}
else
{
m_bMouseOver = true;
RedrawWindow();
SetCapture();
}*/
CStatic::OnMouseMove(nFlags, point);
}
BOOL CExecStatic::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
::SetCursor(m_hHyperCursor);
return true;
}
HBRUSH CExecStatic::CtlColor(CDC* pDC, UINT nCtlColor)
{
if (m_bMouseOver)
{
pDC->SetTextColor(m_crHoverColor);
}
else
{
pDC->SetTextColor(m_crDefaultColor);
}
pDC->SetBkMode(TRANSPARENT);
return((HBRUSH)GetStockObject(NULL_BRUSH));
}
void CExecStatic::SetBold(bool bType)
{
LOGFONT sLogFont;
GetFont()->GetLogFont(&sLogFont);
sLogFont.lfWeight = FW_SEMIBOLD;
m_oTextFont.CreateFontIndirect(&sLogFont);
this->SetFont(&m_oTextFont, true);
}
void CExecStatic::SetCommand(CString szCommand)
{
m_szCommand = szCommand;
}
void CExecStatic::SetWnd(CWnd* pWnd)
{
m_pParant = pWnd;
}
[/code]
//
// DATE : September 22, 2006
// CODER : aucd29 (aucd29@gmail.com)
//
// -----------------------------------------------------------------------
// September 22, 2006
// -----------------------------------------------------------------------
// * 프로그램 인스톨을 위해서는 필요한 static 컨트롤을 생성하기 위해서
// 작성한 것
//
#include "stdafx.h"
#include "PressCD.h"
#include "ExecStatic.h"
// CExecStatic
IMPLEMENT_DYNAMIC(CExecStatic, CStatic)
CExecStatic::CExecStatic()
: m_crHoverColor(RGB(46,119,209))
, m_crDefaultColor(RGB(0,0,0))
, m_bMouseOver(false)
, m_szCommand(_T(""))
, m_pParant(NULL)
, m_bClicked(false)
{
}
CExecStatic::~CExecStatic()
{
}
BEGIN_MESSAGE_MAP(CExecStatic, CStatic)
ON_WM_LBUTTONDOWN()
ON_CONTROL_REFLECT(STN_CLICKED, &CExecStatic::OnStnClicked)
ON_WM_MOUSEMOVE()
ON_WM_SETCURSOR()
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
// CExecStatic message handlers
void CExecStatic::SetDefaultColor(COLORREF crColor)
{
m_crDefaultColor = crColor;
}
void CExecStatic::SetHoverColor(COLORREF crColor)
{
m_crHoverColor = crColor;
}
void CExecStatic::OnLButtonDown(UINT nFlags, CPoint point)
{
CStatic::OnLButtonDown(nFlags, point);
}
void CExecStatic::OnStnClicked()
{
m_bClicked = true;
if (m_pParant)
{
if (m_szCommand == _T("close"))
{
exit(1);
// m_pParant->OnCancel();
}
}
// onClick시 생성할 이벤트
if (m_szCommand)
{
// 유니코드와 아스키 간에 차이를 둔다.
#ifdef _UNICODE
int nLen = m_szCommand.GetLength();
char pDest[MAX_PATH+20] = {0,};
WideCharToMultiByte(CP_ACP, 0, m_szCommand, -1, pDest, nLen, NULL, NULL);
WinExec(pDest, SW_SHOW);
#else
WinExec(m_szCommand, SW_SHOW);
#endif
}
}
void CExecStatic::PreSubclassWindow()
{
// 기본적인 스타일 옵션을 가져온 뒤에
DWORD dwStyle = GetStyle();
SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
// 커서를 가져오기 위해서 준비
TCHAR szWindowsDir[MAX_PATH*2]={0,};
GetWindowsDirectory(szWindowsDir ,MAX_PATH*2);
wcscat_s(szWindowsDir,_T("\\Winhlp32.exe"));
HMODULE hModule = LoadLibrary(szWindowsDir);
// 커서를 가져오고
if (hModule){
m_hHyperCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));
}
SetCursor(m_hHyperCursor);
//free the module
if (hModule)
FreeLibrary(hModule);
CStatic::PreSubclassWindow();
}
BOOL CExecStatic::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR* pMsgHeader;
pMsgHeader = (NMHDR*)lParam;
switch(pMsgHeader->code)
{
case NM_RCLICK:
break;
default:;
}
return CStatic::OnNotify(wParam, lParam, pResult);
}
void CExecStatic::OnMouseMove(UINT nFlags, CPoint point)
{
/*if (m_bMouseOver)
{
CRect oRect;
GetClientRect(&oRect);
if (oRect.PtInRect(point) == false)
{
m_bMouseOver = false;
ReleaseCapture();
RedrawWindow();
//return;
}
}
else
{
m_bMouseOver = true;
RedrawWindow();
SetCapture();
}*/
CStatic::OnMouseMove(nFlags, point);
}
BOOL CExecStatic::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
::SetCursor(m_hHyperCursor);
return true;
}
HBRUSH CExecStatic::CtlColor(CDC* pDC, UINT nCtlColor)
{
if (m_bMouseOver)
{
pDC->SetTextColor(m_crHoverColor);
}
else
{
pDC->SetTextColor(m_crDefaultColor);
}
pDC->SetBkMode(TRANSPARENT);
return((HBRUSH)GetStockObject(NULL_BRUSH));
}
void CExecStatic::SetBold(bool bType)
{
LOGFONT sLogFont;
GetFont()->GetLogFont(&sLogFont);
sLogFont.lfWeight = FW_SEMIBOLD;
m_oTextFont.CreateFontIndirect(&sLogFont);
this->SetFont(&m_oTextFont, true);
}
void CExecStatic::SetCommand(CString szCommand)
{
m_szCommand = szCommand;
}
void CExecStatic::SetWnd(CWnd* pWnd)
{
m_pParant = pWnd;
}
[/code]
'Windows > MFC' 카테고리의 다른 글
CMenu 메뉴에서 닫기 아이디로 줘야되는 것 ID_APP_EXIT (0) | 2013.10.02 |
---|---|
LoadString (0) | 2013.10.02 |
그림 크기로 다이얼로그 크기를 변경 (MoveWindow) (0) | 2013.10.02 |
RichEdit 컨트롤을 사용 하기 위한 초기화 AfxInitRichEdit(); (0) | 2013.10.02 |
Taskbar 클릭해서 최소화 안되는 경우. WS_OVERLAPPED (0) | 2013.10.02 |