MicroShareTestDlg.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // MicroShareTestDlg.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "MicroShareTest.h"
  5. #include "MicroShareTestDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #endif
  9. typedef INT (__stdcall *lyfzCreateShare)(
  10. IN LPCTSTR lpShareAccount, // 分享的登录账号;
  11. IN LPCTSTR lpAccountPsw, // 分享的登录账号密码;
  12. IN LPCTSTR lpRootDirectory, // 相片根级目录;
  13. IN LPCTSTR lpBranchName, // 分店域名;
  14. IN LPCTSTR lpOrderNumber, // 订单号,用于生成二维码文件名;
  15. IN LPCTSTR lpScenery, // 景点名;
  16. IN LPCTSTR lpSourceFilePath, // 要分享的文件根目录;
  17. //IN CStringArray *pArySource, // 若不传入相片根目录,则传入相片路径集合(必须有小图的);
  18. IN LPCTSTR lpCustomer1Name, // 客人姓名1 ;
  19. IN LPCTSTR lpCustomer2Name, // 客人姓名2 ;
  20. IN LPCTSTR lpMakeupArtist, // 化妆师;
  21. OUT LPTSTR lpMicroAlbumID // 返回微相册ID;
  22. );
  23. lyfzCreateShare g_lyfzCreateShare = NULL;
  24. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  25. class CAboutDlg : public CDialog
  26. {
  27. public:
  28. CAboutDlg();
  29. // 对话框数据
  30. enum { IDD = IDD_ABOUTBOX };
  31. protected:
  32. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  33. // 实现
  34. protected:
  35. DECLARE_MESSAGE_MAP()
  36. };
  37. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  38. {
  39. }
  40. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialog::DoDataExchange(pDX);
  43. }
  44. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  45. END_MESSAGE_MAP()
  46. // CMicroShareTestDlg 对话框
  47. CMicroShareTestDlg::CMicroShareTestDlg(CWnd* pParent /*=NULL*/)
  48. : CDialog(CMicroShareTestDlg::IDD, pParent)
  49. {
  50. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  51. m_hMyDll = NULL;
  52. }
  53. void CMicroShareTestDlg::DoDataExchange(CDataExchange* pDX)
  54. {
  55. CDialog::DoDataExchange(pDX);
  56. }
  57. BEGIN_MESSAGE_MAP(CMicroShareTestDlg, CDialog)
  58. ON_WM_SYSCOMMAND()
  59. ON_WM_PAINT()
  60. ON_WM_QUERYDRAGICON()
  61. //}}AFX_MSG_MAP
  62. ON_BN_CLICKED(IDOK, &CMicroShareTestDlg::OnBnClickedOk)
  63. ON_BN_CLICKED(IDCANCEL, &CMicroShareTestDlg::OnBnClickedCancel)
  64. ON_BN_CLICKED(IDC_BUTTON1, &CMicroShareTestDlg::OnBnClickedButton1)
  65. END_MESSAGE_MAP()
  66. // CMicroShareTestDlg 消息处理程序
  67. BOOL CMicroShareTestDlg::OnInitDialog()
  68. {
  69. CDialog::OnInitDialog();
  70. // 将“关于...”菜单项添加到系统菜单中。
  71. // IDM_ABOUTBOX 必须在系统命令范围内。
  72. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  73. ASSERT(IDM_ABOUTBOX < 0xF000);
  74. CMenu* pSysMenu = GetSystemMenu(FALSE);
  75. if (pSysMenu != NULL)
  76. {
  77. BOOL bNameValid;
  78. CString strAboutMenu;
  79. bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
  80. ASSERT(bNameValid);
  81. if (!strAboutMenu.IsEmpty())
  82. {
  83. pSysMenu->AppendMenu(MF_SEPARATOR);
  84. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  85. }
  86. }
  87. // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
  88. // 执行此操作
  89. SetIcon(m_hIcon, TRUE); // 设置大图标
  90. SetIcon(m_hIcon, FALSE); // 设置小图标
  91. // TODO: 在此添加额外的初始化代码
  92. return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
  93. }
  94. void CMicroShareTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
  95. {
  96. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  97. {
  98. CAboutDlg dlgAbout;
  99. dlgAbout.DoModal();
  100. }
  101. else
  102. {
  103. CDialog::OnSysCommand(nID, lParam);
  104. }
  105. }
  106. // 如果向对话框添加最小化按钮,则需要下面的代码
  107. // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
  108. // 这将由框架自动完成。
  109. void CMicroShareTestDlg::OnPaint()
  110. {
  111. if (IsIconic())
  112. {
  113. CPaintDC dc(this); // 用于绘制的设备上下文
  114. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  115. // 使图标在工作区矩形中居中
  116. int cxIcon = GetSystemMetrics(SM_CXICON);
  117. int cyIcon = GetSystemMetrics(SM_CYICON);
  118. CRect rect;
  119. GetClientRect(&rect);
  120. int x = (rect.Width() - cxIcon + 1) / 2;
  121. int y = (rect.Height() - cyIcon + 1) / 2;
  122. // 绘制图标
  123. dc.DrawIcon(x, y, m_hIcon);
  124. }
  125. else
  126. {
  127. CDialog::OnPaint();
  128. }
  129. }
  130. //当用户拖动最小化窗口时系统调用此函数取得光标
  131. //显示。
  132. HCURSOR CMicroShareTestDlg::OnQueryDragIcon()
  133. {
  134. return static_cast<HCURSOR>(m_hIcon);
  135. }
  136. void CMicroShareTestDlg::OnBnClickedOk()
  137. {
  138. // TODO: 在此添加控件通知处理程序代码
  139. if ( m_hMyDll )
  140. {
  141. FreeLibrary(m_hMyDll);
  142. m_hMyDll = NULL;
  143. }
  144. OnOK();
  145. }
  146. void CMicroShareTestDlg::OnBnClickedCancel()
  147. {
  148. // TODO: 在此添加控件通知处理程序代码
  149. if ( m_hMyDll )
  150. {
  151. FreeLibrary(m_hMyDll);
  152. m_hMyDll = NULL;
  153. }
  154. OnCancel();
  155. }
  156. void CMicroShareTestDlg::OnBnClickedButton1()
  157. {
  158. // TODO: 在此添加控件通知处理程序代码
  159. #if 1
  160. DWORD dwError = 0;
  161. if ( m_hMyDll == NULL)
  162. m_hMyDll = LoadLibrary(_T("lyfzMicroShare.dll"));
  163. if ( m_hMyDll == NULL)
  164. {
  165. dwError = GetLastError();
  166. AfxMessageBox(_T("加载动态库失败"));
  167. return ;
  168. }
  169. g_lyfzCreateShare = (lyfzCreateShare)::GetProcAddress(m_hMyDll,"lyfzCreateShare");
  170. if ( g_lyfzCreateShare )
  171. {
  172. // 测试;
  173. //CString strTitle;
  174. TCHAR szTitle[1024] = {0};
  175. g_lyfzCreateShare(
  176. _T("windylel"),
  177. _T("19880528"),
  178. _T("E:\\lyfzbin\\Services\\客户原片(管理软件)$"),
  179. _T(""),
  180. _T("20150119-001"),
  181. _T("华强影视城"),
  182. _T(""),
  183. _T("赵军"),
  184. _T("李玉"),
  185. _T("孙梅"),
  186. szTitle);
  187. }
  188. if ( m_hMyDll )
  189. {
  190. FreeLibrary(m_hMyDll);
  191. m_hMyDll = NULL;
  192. }
  193. #endif
  194. }