myWinInet_1Dlg.cpp
资源名称:QQAlbum.rar [点击查看]
上传用户:tianhe
上传日期:2013-11-07
资源大小:40k
文件大小:6k
源码类别:
加密解密
开发平台:
Visual C++
- // myWinInet_1Dlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "myWinInet_1.h"
- #include "myWinInet_1Dlg.h"
- #include "MyVw.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)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyWinInet_1Dlg dialog
- CMyWinInet_1Dlg::CMyWinInet_1Dlg(CWnd* pParent /*=NULL*/)
- : CDialog(CMyWinInet_1Dlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMyWinInet_1Dlg)
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CMyWinInet_1Dlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMyWinInet_1Dlg)
- DDX_Control(pDX, IDC_URL, m_picUrl);
- DDX_Control(pDX, IDC_INFO, m_info);
- DDX_Control(pDX, IDC_QQ_NUM, m_qqNum);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMyWinInet_1Dlg, CDialog)
- //{{AFX_MSG_MAP(CMyWinInet_1Dlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_EMPTY, OnEmpty)
- ON_BN_CLICKED(IDC_BTN_SHOW_PIC, OnBtnShowPic)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyWinInet_1Dlg message handlers
- BOOL CMyWinInet_1Dlg::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
- m_qqNum.SetWindowText("63440321");
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CMyWinInet_1Dlg::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 CMyWinInet_1Dlg::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 CMyWinInet_1Dlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CMyWinInet_1Dlg::OnOK()
- {
- pThread=AfxBeginThread(findHtmlInfo,this);
- }
- UINT CMyWinInet_1Dlg::findHtmlInfo(PVOID lParam)
- {
- CMyWinInet_1Dlg* dlg=(CMyWinInet_1Dlg*)lParam;
- //组成网址=============
- CString strURL="http://photo.qq.com/cgi-bin/portal/cgi_portal_list_album?uin=";
- CString strQQNum;
- dlg->m_qqNum.GetWindowText(strQQNum);
- strURL+=strQQNum;
- //====================
- CInternetSession mySession(NULL,0);
- CHttpFile* myHttpFile=NULL;
- CString myData;
- myHttpFile=(CHttpFile*)mySession.OpenURL(strURL);
- int nPlaceSta,nPlaceEnd;
- CString st;
- dlg->m_info.SetWindowText("");
- while(myHttpFile->ReadString(myData))
- {
- if((nPlaceSta=myData.Find("CDATA"))!=-1)//如果找到了
- {
- dlg->m_info.ReplaceSel("rn");
- nPlaceEnd=myData.Find("]]>");
- st=myData.Mid(nPlaceSta+6,nPlaceEnd-nPlaceSta-6);
- dlg->m_info.ReplaceSel(st);
- }
- if((nPlaceSta=myData.Find("<pre>"))!=-1)//如果找到了
- {
- dlg->m_info.ReplaceSel("rn");
- nPlaceEnd=myData.Find("</pre>");
- st=myData.Mid(nPlaceSta+5,nPlaceEnd-nPlaceSta-5);
- dlg->m_info.ReplaceSel(st);
- dlg->m_picUrl.AddString(st);
- }
- }
- dlg->m_info.ReplaceSel("rn查找结束");
- dlg->m_picUrl .SetWindowText(st);
- return 0;
- }
- void CMyWinInet_1Dlg::OnEmpty()
- {
- m_info.SetWindowText("");
- m_picUrl.ResetContent( );
- }
- void CMyWinInet_1Dlg::GetPicture(CString picUrl)
- {
- CCreateContext pContext;
- CWnd* pFrameWnd = this;
- pContext.m_pCurrentDoc = new CDocument;
- pContext.m_pNewViewClass = RUNTIME_CLASS(CMyVw);
- CMyVw *pView =(CMyVw *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
- ASSERT(pView);
- CRect rectWindow;
- GetDlgItem(IDC_STATI)->GetWindowRect(rectWindow);
- pView->MoveWindow(260,25,140,140);
- pView->ShowWindow(SW_NORMAL);
- pView->Navigate(picUrl);
- }
- void CMyWinInet_1Dlg::OnBtnShowPic()
- {
- CString pu;
- m_picUrl.GetWindowText(pu);
- GetPicture(pu);
- }