#pragma once
#include "afxwin.h"


// DLG_Corp_LXR_SF 对话框

#define WM_CORP_LXR_SF_RET  WM_USER+1098    //通知接收到消息的接口。


class DLG_Corp_LXR_SF : public CDialogEx
{
	DECLARE_DYNAMIC(DLG_Corp_LXR_SF)
public:
	long m_lYWYCount;
	long m_lDefaultYWYID;
	ANS_Corp_SFData m_SF;
	ANS_Corp_LXR_YWYData * m_pYWYData;
	BOOL m_bNew;
public:
	static void GetCurrentPath(TCHAR *pPath);
	static void OnPreparePrinting2(CPrintInfo* pInfo);
	POINT MakePoint(float x, float y, float xrate = 1.0f, float yrate = 1.0f);
	RECT MakeRect(float x, float y, float w, float h, float xrate=1.0f, float yrate= 1.0f);
	void MakeRect_Pict(float &x, float &y, float &w, float &h, SIZE iSize);
	void Draw_Image(HDC pDc, CString strName, float x, float y, float w, float h, float xmm, float ymm);
	static void On_BeginPrint2(CDC *pDC, CPrintInfo *pInfo, void *pVoid);
	static void On_Print2(CDC *pDC, CPrintInfo *pInfo, void *pVoid);
	static void On_Print2_b(CDC *pDC, CPrintInfo *pInfo, void *pVoid);

	BOOL ProcessSocket(Socket_Head_Add *pHead, BYTE *pFrame);
	void SetParam(long lYWYCount, long lDefaultYWYID, ANS_Corp_LXR_YWYData * pYWYData, ANS_Corp_SFData SF,BOOL bNew);
	DLG_Corp_LXR_SF(CWnd* pParent = NULL);   // 标准构造函数
	virtual ~DLG_Corp_LXR_SF();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_CORP_LXR_SF };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
	LRESULT On_SF_Ret(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedCancel();
	CString m_strCargo;
	CString m_strD_Address;
	CString m_strD_Company;
	CString m_strD_Contact;
	CString m_strD_Mobile;
	CString m_strD_Tel;
	CString m_strDestcode;
	int m_lExpressType;
	CString m_strJ_Contact;
	CString m_strJ_Mobile;
	CString m_strJ_Tel;
	CString m_strMailNo;
	CString m_strRemark;
	int m_lPayMethod;
	CButton m_B_Order;
	CButton m_B_Print;
	CButton m_B_Preview;
	double m_fPrice;
	virtual BOOL OnInitDialog();
	CComboBox m_J_Contact;
	afx_msg void OnCbnSelchangeCorpSfJContact();
	CEdit m_E_J_Mobile;
	CEdit m_E_J_Tel;
	afx_msg void OnBnClickedCorpSfOrder();
	afx_msg void OnCbnEditchangeCorpSfJContact();
	afx_msg void OnCbnSelendokCorpSfJContact();
	afx_msg void OnCbnCloseupCorpSfJContact();
	int EnableInputWindows(BOOL bEnable);
	CButton m_B_SFCancel;
	CButton m_B_SFRoute;
	afx_msg void OnBnClickedCorpSfCancel();
	afx_msg void OnBnClickedCorpSfRoute();
	CStatic m_S1;
	afx_msg void OnBnClickedCorpSfPreview();
	afx_msg void OnBnClickedCorpSfPrint();
};



class CMemDCLJ : public CDC {
private:
	CBitmap		m_bitmap;		// Offscreen bitmap
	CBitmap*	m_oldBitmap;	// bitmap originally found in CMemDCLJ
	CDC*		m_pDC;			// Saves CDC passed in constructor
	CRect		m_rect;			// Rectangle of drawing area.
	BOOL		m_bMemDC;		// TRUE if CDC really is a Memory DC.
public:
	CMemDCLJ(CDC* pDC) : CDC(), m_oldBitmap(NULL), m_pDC(pDC)
	{
		ASSERT(m_pDC != NULL); // If you asserted here, you passed in a NULL CDC.
		m_bMemDC = !pDC->IsPrinting();
		if (m_bMemDC) {
			CreateCompatibleDC(pDC);
			pDC->GetClipBox(&m_rect);
			m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
			m_oldBitmap = SelectObject(&m_bitmap);
			SetWindowOrg(m_rect.left, m_rect.top);
		}
		else {
			m_bPrinting = pDC->m_bPrinting;
			m_hDC = pDC->m_hDC;
			m_hAttribDC = pDC->m_hAttribDC;
		}
	}
	~CMemDCLJ()
	{
		if (m_bMemDC) {
			m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
				this, m_rect.left, m_rect.top, SRCCOPY);
			SelectObject(m_oldBitmap);
		}
		else {
			m_hDC = m_hAttribDC = NULL;
		}
		m_bitmap.DeleteObject();
	}
	BOOL LineX(POINT p1, POINT p2)
	{
		MoveTo(p1);
		LineTo(p2);
		return true;
	}
	CMemDCLJ* operator->() { return this; }
	operator CMemDCLJ*() { return this; }
};