- 分享
- 0
- 人气
- 0
- 主题
- 8
- 帖子
- 22
- UID
- 107501
- 积分
- 11
- 阅读权限
- 11
- 注册时间
- 2007-10-30
- 最后登录
- 2011-3-21
- 在线时间
- 25 小时
|
请问为什么我在VC++ MFC 建立一个图片然后再建立一个区域显示网页,当网页显示flash会出现一直闪的情况,不过这个情况是在一些电脑,某一些电脑没出现这个问题,经过测试 window XP 没问题,window 7 (64bit) 和 window vista ,window 7 32bit 某些电脑会出现这个问题,我问了很多人都答不了我,有些说是 双缓冲 关系 但是我是用 IE控件 API 不是已经自带了吗?
一下代码- // tttttDlg.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "ttttt.h"
- #include "tttttDlg.h"
- #include <winuser.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // 对话框数据
- enum { IDD = IDD_ABOUTBOX };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
- // 实现
- protected:
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- END_MESSAGE_MAP()
- // CtttttDlg 对话框
- CtttttDlg::CtttttDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CtttttDlg::IDD, pParent)
- {
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CtttttDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_EXPLORER1, myiebrowser);
- }
- BEGIN_MESSAGE_MAP(CtttttDlg, CDialog)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- HDC g_backgroundhdc;
- HDC g_CloseButtonhdc;
- HBITMAP g_hbkBmp ;
- BITMAP g_Buttombi;
- int g_iButtomPosX = 1010;
- int g_iButtomPosY = 280;
- CRect ButtomCloseRect;
- CDC* dcMain;
- CDC dcCanvas;
- CBrush ctlBrush( RGB( 255,0,255 ) );
- CBitmap bmpCanvas; // 画布位图
- static int IELEFT = 165;
- static int IETOP = 330;
- int IEW = 848;
- int IEH = 140000;
- // CtttttDlg 消息处理程序
- BOOL CtttttDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // 将\“关于...\”菜单项添加到系统菜单中。
- // IDM_ABOUTBOX 必须在系统命令范围内。
- 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);
- }
- }
- // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
- // 执行此操作
- SetIcon(m_hIcon, TRUE); // 设置大图标
- SetIcon(m_hIcon, FALSE); // 设置小图标
- // TODO: 在此添加额外的初始化代码
- CBitmap bmp;
- if(bmp.LoadBitmap(IDB_BITMAP1))
- {
- HRGN rgn;
- rgn = BitmapToRegion((HBITMAP)bmp, RGB(255,255, 0), RGB(0, 0, 0));
- SetWindowRgn(rgn, TRUE);
- bmp.DeleteObject();
- }
- myiebrowser.SetWindowPos( NULL, IELEFT, IETOP, IEW+ IELEFT, IEH + IETOP, 0 );
- myiebrowser.ShowWindow( SW_NORMAL );
- myiebrowser.Navigate( "http://www.163.com", 0, 0, 0, 0 );
- dcMain = GetDC();
- dcMain->SelectObject( GetFont() );
- //dcMain->SelectObject( GetStockObject( HOLLOW_BRUSH ) );
- dcMain->SelectObject( ctlBrush );
- dcMain->SetBkColor( RGB(255, 0, 255) );
- HWND hWnd = GetSafeHwnd();
- #define WS_EX_LAYERED 0x00080000
- HWND hAlpha = hWnd;//CreateDialog( AfxGetInstanceHandle(), MAKEINTRESOURCE( IDD_DHTML_FORM ), hWnd, AlphaProc );
- g_backgroundhdc = CreateCompatibleDC(0);
- CBitmap bmp2;
- bmp2.LoadBitmap(IDB_BITMAP1);
- HBITMAP hbmp = (HBITMAP)bmp2.GetSafeHandle();//LoadImage(0, "2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- SelectObject(g_backgroundhdc, hbmp );
- g_CloseButtonhdc = CreateCompatibleDC(0);
-
- //g_hbkBmp = (HBITMAP)LoadImage(0, "mini.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
-
- //SelectObject(g_CloseButtonhdc, g_hbkBmp );
- CBitmap bmpCloseButton;
- bmpCloseButton.LoadBitmap(IDB_CLOSE);
- SelectObject(g_CloseButtonhdc, (HBITMAP)bmpCloseButton.GetSafeHandle() );
- ::GetObject( (HBITMAP)bmpCloseButton.GetSafeHandle(), sizeof(BITMAP), &g_Buttombi);
- COLORREF first = GetPixel(g_CloseButtonhdc,0,0);
- for(int ix = 0 ; ix < g_Buttombi.bmWidth ; ix++)
- {
- for(int iy = 0 ; iy < g_Buttombi.bmWidth ; iy++)
- {
- COLORREF tmp = GetPixel(g_CloseButtonhdc,ix,iy);
- if(tmp != first)
- SetPixel(g_backgroundhdc,g_iButtomPosX+ix,g_iButtomPosY+iy,tmp);
- }
- }
- HDC MiniButtonhdc = CreateCompatibleDC(0);
- CBitmap bmpMiniButton;
- bmpMiniButton.LoadBitmap(IDB_MINI);
- //g_hbkBmp = (HBITMAP)LoadImage(0, "close.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- // SelectObject(MiniButtonhdc, (HBITMAP)g_hbkBmp );
- SelectObject(MiniButtonhdc, (HBITMAP)bmpMiniButton.GetSafeHandle() );
- ::GetObject( (HBITMAP)bmpMiniButton.GetSafeHandle(), sizeof(BITMAP), &g_Buttombi);
- first = GetPixel(MiniButtonhdc,0,0);
- for(int ix = 0 ; ix < g_Buttombi.bmWidth ; ix++)
- {
- for(int iy = 0 ; iy < g_Buttombi.bmWidth ; iy++)
- {
- COLORREF tmp = GetPixel(MiniButtonhdc,ix,iy);
- if(tmp != first)
- SetPixel(g_backgroundhdc,g_iButtomPosX+ix -50,g_iButtomPosY+iy,tmp);
- }
- }
- ButtomCloseRect.left = g_iButtomPosX;
- ButtomCloseRect.right = ButtomCloseRect.left + g_Buttombi.bmWidth;
- ButtomCloseRect.top = g_iButtomPosY;
- ButtomCloseRect.bottom = ButtomCloseRect.top + g_Buttombi.bmHeight;
- return TRUE; // 除非设置了控件的焦点,否则返回 TRUE
- }
- void CtttttDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // 如果向对话框添加最小化按钮,则需要下面的代码
- // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
- // 这将由框架自动完成。
- void CtttttDlg::OnPaint()
- {
- if (1)
- {
- CPaintDC dc(this); // 用于绘制的设备上下文
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
- // 使图标在工作矩形中居中
- 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;
- static int ttx = 0;
- static int tty = 0;
- BitBlt( dc,0,0, 1224, 900,g_backgroundhdc, ttx, tty, SRCCOPY );
- //BitBlt( dc,150,100, 1224, 900,g_CloseButtonhdc, 0, 0, SRCCOPY );
-
- //dcMain->BitBlt( 0,0, 316, 126,&dcCanvas, 0, 0, SRCCOPY );
- //RECT fd;
- //fd.left =fd.top = 50;
- //fd.right =fd.bottom = 400;
- //dc.DrawText("DDDDD",4,&fd,DT_CENTER);
- // 绘制图标
- //dc.DrawIcon(x, y, m_hIcon);
- CDialog::OnPaint();
- }
- else
- {
- CDialog::OnPaint();
- }
- }
-
- //BOOL CUpdateDlg::OnMsgComing( UINT message, WPARAM wParam, LPARAM lParam )
- LRESULT CtttttDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch(message)
- {
- case WM_LBUTTONDOWN:
- {
-
- CRect minibuttom = ButtomCloseRect;
- minibuttom.left -= 50;
- minibuttom.right -= 50;
- CPoint pt( LOWORD( lParam ), HIWORD( lParam ) );
- if ( ::PtInRect( &ButtomCloseRect, pt ) )
- {
- theApp.CWinThread::GetMainWnd()->DestroyWindow();
- }
- else if ( ::PtInRect( &minibuttom, pt ) )
- {
- ShowWindow(SW_SHOWMINIMIZED);
- }else
- SendMessage(WM_SYSCOMMAND,0xf012,0);
- }
- break;
- default:
- break;
- }
- return CDialog::WindowProc( message, wParam, lParam );
- }
复制代码 |
|