| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- // QR_Image.cpp : 傾僾儕働乕僔儑儞梡僋儔僗偺婡擻掕媊
- // Date 2006/05/17 Ver. 1.22 Psytec Inc.
- #include "stdafx.h"
- #include "QR_Image.h"
- #include "QR_Encode.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CQR_ImageApp
- BEGIN_MESSAGE_MAP(CQR_ImageApp, CWinApp)
- //{{AFX_MSG_MAP(CQR_ImageApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CQR_ImageApp 级的初始化
- CQR_ImageApp::CQR_ImageApp()
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // 桞堦偺 CQR_ImageApp 僆僽僕僃僋僩
- CQR_ImageApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // CQR_ImageApp 初始化
- BOOL CQR_ImageApp::InitInstance()
- {
- // OLE 初始化
- if (! AfxOleInit())
- return FALSE;
- // 内存泄漏查出用检查站设定(只调试时) //※ToolTip 关联的泄漏没有问题
- #ifdef _DEBUG
- mStart.Checkpoint();
- #endif //_DEBUG
- #if _MFC_VER <= 0x0600
- #ifdef _AFXDLL
- Enable3dControls();
- #else
- Enable3dControlsStatic();
- #endif
- #endif
- // 主要窗口作成
- CMainFrame* pFrame = new CMainFrame;
- m_pMainWnd = pFrame;
- // 由资源路框架
- pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW, NULL, NULL);
- // 应用图标组套
- HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- pFrame->SetIcon(hIcon, TRUE);
- // 主要窗表示,更新
- pFrame->ShowWindow(SW_SHOW);
- pFrame->UpdateWindow();
- return TRUE;
- }
- int CQR_ImageApp::ExitInstance()
- {
- // 内存泄漏信息表示(只调试时
- #ifdef _DEBUG
- mEnd.Checkpoint();
- if (mDiff.Difference(mStart, mEnd))
- {
- TRACE("\n-------- Detected memory leaks. DUMP(DumpStatistics) Start --------\n");
- mDiff.DumpStatistics();
- TRACE("-------- Detected memory leaks. DUMP(DumpStatistics) End --------\n");
- TRACE("\n-------- Detected memory leaks. DUMP(DumpAllObjectsSince) Start --------\n");
- mDiff.DumpAllObjectsSince();
- TRACE("-------- Detected memory leaks. DUMP(DumpAllObjectsSince) End --------\n\n");
- // AfxMessageBox("Detected memory leaks.", MB_OK | MB_ICONEXCLAMATION);
- }
- else
- {
- TRACE("\n-------- No detected memory leaks. OK !! --------\n\n");
- }
- #endif //_DEBUG
- return CWinApp::ExitInstance();
- }
- /////////////////////////////////////////////////////////////////////////////
- // 用应用的版本信息被使用的 CAboutDlg 对话框
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- HCURSOR m_hCurArrow, m_hCurWait, m_hCurHand;
- HFONT m_hFont; // URL/MailTo 表示字符串字体
- // 为了再绘画抑制的标志
- BOOL m_bPointOnUrl;
- BOOL m_bPointOnMailTo;
- // 为了对鼠标键押上时指令实行的标志
- BOOL m_bBtnDownUrl;
- BOOL m_bBtnDownMailTo;
- // 对话框数据
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 偺僒億乕僩
- //}}AFX_VIRTUAL
- // implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- virtual BOOL OnInitDialog();
- afx_msg void OnDestroy();
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- //}}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)
- ON_WM_DESTROY()
- ON_WM_CTLCOLOR()
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- //为了实行对话框的应用指令
- void CQR_ImageApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_hCurArrow = LoadCursor(NULL, IDC_ARROW);
- m_hCurWait = LoadCursor(NULL, IDC_WAIT);
- m_hCurHand = AfxGetApp()->LoadCursor(IDC_RHAND);
- m_bPointOnUrl = m_bPointOnMailTo = FALSE;
- m_bBtnDownUrl = m_bBtnDownMailTo = FALSE;
- // 字体作成(字下线补充)
- LOGFONT lf;
- lf.lfHeight = 12;
- lf.lfWidth = 0;
- lf.lfEscapement = 0;
- lf.lfOrientation = 0;
- lf.lfWeight = FW_DONTCARE;
- lf.lfItalic = FALSE;
- lf.lfUnderline = TRUE;
- lf.lfStrikeOut = FALSE;
- lf.lfCharSet = SHIFTJIS_CHARSET;
- lf.lfOutPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfQuality = PROOF_QUALITY;
- lf.lfPitchAndFamily = DEFAULT_PITCH;
- lstrcpy(lf.lfFaceName, "宋体");
- m_hFont = CreateFontIndirect(&lf);
- GetDlgItem(IDC_STATICURL)->SendMessage(WM_SETFONT, (WPARAM)m_hFont, TRUE);
- GetDlgItem(IDC_STATICMAILTO)->SendMessage(WM_SETFONT, (WPARAM)m_hFont, TRUE);
- return TRUE;
- }
- void CAboutDlg::OnDestroy()
- {
- CDialog::OnDestroy();
-
- // 使用客观废弃
- DeleteObject(m_hFont);
- }
- HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- int nID = pWnd->GetDlgCtrlID();
- if (nID == IDC_STATICURL)
- pDC->SetTextColor(m_bPointOnUrl ? RGB(255, 128, 0) : RGB(0, 0, 128));
- if (nID == IDC_STATICMAILTO)
- pDC->SetTextColor(m_bPointOnMailTo ? RGB(255, 128, 0) : RGB(0, 0, 128));
- return hbr;
- }
- void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point)
- {
- // 鼠标坐标位置检查
- ClientToScreen(&point);
- CRect rectUrl;
- GetDlgItem(IDC_STATICURL)->GetWindowRect(rectUrl);
- CRect rectMailTo;
- GetDlgItem(IDC_STATICMAILTO)->GetWindowRect(rectMailTo);
- // 光标变更
- SetCursor(rectUrl.PtInRect(point) || rectMailTo.PtInRect(point) ? m_hCurHand : m_hCurArrow);
- if (m_bPointOnUrl != rectUrl.PtInRect(point))
- {
- // URL 表示文本变色更
- GetDlgItem(IDC_STATICURL)->InvalidateRect(NULL);
- m_bPointOnUrl = rectUrl.PtInRect(point);
- if (m_bPointOnUrl)
- SetCapture();
- else
- ReleaseCapture();
- }
- if (m_bPointOnMailTo != rectMailTo.PtInRect(point))
- {
- // mailto 表示文本变色更
- GetDlgItem(IDC_STATICMAILTO)->InvalidateRect(NULL);
- m_bPointOnMailTo = rectMailTo.PtInRect(point);
- if (m_bPointOnMailTo)
- SetCapture();
- else
- ReleaseCapture();
- }
- CDialog::OnMouseMove(nFlags, point);
- }
- void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // mailto 表示文书?颜色更
- ClientToScreen(&point);
- CRect rectUrl;
- GetDlgItem(IDC_STATICURL)->GetWindowRect(rectUrl);
- CRect rectMailTo;
- GetDlgItem(IDC_STATICMAILTO)->GetWindowRect(rectMailTo);
- // 光标变更
- SetCursor(rectUrl.PtInRect(point) || rectMailTo.PtInRect(point) ? m_hCurHand : m_hCurArrow);
- m_bBtnDownUrl = rectUrl.PtInRect(point);
- m_bBtnDownMailTo = rectMailTo.PtInRect(point);
- CDialog::OnLButtonDown(nFlags, point);
- }
- void CAboutDlg::OnLButtonUp(UINT nFlags, CPoint point)
- {
- if (m_bBtnDownUrl)
- {
- // 鼠标坐标位置检查
- ClientToScreen(&point);
- CRect rectUrl;
- GetDlgItem(IDC_STATICURL)->GetWindowRect(rectUrl);
- if (rectUrl.PtInRect(point))
- {
- SetCursor(m_hCurWait);
- // 浏览器启动
- ShellExecute(m_hWnd, "open", "http://www.lyfz.net", NULL, "", SW_SHOW);
- //考虑本对话框被遮住的情况绘画文本
- m_bPointOnUrl = FALSE;
- GetDlgItem(IDC_STATICURL)->InvalidateRect(NULL);
- SetCursor(m_hCurArrow);
- }
- m_bBtnDownUrl = FALSE;
- }
- else if (m_bBtnDownMailTo)
- {
- //鼠标坐标位置检查
- ClientToScreen(&point);
- CRect rectMailTo;
- GetDlgItem(IDC_STATICMAILTO)->GetWindowRect(rectMailTo);
- if (rectMailTo.PtInRect(point))
- {
- SetCursor(m_hCurWait);
- //mailer启动
- ShellExecute(m_hWnd, "open", "mailto:10000@qq.com", NULL, "", SW_SHOW);
- // 考虑本对话框被遮住的情况绘画文本
- m_bPointOnMailTo = FALSE;
- GetDlgItem(IDC_STATICMAILTO)->InvalidateRect(NULL);
- SetCursor(m_hCurArrow);
- }
- m_bBtnDownMailTo = FALSE;
- }
- CDialog::OnLButtonUp(nFlags, point);
- }
|