📄 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
rec = NULL;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// 读取文件 C:\BXX\IMAGEPATH.INF 获得图象文件目录,如果无法读取则设定
// 默认目录为 C:\BXX
FILE *fp = NULL;
if (NULL == (fp = fopen("c:\\bxx\\imagepath.inf","r")))
{
m_imagepath = "C:\\BXX\\";
}
else
{
char textline[510];
fgets(textline,200,fp);
fclose(fp);
m_imagepath = textline;
m_imagepath.TrimLeft();
m_imagepath.TrimRight();
if ("\\" != m_imagepath.Right(1)) m_imagepath += "\\";
}
}
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_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
ON_BN_CLICKED(IDOKX, OnOkx)
ON_WM_TIMER()
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();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
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
// TODO: Add extra initialization here
//For Main
geninfo = new GenInfo;
geninfo->Create(GenInfo::IDD,&m_s);
reccing = new Reccing;
reccing->Create(Reccing::IDD,&m_s);
/**********************************/
//recinfo = new RecInfo;
//recinfo->Create(RecInfo::IDD,&m_s);
recinforgb = new RecInfoRGB;
recinforgb->Create(RecInfoRGB::IDD,&m_s);
/**********************************/
m_s.AddTab(geninfo,"一般信息",0);
m_s.AddTab(reccing,"采集",1);
/**********************************/
//m_s.AddTab(recinfo,"采集调整",2);
m_s.AddTab(recinforgb,"采集调整",2);
/**********************************/
m_s.SetSelectedColor(RGB(0, 0, 255));
m_s.SetMouseOverColor(RGB(255, 10, 255));
m_s.SetID(IDC_TAB2);
CRect rr;
m_s.GetWindowRect(&rr);
int cyc=GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYDLGFRAME);
int cxc=GetSystemMetrics(SM_CXDLGFRAME);
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;
dispimginfo->Create(DispImgInfo::IDD,&m_sImagePcs);
dispmarking = new DispMarking;
dispmarking->Create(DispMarking::IDD,&m_sImagePcs);
dispmeasure = new DispMeasure;
dispmeasure->Create(DispMeasure::IDD,&m_sImagePcs);
dispprocess = new DispProcess;
dispprocess->Create(DispProcess::IDD,&m_sImagePcs);
dispzoom = new DispZoom;
dispzoom->Create(DispZoom::IDD,&m_sImagePcs);
dispconbri = new DispConBri;
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;
queryname->Create(QueryName::IDD,&m_sQuery);
querytime = new QueryTime;
querytime->Create(QueryTime::IDD,&m_sQuery);
queryfree = new QueryFree;
queryfree->Create(QueryFree::IDD,&m_sQuery);
queryorder = new QueryOrder;
queryorder->Create(QueryOrder::IDD,&m_sQuery);
m_sQuery.AddTab(queryname,"精确",0);
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;
printimage->Create(PrintImage::IDD,&m_sReport);
rpttemplate = new RptTemplate;
rpttemplate->Create(RptTemplate::IDD,&m_sReport);
m_sReport.AddTab(rpttemplate,"模板",0);
m_sReport.AddTab(printimage,"打印",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;
helphelp->Create(HelpHelp::IDD,&m_sHelp);
helppic = new HelpPIc;
helppic->Create(HelpPIc::IDD,&m_sHelp);
helpref = new HelpRef;
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);
rec = new RecImage;
rec->Create(RecImage::IDD,&m_m);
imgpcs = new ImageProcess("c:\\");//zlj
imgpcs->Create(ImageProcess::IDD,&m_m);
report = new Report;
report->Create(Report::IDD,&m_m);
query = new Query;
query->Create(Query::IDD,&m_m);
xhelp = new xHelp;
xhelp->Create(xHelp::IDD,&m_m);
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);
//rec->ShowWindow(SW_HIDE);
/* m_s.InsertItem( 1,"test1");
m_s.InsertItem( 1,"test2");
m_s.InsertItem( 1,"test3");*/
//m_s.SetProperty()
//m_s.SetExtendedStyle(TCS_BOTTOM);
temp.SubclassDlgItem(IDC_BUTTON2,this);
temp.SetIcon(IDI_P1);
temp2.SubclassDlgItem(IDC_BUTTON1,this);
temp2.SetIcon(IDI_P4);
// temp.setpres
//SetTimer(9,500,NULL);
//->
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
wp.showCmd = SW_SHOWMAXIMIZED;
SetWindowPlacement(&wp);
//<-
// RECT rect;
//GetWindowRect(&rect);
// rect.left=0;
// rect.top = 0;
// rect.right = 1023;
// rect.bottom = 767;
// this->MoveWindow(&rect);
// m_ok.LoadBitmaps(IDB_BITMAP1,IDB_COMPANY,IDB_TEMPLATE);
// m_ok.AutoLoad(IDOK,this);
return TRUE; // return TRUE unless you set the focus to a control
}
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::OnButton1()
{
//m_s.ModifyStyle(TCS_VERTICAL,0);
/* long l=m_s.GetStyle();
char mm[100];
sprintf(mm,"%d",l);
AfxMessageBox(mm);
m_s.ModifyStyle(TCS_BOTTOM,TCS_VERTICAL|TCS_MULTILINE);*/
//m_s.ModifyStyle(0,1409286788);
//m_s.DeleteAllTabs();
int i=m_m.GetCurSel();
if(i==1)
{
m_s.DeleteAllItems();
m_s.DeleteAllTabs();
m_s.AddTab(dispimginfo,"显示方式",0);
}
}
void CBxtDlg::OnButton2()
{
//m_s.ModifyStyle(TCS_VERTICAL|TCS_MULTISELECT|TCS_FORCELABELLEFT,0);
m_s.ModifyStyle(TCS_VERTICAL|TCS_MULTILINE,0);
}
void CBxtDlg::TabSelChange(WPARAM wParm,LPARAM lParm)
{
if(wParm==IDC_TAB1)
{
int i=m_m.GetCurSel();
if(i==1)
{
m_s.ShowWindow(SW_HIDE);
m_sQuery.ShowWindow(SW_HIDE);
m_sReport.ShowWindow(SW_HIDE);
m_sHelp.ShowWindow(SW_HIDE);
m_sImagePcs.ShowWindow(SW_SHOW);
}
else if(i==2)
{
m_s.ShowWindow(SW_HIDE);
m_sImagePcs.ShowWindow(SW_HIDE);
m_sQuery.ShowWindow(SW_HIDE);
m_sHelp.ShowWindow(SW_HIDE);
m_sReport.ShowWindow(SW_SHOW);
}
else if(i==3)
{
m_s.ShowWindow(SW_HIDE);
m_sImagePcs.ShowWindow(SW_HIDE);
m_sReport.ShowWindow(SW_HIDE);
m_sHelp.ShowWindow(SW_HIDE);
m_sQuery.ShowWindow(SW_SHOW);
}
else if(i==4)
{
m_s.ShowWindow(SW_HIDE);
m_sImagePcs.ShowWindow(SW_HIDE);
m_sReport.ShowWindow(SW_HIDE);
m_sQuery.ShowWindow(SW_HIDE);
m_sHelp.ShowWindow(SW_SHOW);
}
else //==0
{
m_s.ShowWindow(SW_SHOW);
m_sImagePcs.ShowWindow(SW_HIDE);
m_sReport.ShowWindow(SW_HIDE);
m_sQuery.ShowWindow(SW_HIDE);
m_sHelp.ShowWindow(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;
if (printway < 0 || printway > 5)
{
AfxMessageBox("打印时参数不正确!");
return;
}
#ifdef _DEBUG
m_path = "e:\\";
#else
// m_path = "C:\\BXrr\\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;
//}
m_path += query->m_id;
}
m_path += "\\";
#endif
bool seled[MAX_PIC];
CSelPic selpic(m_path.GetBuffer(m_path.GetLength()),seled);
if (selpic.DoModal() != IDOK) return;
int piccount,maxpiccount;
char picpathname[12][200];
switch (printway)
{
case 0:
maxpiccount = 9;
break;
case 1:
maxpiccount = 12;
break;
case 2:
maxpiccount = 1;
break;
case 3:
maxpiccount = 2;
break;
case 4:
maxpiccount = 4;
break;
case 5:
maxpiccount = 6;
break;
}
for (piccount = 0, i = 0; i < MAX_PIC; i++)
{
if (seled[i])
{
sprintf(picpathname[piccount++],"%s%d.jpg",m_path.GetBuffer(m_path.GetLength()),i+1);
if (piccount >= maxpiccount) break;
}
}
CString text;
// m_rich
CRichEditCtrl *m_rich;
if (iscurrentrecord)
m_rich = &(report->m_rich);
else
m_rich = &(query->m_rich);
// rows,cols
int rows,cols;
switch (printway)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -