📄 bxtdlg.cpp
字号:
// bxtDlg.cpp : implementation file
//
#include "stdafx.h"
#include "bxt.h"
#include "bxtDlg.h"
#include "SelPic.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBxtDlg dialog
CBxtDlg::CBxtDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBxtDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBxtDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
CHAR textline[510];
m_pCfg = ((CBxtApp *)(AfxGetApp()))->GetConfig();
FILE *fp = fopen("c:\\bxt\\imagepath.inf", "r");
if (NULL != fp)
{
fgets(textline, 200, fp);
fclose(fp);
m_imagepath = textline;
m_imagepath.TrimLeft();
m_imagepath.TrimRight();
}
else
{
m_imagepath = "C:\\BXT\\";
}
m_fixedimagepath = m_imagepath;
m_cdimagepath = "E:\\data\\";
}
void
CBxtDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBxtDlg)
DDX_Control(pDX, IDOKX, m_ok);
DDX_Control(pDX, IDC_TAB2, m_s);
DDX_Control(pDX, IDC_TAB1, m_m);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBxtDlg, CDialog)
//{{AFX_MSG_MAP(CBxtDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
ON_BN_CLICKED(IDOKX, OnOkx)
ON_WM_NCLBUTTONDOWN()
ON_WM_NCLBUTTONDBLCLK()
//}}AFX_MSG_MAP
ON_MESSAGE(WX_TABSELCHANG, TabSelChange)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBxtDlg message handlers
BOOL
CBxtDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
//For Main
// ->
geninfo = new GenInfo;
reccing = new Reccing;
recinfo = new RecInfo;
geninfo->Create(GenInfo::IDD, &m_s);
reccing->Create(Reccing::IDD, &m_s);
recinfo->Create(RecInfo::IDD, &m_s);
m_s.AddTab(geninfo, "一般信息", 0);
m_s.AddTab(reccing, "采集", 1);
m_s.AddTab(recinfo, "采集调整", 2);
m_s.SetSelectedColor(RGB(0, 0, 255));
m_s.SetMouseOverColor(RGB(255, 10, 255));
m_s.SetID(IDC_TAB2);
// <-
CRect rr;
int cyc = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME);
int cxc = GetSystemMetrics(SM_CXDLGFRAME);
m_s.GetWindowRect(&rr);
rr.top -= cyc;
rr.bottom -= cyc;
rr.left -= cxc;
rr.right -= cxc;
//->
m_sImagePcs.Create(m_s.GetStyle() | TCS_MULTILINE, rr, this, 2000);
m_sImagePcs.SetFont(m_s.GetFont());
CPoint pp(4, 28 + 18);
m_sImagePcs.SetTopLeftCorner(pp);
m_sImagePcs.ShowWindow(SW_HIDE);
dispimginfo = new DispImgInfo;
dispmarking = new DispMarking;
dispmeasure = new DispMeasure;
dispprocess = new DispProcess;
dispzoom = new DispZoom;
dispconbri = new DispConBri;
dispimginfo->Create(DispImgInfo::IDD, &m_sImagePcs);
dispmarking->Create(DispMarking::IDD, &m_sImagePcs);
dispmeasure->Create(DispMeasure::IDD, &m_sImagePcs);
dispprocess->Create(DispProcess::IDD, &m_sImagePcs);
dispzoom->Create(DispZoom::IDD, &m_sImagePcs);
dispconbri->Create(DispConBri::IDD, &m_sImagePcs);
m_sImagePcs.AddTab(dispimginfo, "显示方式", 0);
m_sImagePcs.AddTab(dispprocess, "处理", 1);
m_sImagePcs.AddTab(dispconbri, "调整", 2);
m_sImagePcs.AddTab(dispmarking, "标注", 3);
m_sImagePcs.AddTab(dispmeasure, "测量", 4);
m_sImagePcs.AddTab(dispzoom, "放大", 5);
m_sImagePcs.SetSelectedColor(RGB(0, 0, 255));
m_sImagePcs.SetMouseOverColor(RGB(255, 255, 0));
m_sImagePcs.SetID(3000);
// <-
// ->
m_sQuery.Create(m_s.GetStyle() | TCS_MULTILINE, rr, this, 2001);
m_sQuery.SetFont(m_s.GetFont());
m_sQuery.ShowWindow(SW_HIDE);
queryname = new QueryName;
querytime = new QueryTime;
queryfree = new QueryFree;
queryorder = new QueryOrder;
queryname->Create(QueryName::IDD, &m_sQuery);
querytime->Create(QueryTime::IDD, &m_sQuery);
queryfree->Create(QueryFree::IDD, &m_sQuery);
queryorder->Create(QueryOrder::IDD, &m_sQuery);
m_sQuery.AddTab(queryname, "精确", 0);
if (m_pCfg->iUiType != UI_TYPE_SIMPLE)
{
m_sQuery.AddTab(queryfree, "模糊", 1);
m_sQuery.AddTab(querytime, "时间", 2);
m_sQuery.AddTab(queryorder, "排序", 3);
}
m_sQuery.SetSelectedColor(RGB(0, 0, 255));
m_sQuery.SetMouseOverColor(RGB(255, 255, 0));
m_sQuery.SetID(3001);
// <-
// ->
m_sReport.Create(m_s.GetStyle() | TCS_MULTILINE, rr, this, 2001);
m_sReport.SetFont(m_s.GetFont());
m_sReport.ShowWindow(SW_HIDE);
printimage = new PrintImage;
rpttemplate = new RptTemplate;
printimage->Create(PrintImage::IDD, &m_sReport);
rpttemplate->Create(RptTemplate::IDD, &m_sReport);
m_sReport.AddTab(printimage, "打印", 0);
m_sReport.AddTab(rpttemplate, "模板", 1);
m_sReport.SetSelectedColor(RGB(0, 0, 255));
m_sReport.SetMouseOverColor(RGB(255, 255, 0));
m_sReport.SetID(3002);
// <-
// ->
m_sHelp.Create(m_s.GetStyle() | TCS_MULTILINE, rr, this, 2001);
m_sHelp.SetFont(m_s.GetFont());
m_sHelp.ShowWindow(SW_HIDE);
helphelp = new HelpHelp;
helppic = new HelpPIc;
helpref = new HelpRef;
helphelp->Create(HelpHelp::IDD, &m_sHelp);
helppic->Create(HelpPIc::IDD, &m_sHelp);
helpref->Create(HelpRef::IDD, &m_sHelp);
m_sHelp.AddTab(helppic, "图谱", 0);
m_sHelp.AddTab(helpref, "资料", 1);
m_sHelp.AddTab(helphelp, "帮助", 3);
m_sHelp.SetSelectedColor(RGB(0, 0, 255));
m_sHelp.SetMouseOverColor(RGB(255, 255, 0));
m_sHelp.SetID(3002);
// <-
// ->
imgpcs = new ImageProcess("e:\\");
query = new Query;
imgpcs->Create(ImageProcess::IDD, &m_m);
query->Create(Query::IDD, &m_m);
rec = new RecImage;
report = new Report;
xhelp = new xHelp;
rec->Create(RecImage::IDD, &m_m);
report->Create(Report::IDD, &m_m);
xhelp->Create(xHelp::IDD, &m_m);
if (m_pCfg->iUiType == UI_TYPE_SIMPLE)
{
m_m.AddTab(imgpcs, "处理", 0);
m_m.AddTab(query, "检索", 1);
}
else
{
m_m.AddTab(rec, "采集", 0);
m_m.AddTab(imgpcs, "处理", 1);
m_m.AddTab(report, "报告", 2);
m_m.AddTab(query, "检索", 3);
m_m.AddTab(xhelp, "帮助", 4);
}
m_m.SetSelectedColor(RGB(0, 0, 255));
m_m.SetMouseOverColor(RGB(255, 255, 0));
m_m.SetID(IDC_TAB1);
SendMessage(WX_TABSELCHANG, IDC_TAB1, 0);
temp.SubclassDlgItem(IDC_BUTTON2,this);
temp.SetIcon(IDI_P1);
temp2.SubclassDlgItem(IDC_BUTTON1,this);
temp2.SetIcon(IDI_P4);
ShowWindow(SW_SHOWMAXIMIZED);
return (TRUE);
}
void
CBxtDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void
CBxtDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR
CBxtDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void
CBxtDlg::TabSelChange(WPARAM wParm, LPARAM lParm)
{
if (IDC_TAB1 == wParm)
{
INT iCurSel = m_m.GetCurSel();
if (m_pCfg->iUiType == UI_TYPE_SIMPLE)
{
m_s.ShowWindow(SW_HIDE);
m_sImagePcs.ShowWindow((0 == iCurSel) ? (SW_SHOW) : (SW_HIDE));
m_sReport.ShowWindow(SW_HIDE);
m_sQuery.ShowWindow((1 == iCurSel) ? (SW_SHOW) : (SW_HIDE));
m_sHelp.ShowWindow(SW_HIDE);
}
else
{
m_s.ShowWindow((0 == iCurSel) ? (SW_SHOW) : (SW_HIDE));
m_sImagePcs.ShowWindow((1 == iCurSel) ? (SW_SHOW) : (SW_HIDE));
m_sReport.ShowWindow((2 == iCurSel) ? (SW_SHOW) : (SW_HIDE));
m_sQuery.ShowWindow((3 == iCurSel) ? (SW_SHOW) : (SW_HIDE));
m_sHelp.ShowWindow((4 == iCurSel) ? (SW_SHOW) : (SW_HIDE));
}
}
}
void
CBxtDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
}
// ---------- ---------- ---------- ---------- ----------
#define midx(w) ((int)((2100 * ww - (w))/2))
#define xcm(x) ((int)((x) * ww * 100))
#define ycm(y) ((int)((y) * hh * 100))
#define fontsize(size) ((int)((size) * ww * 10))
#define cm2twip(cm) ((int)((cm) * 567))
// ---------- ---------- ---------- ---------- ----------
// iscurrentrecord: true -> FROM REPORT, false -> FROM QUERY
// printway: 0 -> print 3 X 3 pictures, 1 -> print 3 X 4 pictures
void
CBxtDlg::PrintReport(bool iscurrentrecord,int printway)
{
int i, j;
CString m_path;
#ifdef _DEBUG
m_path = "e:\\";
#else
// m_path = "C:\\BXT\\DATA\\xxxxxxxxxxxxx\\";
m_path = ((CBxtDlg *)AfxGetMainWnd())->m_imagepath;
if (iscurrentrecord)
{
//if ((geninfo->m_id).GetLength() != 13)
// return;
m_path += geninfo->m_id;
}
else
{
//if ((query->m_id).GetLength() != 13)
//{
// AfxMessageBox("没有可以打印的记录!");
// return;
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -