a
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
// optgddlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "optgddlg.h"
|
||||
|
||||
#include "floatedit.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COpTGDDlg dialog
|
||||
extern HHOOK hHook;
|
||||
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
COpTGDDlg::COpTGDDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(COpTGDDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(COpTGDDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void COpTGDDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(COpTGDDlg)
|
||||
DDX_Control(pDX, IDC_TGD_LIST, m_tgdList);
|
||||
DDX_Control(pDX, IDC_ED_ELEVATION, m_edElevation);
|
||||
DDX_Control(pDX, IDC_ED_DISTANCE, m_edDistance);
|
||||
DDX_Control(pDX, IDC_CB_TGDSN, m_cbTGDSN);
|
||||
DDX_Control(pDX, IDC_CB_DISTANCE_TYPE, m_cbDisType);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(COpTGDDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(COpTGDDlg)
|
||||
ON_BN_CLICKED(IDC_BTN_INS, OnBtnIns)
|
||||
ON_NOTIFY(LVN_ITEMCHANGED, IDC_TGD_LIST, OnItemchangedTgdList)
|
||||
ON_BN_CLICKED(IDC_BTN_UPD, OnBtnUpd)
|
||||
ON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COpTGDDlg message handlers
|
||||
|
||||
BOOL COpTGDDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
int iColIndex = (int)VAL_ZERO;
|
||||
CString strColTitle = _T("");
|
||||
|
||||
m_edDistance.SetIntLimitLen(3);
|
||||
m_edDistance.SetDecLimitLen(0);
|
||||
m_edDistance.SetIsMinus();
|
||||
m_edDistance.SetWindowText(_T("0"));
|
||||
|
||||
m_edElevation.SetIntLimitLen(3);
|
||||
m_edElevation.SetDecLimitLen(3);
|
||||
m_edElevation.SetWindowText(_T("0"));
|
||||
|
||||
m_tgdList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
||||
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
|
||||
|
||||
iColIndex = (int)VAL_ZERO;
|
||||
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_SN);
|
||||
m_tgdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DISTANCE);
|
||||
m_tgdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_ELEVATION);
|
||||
m_tgdList.InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void COpTGDDlg::OnBtnIns()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
CString szValue = _T("");
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
|
||||
iIndex = this->m_tgdList.GetItemCount();
|
||||
|
||||
szValue.Empty();
|
||||
szValue.Format(_T("%d"), iIndex + 1);
|
||||
this->m_tgdList.InsertItem(iIndex, szValue);
|
||||
|
||||
this->m_cbTGDSN.AddString(szValue);
|
||||
if (this->m_cbTGDSN.GetCurSel() == (int)VAL_MINUS_ONE)
|
||||
{
|
||||
this->m_cbTGDSN.SetCurSel(0);
|
||||
}
|
||||
|
||||
szValue.Empty();
|
||||
m_edDistance.GetWindowText(szValue);
|
||||
this->m_tgdList.SetItemText(iIndex, 1, szValue);
|
||||
|
||||
szValue.Empty();
|
||||
m_edElevation.GetWindowText(szValue);
|
||||
this->m_tgdList.SetItemText(iIndex, 2, szValue);
|
||||
|
||||
this->m_tgdList.SetItemData(iIndex, (DWORD)iIndex + 1);
|
||||
}
|
||||
|
||||
void COpTGDDlg::OnItemchangedTgdList(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
||||
// TODO: Add your control notification handler code here
|
||||
if (((pNMListView->uOldState & LVIS_SELECTED) == VAL_ZERO) && ((pNMListView->uNewState & LVIS_SELECTED) == LVIS_SELECTED))
|
||||
{
|
||||
this->m_edDistance.SetWindowText(_T(""));
|
||||
this->m_edDistance.SetWindowText(this->m_tgdList.GetItemText(pNMListView->iItem, 1));
|
||||
|
||||
this->m_edElevation.SetWindowText(_T(""));
|
||||
this->m_edElevation.SetWindowText(this->m_tgdList.GetItemText(pNMListView->iItem, 2));
|
||||
}
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
|
||||
void COpTGDDlg::OnBtnUpd()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
CString szValue = _T("");
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
POSITION pos = NULL;
|
||||
|
||||
pos = NULL;
|
||||
pos = this->m_tgdList.GetFirstSelectedItemPosition();
|
||||
|
||||
if (NULL != pos)
|
||||
{
|
||||
iIndex = this->m_tgdList.GetNextSelectedItem(pos);
|
||||
|
||||
szValue.Empty();
|
||||
m_edDistance.GetWindowText(szValue);
|
||||
this->m_tgdList.SetItemText(iIndex, 1, szValue);
|
||||
|
||||
szValue.Empty();
|
||||
m_edElevation.GetWindowText(szValue);
|
||||
this->m_tgdList.SetItemText(iIndex, 2, szValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(_T("Please select terrain data record!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void COpTGDDlg::OnBtnDel()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
CString szValue = _T("");
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
POSITION pos = NULL;
|
||||
|
||||
pos = NULL;
|
||||
pos = this->m_tgdList.GetFirstSelectedItemPosition();
|
||||
|
||||
if (NULL != pos)
|
||||
{
|
||||
iIndex = this->m_tgdList.GetNextSelectedItem(pos);
|
||||
this->m_tgdList.DeleteItem(iIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(_T("Please select terrain data record!"));
|
||||
return;
|
||||
}
|
||||
|
||||
this->m_cbTGDSN.ResetContent();
|
||||
iIndex = (int)VAL_ZERO;
|
||||
while (iIndex < this->m_tgdList.GetItemCount())
|
||||
{
|
||||
szValue.Empty();
|
||||
szValue.Format(_T("%d"), iIndex + 1);
|
||||
this->m_tgdList.SetItemText(iIndex, 0, szValue);
|
||||
this->m_tgdList.SetItemData(iIndex, (DWORD)iIndex + 1);
|
||||
|
||||
this->m_cbTGDSN.AddString(szValue);
|
||||
this->m_cbTGDSN.SetItemData(iIndex, (DWORD)iIndex + 1);
|
||||
|
||||
iIndex ++;
|
||||
}
|
||||
|
||||
this->m_cbTGDSN.SetCurSel(-1);
|
||||
}
|
||||
|
||||
void COpTGDDlg::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
CString szValue = _T("");
|
||||
CString szCaption = _T("");
|
||||
|
||||
if (this->m_cbDisType.GetCurSel() == -1)
|
||||
{
|
||||
szCaption.Empty();
|
||||
szCaption.LoadString(IDS_CAPTION_0010);
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szCaption);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->m_tgdList.GetItemCount() == 0)
|
||||
{
|
||||
szCaption.Empty();
|
||||
szCaption.LoadString(IDS_CAPTION_0012);
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szCaption);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->m_cbTGDSN.GetCurSel() == -1)
|
||||
{
|
||||
szCaption.Empty();
|
||||
szCaption.LoadString(IDS_CAPTION_0011);
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szCaption);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
BOOL COpTGDDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
// TODO: Add your specialized code here and/or call the base class
|
||||
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
Reference in New Issue
Block a user