// testDlg.cpp : implementation file
//
#include "stdafx.h"
#include "test.h"
#include "testDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int FirstRun = 1;
void TransparentBlt( HDC hdcDest, int nXDest, int nYDest, int nWidth,
int nHeight, HBITMAP hBitmap, int nXSrc, int nYSrc,
COLORREF colorTransparent, HPALETTE hPal );
static void MessageBlast(int iColumn,int iRow,LPCTSTR lpszMsg);
/////////////////////////////////////////////////////////////////////////////
// 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)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
//{{AFX_MSG_MAP(CTestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers
BOOL CTestDlg::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
// TODO: Add extra initialization here
//Initialize fisrt run flag
FirstRun = 1;
//resize window to fit bitmap rect
MoveWindow(200,200,535,105,TRUE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CTestDlg::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 CTestDlg::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
{
CPaintDC dc(this); // device context for painting
//Get and HDC pointer and pass it to SetupBk()
HDC hdc;
hdc = dc.GetSafeHdc();
SetupBk(dc);
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTestDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//Overridden to allow for mouse draging
void CTestDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDown(nFlags, point);
PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(point.x,point.y));
}
//From Codeguru.. by Zafir Anjum, the transparency here is overkill,
//SetupBk() will take care of the transparency that we are dealing with
void TransparentBlt( HDC hdcDest, int nXDest, int nYDest, int nWidth,
int nHeight, HBITMAP hBitmap, int nXSrc, int nYSrc,
COLORREF colorTransparent, HPALETTE hPal )
{
CDC dc, memDC, maskDC, tempDC;
dc.Attach( hdcDest );
maskDC.CreateCompatibleDC(&dc);
CBitmap maskBitmap;
//add these to store return of SelectObject() calls
CBitmap* pOldMemBmp = NULL;
CBitmap* pOldMaskBmp = NULL;
HBITMAP hOldTempBmp = NULL;
memDC.CreateCompatibleDC(&dc);
tempDC.CreateCompatibleDC(&dc);
CBitmap bmpImage;
bmpImage.CreateCompatibleBitmap( &dc, nWidth, nHeight );
pOldMemBmp = memDC.SelectObject( &bmpImage );
// Select and realize the palette
if( dc.GetDeviceCaps(RASTERCAPS) & RC_PALETTE && hPal )
{
::SelectPalette( dc, hPal, FALSE );
dc.RealizePalette();
::SelectPalette( memDC, hPal, FALSE );
}
hOldTempBmp = (HBITMAP) ::SelectObject( tempDC.m_hDC, hBitmap );
memDC.BitBlt( 0,0,nWidth, nHeight, &tempDC, nXSrc, nYSrc, SRCCOPY );
// Create monochrome bitmap for the mask
maskBitmap.CreateBitmap( nWidth, nHeight, 1, 1, NULL );
pOldMaskBmp = maskDC.SelectObject( &maskBitmap );
memDC.SetBkColor( colorTransparent );
// Create the mask from the memory DC
maskDC.BitBlt( 0, 0, nWidth, nHeight, &memDC,
0, 0, SRCCOPY );
// Set the background in memDC to black. Using SRCPAINT with black
// and any other color results in the other color, thus making
// black the transparent color
memDC.SetBkColor(RGB(0,0,0));
memDC.SetTextColor(RGB(255,255,255));
memDC.BitBlt(0, 0, nWidth, nHeight, &maskDC, 0, 0, SRCAND);
// Set the foreground to black. See comment above.
dc.SetBkColor(RGB(255,255,255));
dc.SetTextColor(RGB(0,0,0));
dc.BitBlt(nXDest, nYDest, nWidth, nHeight, &maskDC, 0, 0, SRCAND);
// Combine the foreground with the background
dc.BitBlt(nXDest, nYDest, nWidth, nHeight, &memDC,
0, 0, SRCPAINT);
if (hOldTempBmp)
::SelectObject( tempDC.m_hDC, hOldTempBmp);
if (pOldMaskBmp)
maskDC.SelectObject( pOldMaskBmp );
if (pOldMemBmp)
memDC.SelectObject( pOldMemBmp );
dc.Detach();
}
//Used for debugging.....
static void MessageBlast(int iColumn,int iRow,LPCTSTR lpszMsg)
{
HDC hdcScreen;
// Get a raw screen DC
hdcScreen = GetWindowDC( GetDesktopWindow() );
if (hdcScreen)
{
TextOut( hdcScreen, iColumn, iRow, lpszMsg, lstrlen(lpszMsg));
// Release the screen DC
ReleaseDC( GetDesktopWindow(), hdcScreen );
}
}
//Setup the windows Region
//The windows region controls what the OS will draw in reguards to the window
//The loop below will search for the "magic color" and add it to a region
//then Xor the region and assign it to the window and viola.
void CTestDlg::SetupBk(HDC hdc)
{
int X,Y,H,W;
CBitmap CB;
CRect R;
COLORREF C;
GetWindowRect(&R);
H = R.bottom - R.top;
W = R.right - R.left;
CB.LoadBitmap(ID
没有合适的资源?快使用搜索试试~ 我知道了~
VC++界面操作变换界面变换界面
共28个文件
h:4个
cpp:3个
obj:3个
需积分: 9 27 下载量 90 浏览量
2008-09-24
16:16:56
上传
评论
收藏 1.61MB RAR 举报
温馨提示
Visual.C++高级界面变换界面,请你给出意见,++++++++++++++++++++++++++++++
资源推荐
资源详情
资源评论
收起资源包目录
.rar (28个子文件)
变换界面
test.opt 53KB
test.h 1KB
StdAfx.cpp 202B
test.plg 2KB
resource.h 681B
test.ncb 41KB
test.cpp 2KB
test.001 4KB
test.clw 1KB
test.rc 5KB
testDlg.cpp 9KB
StdAfx.h 987B
testDlg.h 1KB
Release
test.exe 188KB
testDlg.obj 25KB
vc60.idb 49KB
test.res 167KB
test.pch 5.34MB
StdAfx.obj 804B
test.obj 13KB
test.dsp 4KB
res
Image1.bmp 43KB
test.rc2 396B
Untitled-1.BMP 165KB
bitmap2.bmp 126KB
test.ico 1KB
test.dsw 533B
test.aps 185KB
共 28 条
- 1
资源评论
zhuzhen1
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功