myWinInet_1Dlg.cpp
上传用户:tianhe
上传日期:2013-11-07
资源大小:40k
文件大小:6k
源码类别:

加密解密

开发平台:

Visual C++

  1. // myWinInet_1Dlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "myWinInet_1.h"
  5. #include "myWinInet_1Dlg.h"
  6. #include "MyVw.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CAboutDlg dialog used for App About
  14. class CAboutDlg : public CDialog
  15. {
  16. public:
  17. CAboutDlg();
  18. // Dialog Data
  19. //{{AFX_DATA(CAboutDlg)
  20. enum { IDD = IDD_ABOUTBOX };
  21. //}}AFX_DATA
  22. // ClassWizard generated virtual function overrides
  23. //{{AFX_VIRTUAL(CAboutDlg)
  24. protected:
  25. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  26. //}}AFX_VIRTUAL
  27. // Implementation
  28. protected:
  29. //{{AFX_MSG(CAboutDlg)
  30. //}}AFX_MSG
  31. DECLARE_MESSAGE_MAP()
  32. };
  33. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  34. {
  35. //{{AFX_DATA_INIT(CAboutDlg)
  36. //}}AFX_DATA_INIT
  37. }
  38. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CAboutDlg)
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  45. //{{AFX_MSG_MAP(CAboutDlg)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CMyWinInet_1Dlg dialog
  50. CMyWinInet_1Dlg::CMyWinInet_1Dlg(CWnd* pParent /*=NULL*/)
  51. : CDialog(CMyWinInet_1Dlg::IDD, pParent)
  52. {
  53. //{{AFX_DATA_INIT(CMyWinInet_1Dlg)
  54. //}}AFX_DATA_INIT
  55. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  56. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  57. }
  58. void CMyWinInet_1Dlg::DoDataExchange(CDataExchange* pDX)
  59. {
  60. CDialog::DoDataExchange(pDX);
  61. //{{AFX_DATA_MAP(CMyWinInet_1Dlg)
  62. DDX_Control(pDX, IDC_URL, m_picUrl);
  63. DDX_Control(pDX, IDC_INFO, m_info);
  64. DDX_Control(pDX, IDC_QQ_NUM, m_qqNum);
  65. //}}AFX_DATA_MAP
  66. }
  67. BEGIN_MESSAGE_MAP(CMyWinInet_1Dlg, CDialog)
  68. //{{AFX_MSG_MAP(CMyWinInet_1Dlg)
  69. ON_WM_SYSCOMMAND()
  70. ON_WM_PAINT()
  71. ON_WM_QUERYDRAGICON()
  72. ON_BN_CLICKED(IDC_EMPTY, OnEmpty)
  73. ON_BN_CLICKED(IDC_BTN_SHOW_PIC, OnBtnShowPic)
  74. //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CMyWinInet_1Dlg message handlers
  78. BOOL CMyWinInet_1Dlg::OnInitDialog()
  79. {
  80. CDialog::OnInitDialog();
  81. // Add "About..." menu item to system menu.
  82. // IDM_ABOUTBOX must be in the system command range.
  83. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  84. ASSERT(IDM_ABOUTBOX < 0xF000);
  85. CMenu* pSysMenu = GetSystemMenu(FALSE);
  86. if (pSysMenu != NULL)
  87. {
  88. CString strAboutMenu;
  89. strAboutMenu.LoadString(IDS_ABOUTBOX);
  90. if (!strAboutMenu.IsEmpty())
  91. {
  92. pSysMenu->AppendMenu(MF_SEPARATOR);
  93. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  94. }
  95. }
  96. // Set the icon for this dialog.  The framework does this automatically
  97. //  when the application's main window is not a dialog
  98. SetIcon(m_hIcon, TRUE); // Set big icon
  99. SetIcon(m_hIcon, FALSE); // Set small icon
  100. m_qqNum.SetWindowText("63440321");
  101. return TRUE;  // return TRUE  unless you set the focus to a control
  102. }
  103. void CMyWinInet_1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
  104. {
  105. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  106. {
  107. CAboutDlg dlgAbout;
  108. dlgAbout.DoModal();
  109. }
  110. else
  111. {
  112. CDialog::OnSysCommand(nID, lParam);
  113. }
  114. }
  115. // If you add a minimize button to your dialog, you will need the code below
  116. //  to draw the icon.  For MFC applications using the document/view model,
  117. //  this is automatically done for you by the framework.
  118. void CMyWinInet_1Dlg::OnPaint() 
  119. {
  120. if (IsIconic())
  121. {
  122. CPaintDC dc(this); // device context for painting
  123. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  124. // Center icon in client rectangle
  125. int cxIcon = GetSystemMetrics(SM_CXICON);
  126. int cyIcon = GetSystemMetrics(SM_CYICON);
  127. CRect rect;
  128. GetClientRect(&rect);
  129. int x = (rect.Width() - cxIcon + 1) / 2;
  130. int y = (rect.Height() - cyIcon + 1) / 2;
  131. // Draw the icon
  132. dc.DrawIcon(x, y, m_hIcon);
  133. }
  134. else
  135. {
  136. CDialog::OnPaint();
  137. }
  138. }
  139. // The system calls this to obtain the cursor to display while the user drags
  140. //  the minimized window.
  141. HCURSOR CMyWinInet_1Dlg::OnQueryDragIcon()
  142. {
  143. return (HCURSOR) m_hIcon;
  144. }
  145. void CMyWinInet_1Dlg::OnOK() 
  146. {
  147. pThread=AfxBeginThread(findHtmlInfo,this);
  148. }
  149. UINT CMyWinInet_1Dlg::findHtmlInfo(PVOID lParam)
  150. {
  151. CMyWinInet_1Dlg* dlg=(CMyWinInet_1Dlg*)lParam;
  152.    
  153.     //组成网址=============
  154. CString strURL="http://photo.qq.com/cgi-bin/portal/cgi_portal_list_album?uin=";
  155. CString strQQNum;
  156. dlg->m_qqNum.GetWindowText(strQQNum);
  157. strURL+=strQQNum;
  158.     //====================
  159.     CInternetSession mySession(NULL,0);
  160. CHttpFile* myHttpFile=NULL;
  161. CString myData;
  162. myHttpFile=(CHttpFile*)mySession.OpenURL(strURL);
  163.     int nPlaceSta,nPlaceEnd;
  164.     CString st;
  165.     dlg->m_info.SetWindowText("");
  166. while(myHttpFile->ReadString(myData))
  167. {
  168. if((nPlaceSta=myData.Find("CDATA"))!=-1)//如果找到了
  169. {
  170. dlg->m_info.ReplaceSel("rn");
  171. nPlaceEnd=myData.Find("]]>");
  172. st=myData.Mid(nPlaceSta+6,nPlaceEnd-nPlaceSta-6);   
  173. dlg->m_info.ReplaceSel(st);
  174. }
  175. if((nPlaceSta=myData.Find("<pre>"))!=-1)//如果找到了
  176. {
  177. dlg->m_info.ReplaceSel("rn");
  178. nPlaceEnd=myData.Find("</pre>");
  179. st=myData.Mid(nPlaceSta+5,nPlaceEnd-nPlaceSta-5);   
  180. dlg->m_info.ReplaceSel(st);
  181. dlg->m_picUrl.AddString(st);
  182. }
  183. }
  184. dlg->m_info.ReplaceSel("rn查找结束");
  185.     dlg->m_picUrl .SetWindowText(st);
  186. return 0;
  187. }
  188. void CMyWinInet_1Dlg::OnEmpty() 
  189. {
  190. m_info.SetWindowText("");
  191. m_picUrl.ResetContent( );
  192. }
  193. void CMyWinInet_1Dlg::GetPicture(CString picUrl)
  194. {
  195.     CCreateContext pContext;
  196. CWnd* pFrameWnd = this;
  197. pContext.m_pCurrentDoc = new CDocument;
  198. pContext.m_pNewViewClass = RUNTIME_CLASS(CMyVw);
  199. CMyVw *pView =(CMyVw *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
  200. ASSERT(pView);
  201. CRect rectWindow;
  202. GetDlgItem(IDC_STATI)->GetWindowRect(rectWindow);
  203. pView->MoveWindow(260,25,140,140);
  204. pView->ShowWindow(SW_NORMAL);
  205. pView->Navigate(picUrl);
  206. }
  207. void CMyWinInet_1Dlg::OnBtnShowPic() 
  208. {
  209. CString pu;
  210. m_picUrl.GetWindowText(pu);
  211. GetPicture(pu);
  212. }