229 lines
6.0 KiB
C++
Executable File
229 lines
6.0 KiB
C++
Executable File
// GPSMainDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "GPSMain.h"
|
|
#include "GPSMainDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGPSMainDlg dialog
|
|
|
|
CGPSMainDlg::CGPSMainDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CGPSMainDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CGPSMainDlg)
|
|
//}}AFX_DATA_INIT
|
|
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
|
|
// 初始化背景画刷
|
|
CBitmap tmpBmp;
|
|
// 从资源中加载背景图片
|
|
tmpBmp.LoadBitmap(IDB_MAIN_WND);
|
|
|
|
m_BgDC.CreateCompatibleDC(NULL);
|
|
m_BgDC.SelectObject(&tmpBmp);
|
|
|
|
tmpBmp.DeleteObject();
|
|
|
|
// 加载资源文件
|
|
theApp.LoadLanguageRes(theApp.GetLanguage());
|
|
|
|
m_txtFont.CreateFont(14,0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,OUT_DEFAULT_PRECIS,
|
|
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,_T("Arial"));
|
|
|
|
// 绘制日期日期
|
|
SYSTEMTIME dt;
|
|
// 获取本地日期和时间
|
|
GetLocalTime(&dt);
|
|
|
|
// 格式化时间
|
|
m_DateTime.Format(L"%04d/%02d/%02d %02d:%02d:%02d",dt.wYear,dt.wMonth,dt.wDay,dt.wHour,dt.wMinute,dt.wSecond);
|
|
|
|
//m_DateTime = "";
|
|
m_InitDC = false;
|
|
}
|
|
|
|
CGPSMainDlg::~CGPSMainDlg()
|
|
{
|
|
m_BgDC.DeleteDC();
|
|
m_MemDC.DeleteDC();
|
|
m_BgBmp.DeleteObject();
|
|
m_txtFont.DeleteObject();
|
|
}
|
|
|
|
void CGPSMainDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CGPSMainDlg)
|
|
DDX_Control(pDX, IDC_BUTTON_VIDEO, m_butVideo);
|
|
DDX_Control(pDX, IDC_BUTTON_SET, m_butSet);
|
|
DDX_Control(pDX, IDC_BUTTON_NAVIGATION, m_butNavigation);
|
|
DDX_Control(pDX, IDC_BUTTON_MUSIC, m_butMusic);
|
|
DDX_Control(pDX, IDC_BUTTON_IMAGE, m_butImage);
|
|
DDX_Control(pDX, IDC_BUTTON_EBOOK, m_butEBoot);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CGPSMainDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CGPSMainDlg)
|
|
ON_BN_CLICKED(IDC_BUTTON_SET, OnButtonSet)
|
|
ON_BN_CLICKED(IDC_BUTTON_EBOOK, OnButtonEbook)
|
|
ON_WM_ERASEBKGND()
|
|
ON_WM_PAINT()
|
|
ON_WM_TIMER()
|
|
ON_BN_CLICKED(IDC_BUTTON_MUSIC, OnButtonMusic)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGPSMainDlg message handlers
|
|
|
|
BOOL CGPSMainDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// Set the icon for this dialog. The framework does this automatically
|
|
// when the application's main window is not a dialog
|
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
|
|
CenterWindow(GetDesktopWindow()); // center to the hpc screen
|
|
|
|
// TODO: Add extra initialization here
|
|
// 设置窗口大小
|
|
MoveWindow(0,0,320,240);
|
|
|
|
m_butNavigation.MoveWindow(31,34,70,85);
|
|
m_butNavigation.LoadBitmaps(IDB_MAIN_NAVIGATION,IDB_MAIN_NAVIGATIOND);
|
|
|
|
m_butImage.MoveWindow(125,34,70,85);
|
|
m_butImage.LoadBitmaps(IDB_MAIN_PICTURE,IDB_MAIN_PICTURED);
|
|
|
|
m_butMusic.MoveWindow(220,34,70,85);
|
|
m_butMusic.LoadBitmaps(IDB_MAIN_MUSIC,IDB_MAIN_MUSICD);
|
|
|
|
m_butSet.MoveWindow(31,135,70,85);
|
|
m_butSet.LoadBitmaps(IDB_MAIN_SET,IDB_MAIN_SETD);
|
|
|
|
m_butVideo.MoveWindow(125,135,70,85);
|
|
m_butVideo.LoadBitmaps(IDB_MAIN_VIDEO,IDB_MAIN_VIDEOD);
|
|
|
|
m_butEBoot.MoveWindow(220,135,70,85);
|
|
m_butEBoot.LoadBitmaps(IDB_MAIN_BOOK,IDB_MAIN_BOOKD);
|
|
|
|
SetButtonTitle();
|
|
|
|
SetTimer(1,1000,NULL);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void CGPSMainDlg::OnButtonSet()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
CSysSettingDlg dlgSysInfo;
|
|
if (dlgSysInfo.DoModal() == IDOK)
|
|
{
|
|
//
|
|
SetButtonTitle();
|
|
}
|
|
else
|
|
{
|
|
}
|
|
}
|
|
|
|
void CGPSMainDlg::OnButtonEbook()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
}
|
|
|
|
BOOL CGPSMainDlg::OnEraseBkgnd(CDC* pDC)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
return FALSE;
|
|
//return CDialog::OnEraseBkgnd(pDC);
|
|
}
|
|
|
|
void CGPSMainDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
// TODO: Add your message handler code here
|
|
if (!m_InitDC)
|
|
{
|
|
m_BgBmp.CreateCompatibleBitmap(&dc,320,240);
|
|
m_MemDC.CreateCompatibleDC(&dc);
|
|
m_MemDC.SelectObject(&m_BgBmp);
|
|
m_MemDC.SelectObject(&m_txtFont);
|
|
m_MemDC.SetBkMode(TRANSPARENT);
|
|
m_MemDC.SetTextColor(RGB(252,247,151));
|
|
m_InitDC = true;
|
|
}
|
|
|
|
m_MemDC.BitBlt(0,0,320,240,&m_BgDC,0,0,SRCCOPY);
|
|
m_MemDC.DrawText(m_DateTime,CRect(139,4,280,21),DT_CENTER|DT_VCENTER);
|
|
|
|
dc.BitBlt(0,0,320,240,&m_MemDC,0,0,SRCCOPY);
|
|
//dc.BitBlt(0,0,320,240,&m_BgDC,0,0,SRCCOPY);
|
|
// Do not call CDialog::OnPaint() for painting messages
|
|
}
|
|
|
|
void CGPSMainDlg::SetButtonTitle()
|
|
{
|
|
WCHAR strRes[MAX_PATH];
|
|
|
|
// 按钮标题
|
|
// 导航
|
|
CString(LoadString(theApp.GetResourceLib(),IDS_MAIN_NAVIGATION,strRes,MAX_PATH));
|
|
m_butNavigation.SetButtonTitle(strRes);
|
|
|
|
// 音乐播放器
|
|
CString(LoadString(theApp.GetResourceLib(),IDS_MAIN_MUSIC,strRes,MAX_PATH));
|
|
m_butMusic.SetButtonTitle(strRes);
|
|
|
|
// 电子书
|
|
CString(LoadString(theApp.GetResourceLib(),IDS_MAIN_EBOOK,strRes,MAX_PATH));
|
|
m_butEBoot.SetButtonTitle(strRes);
|
|
|
|
// 视频播放器
|
|
CString(LoadString(theApp.GetResourceLib(),IDS_MAIN_MOVE,strRes,MAX_PATH));
|
|
m_butVideo.SetButtonTitle(strRes);
|
|
|
|
// 图片浏览器
|
|
CString(LoadString(theApp.GetResourceLib(),IDS_MAIN_IMAGE,strRes,MAX_PATH));
|
|
m_butImage.SetButtonTitle(strRes);
|
|
|
|
// 系统设置
|
|
CString(LoadString(theApp.GetResourceLib(),IDS_MAIN_SETTING,strRes,MAX_PATH));
|
|
m_butSet.SetButtonTitle(strRes);
|
|
}
|
|
|
|
void CGPSMainDlg::OnTimer(UINT nIDEvent)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
|
|
// 绘制日期日期
|
|
SYSTEMTIME dt;
|
|
// 获取本地日期和时间
|
|
GetLocalTime(&dt);
|
|
|
|
// 格式化时间
|
|
m_DateTime.Format(L"%04d/%02d/%02d %02d:%02d:%02d",dt.wYear,dt.wMonth,dt.wDay,dt.wHour,dt.wMinute,dt.wSecond);
|
|
|
|
InvalidateRect(CRect(139,4,280,21));
|
|
CDialog::OnTimer(nIDEvent);
|
|
}
|
|
|
|
void CGPSMainDlg::OnButtonMusic()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
RunApplication(L"\\MusicPlayer.exe");
|
|
}
|
|
|