📄 settingdlg.cpp
字号:
// SettingDlg.cpp: implementation of the CSettingDlg class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SettingDlg.h"
#include "resource.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CSettingDlg, CNDialog)
ON_STN_CLICKED(IDC_RETURN,OnReturn)
END_MESSAGE_MAP()
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
HFONT CSettingDlg::sm_hCaptionFont = NULL;
CSettingDlg::CSettingDlg(CNWnd* pParent, UINT uID)
:CNDialog(pParent, uID)
{
}
CSettingDlg::~CSettingDlg()
{
}
BOOL CSettingDlg::OnInitDialog()
{
CNDialog::OnInitDialog();
// subclassing dialog item
m_btnReturn.SubclassDlgItem(IDC_RETURN,this);
m_btnReturn.SetBkStyle(BK_STD_OPER);
m_btnReturn.SetTransBlt(TRUE);
// m_btnReturn.SetWindowPos(NULL, 374, 232, SHORT_OPER_BTN_WIDTH, SHORT_OPER_BTN_HEIGHT, SWP_NOACTIVATE | SWP_NOSIZE);
// create caption static control.
RECT rect = { 10, 0, 300, 28 };
m_stcCaption.Create(_T("Caption"), WS_CHILD | WS_VISIBLE /*| SS_OWNERDRAW*/, rect, this);
m_stcCaption.SetFont(sm_hCaptionFont,FALSE);
m_stcCaption.SetTextColor(RGB(255,255,255));
return TRUE;
}
void CSettingDlg::SetCaption(LPCTSTR lpCaption )
{
ASSERT( ::IsWindow(m_stcCaption.m_hWnd) );
::SetWindowText(m_stcCaption.GetSafeHwnd(), lpCaption);
}
BOOL CSettingDlg::OnEraseBkgnd(HDC hdc)
{
// HRESULT ddrval;
// copy setting dlg backgnd to overlay
/* while(1)
{
ddrval = g_pDDSOverlay->BltFast(0, 0, g_pDDSSetBkgnd, NULL, DDBLTFAST_WAIT);
if( ddrval == DD_OK )
break;
else if( ddrval == DDERR_SURFACELOST )
{
RestoreAllSurfaces();
}
}
*/
static HDC s_hdcBk;
static HBITMAP s_hbmpBk;
static s_bInit = FALSE;
if( !s_bInit )
{
s_hbmpBk = (HBITMAP)LoadImage(NGetInstanceHandle(), MAKEINTRESOURCE(IDB_SETTINGDLG_BK),
IMAGE_BITMAP, 0, 0, 0);
s_hdcBk = CreateCompatibleDC(NULL);
SelectObject(s_hdcBk, s_hbmpBk);
s_bInit = TRUE;
}
// g_pDDSSetBkgnd->GetDC(&hdcBk);
// BitBlt(hdc, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hdcBk, 0, 0, SRCCOPY);
// g_pDDSSetBkgnd->ReleaseDC(hdcBk);
BitBlt(hdc,0,0,SCREEN_WIDTH, SCREEN_HEIGHT,s_hdcBk, 0,0, SRCCOPY);
return TRUE;
// return CNDialog::OnEraseBkgnd(hdc);
}
HBRUSH CSettingDlg::OnCtlColor(HDC hdc,HWND hwnd, UINT nCtlColor)
{
static HBRUSH s_hbrBkgnd;
static BOOL bInit = FALSE;
HBRUSH hbr;
if(!bInit)
{
s_hbrBkgnd = CreateSolidBrush(RGB(41,73,123));
ASSERT( s_hbrBkgnd != NULL );
bInit = TRUE;
}
// use KEY_COLOR for buttons and static controls in default.
if(nCtlColor == WM_CTLCOLORBTN)
hbr = s_hbrBkgnd;
else if( nCtlColor == WM_CTLCOLORSTATIC)
{
// in default, set output text transparent and in white color.
::SetBkMode(hdc, TRANSPARENT);
::SetTextColor(hdc, RGB(255,255,255));
hbr = s_hbrBkgnd;//(HBRUSH)GetStockObject(WHITE_BRUSH);//s_hbrBtnBkgnd;
}
else
hbr = CNWnd::OnCtlColor(hdc, hwnd, nCtlColor);
return hbr;
}
void CSettingDlg::OnPaint(void)
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(GetSafeHwnd(), &ps);
EndPaint(m_hWnd, &ps);
}
void CSettingDlg::OnReturn()
{
EndDialog(IDC_RETURN);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -