📄 startdlg.cpp
字号:
// StartMapDlg.cpp: implementation of the CStartDlg class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "StartDlg.h"
#include "UICommon.h"
#include "MediaPlayer.h"
#include "MP3PlayerDlg.h"
#include "PhotoListDlg.h"
#include "SysSettingDlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CStartDlg, CSettingDlg)
ON_BN_CLICKED(IDC_MEDIA_PLAYER, OnMediaPlayer)
ON_BN_CLICKED(IDC_NAVIGATION, OnNavigation)
ON_BN_CLICKED(IDC_MP3_PLAYER, OnMp3Player)
ON_BN_CLICKED(IDC_PHOTO_VIEWER, OnPhotoViewer)
ON_BN_CLICKED(IDC_SYSTEM_SETTINGS, OnSysSetting)
END_MESSAGE_MAP()
CStartDlg::CStartDlg(CNWnd* pParent, UINT uID)
:CSettingDlg(pParent, uID)
{
}
CStartDlg::~CStartDlg()
{
}
BOOL CStartDlg::OnInitDialog()
{
// Initialize all neccessary for the app.
SetWindowText(_T("NavGPS"));
if ( ! InitNavGPS() )
{
TRACE(_T("Fail to initialize NavGPS.\n"));
ASSERT(FALSE);
EndDialog(1);
return FALSE;
}
#ifdef PC_VERSION
// set the class info style. put it in InitNavBird() later.
ULONG ulStyle = GetClassLong(GetSafeHwnd(), GCL_STYLE);
ulStyle &= ~CS_SAVEBITS;
SetClassLong(GetSafeHwnd(), GCL_STYLE, ulStyle);
#endif
// Set the icon for this dialog.
m_hIcon = (HICON)::LoadImage(NGetInstanceHandle(), MAKEINTRESOURCE(IDI_NAVGPS), IMAGE_ICON, 0, 0, 0);
NGetMainWnd()->SendMessage(WM_SETICON, ICON_BIG, (LPARAM)m_hIcon);
NGetMainWnd()->SendMessage(WM_SETICON, ICON_SMALL, (LPARAM)m_hIcon);
CSettingDlg::OnInitDialog();
// set a timer to refresh gps timer every 1 seconds.
SetTimer(ID_TIMER_GPS_TIME, 1000, NULL);
SendMessage(WM_TIMER, (WPARAM)ID_TIMER_GPS_TIME, 0);
// subclassing dialog item
m_btnNavigation.SubclassDlgItem(IDC_NAVIGATION,this);
m_btnNavigation.SetIcon(IDI_NAVIGATION);
m_btnMediaPlayer.SubclassDlgItem(IDC_MEDIA_PLAYER,this);
m_btnMediaPlayer.SetIcon(IDI_MEDIA_PLAYER);
m_btnMp3Player.SubclassDlgItem(IDC_MP3_PLAYER,this);
m_btnMp3Player.SetIcon(IDI_MP3_PLAYER);
m_btnPhotoViewer.SubclassDlgItem(IDC_PHOTO_VIEWER,this);
m_btnPhotoViewer.SetIcon(IDI_PHOTO_VIEWER);
m_btnSystemSettings.SubclassDlgItem(IDC_SYSTEM_SETTINGS,this);
m_btnSystemSettings.SetIcon(IDI_SYSTEM_SETTINGS);
m_btnAbout.SubclassDlgItem(IDC_ABOUT,this);
m_btnAbout.SetIcon(IDI_ABOUT);
// m_btnPhotoViewer.PostMessage(BM_CLICK,0,0);
return TRUE;
}
void CStartDlg::OnTimer(UINT nIDEvent)
{
CNString str;
LPSYSTEMTIME pTime = GetGPSTime();
if( nIDEvent == ID_TIMER_GPS_TIME )
{
GetLocalTime( pTime );
if(pTime->wSecond<10)
str.Format(_T("%d:%d:0%d"), pTime->wHour, pTime->wMinute, pTime->wSecond);
else
str.Format(_T("%d:%d:%d"), pTime->wHour, pTime->wMinute, pTime->wSecond);
m_stcCaption.SetWindowText(str);
m_stcCaption.InvalidateRect(NULL);
m_stcCaption.UpdateWindow();
}
CSettingDlg::OnTimer(nIDEvent);
}
void CStartDlg::OnMediaPlayer()
{
CMediaPlayer dlg;
dlg.DoModal();
return;
}
void CStartDlg::OnMp3Player()
{
CMP3PlayerDlg dlg;
dlg.DoModal();
return;
}
void CStartDlg::OnPhotoViewer()
{
// CPhotoListDlg dlg;
// dlg.DoModal();
return;
}
void CStartDlg::OnSysSetting()
{
CSysSettingDlg dlg;
dlg.DoModal();
return;
}
void CStartDlg::OnNavigation()
{
BOOL bSuccess;
PROCESS_INFORMATION processInfo;
// STARTUPINFO startupInfo;
// GetStartupInfo(&startupInfo);
TCHAR szPath[MAX_PATH+1];
_tcscpy(szPath, NGetCurrentDir());
_tcscat(szPath, _T("\\Windows\\Test.exe"));
LPCTSTR lpApplicationName = szPath;// TEXT("Navigation.exe"); //D:\\PCUI_UNICODE\\PC\\Debug\\g
LPTSTR lpCommandLine = NULL;
LPSECURITY_ATTRIBUTES lpProcessAttributes = NULL;
LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL;
BOOL bInheritHandles = FALSE;
DWORD dwCreationFlags = 0; // creation flags
LPVOID lpEnvironment = NULL; // new environment block
TCHAR lpCurrentDirectory[MAX_PATH+1];
_tcscpy( lpCurrentDirectory, NGetCurrentDir() );//_T("D:\\MyProj\\NavGPS\\Debug\\"); // current directory name
LPSTARTUPINFO lpStartupInfo = NULL; // startup information
LPPROCESS_INFORMATION lpProcessInformation = &processInfo; // process information
bSuccess = CreateProcess(
lpApplicationName, // name of executable module
lpCommandLine, // command line string
lpProcessAttributes, // SD
lpThreadAttributes, // SD
bInheritHandles, // handle inheritance option
dwCreationFlags, // creation flags
lpEnvironment, // new environment block
NULL,//lpCurrentDirectory, // current directory name
lpStartupInfo, // startup information
lpProcessInformation // process information
);
int err = GetLastError();
if(bSuccess)
{
// BLOCK AT HERE
ShowWindow(SW_HIDE);
WaitForSingleObject(lpProcessInformation->hProcess, INFINITE);
ShowWindow(SW_SHOW);
CloseHandle(lpProcessInformation->hThread);
CloseHandle(lpProcessInformation->hProcess);
}
else
{
UpdateWindow();
TRACE(_T("Load fail.\n"));
// MessageBox(GetSafeHwnd(), _T("Load navigation fail."), _T("Error"), 0);
}
}
void CStartDlg::OnClose()
{
KillTimer(ID_TIMER_GPS_TIME);
CSettingDlg::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -