【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:BmpAccessDlg.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
// BmpAccessDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BmpAccess.h"
#include "BmpAccessDlg.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)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBmpAccessDlg dialog
CBmpAccessDlg::CBmpAccessDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBmpAccessDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBmpAccessDlg)
m_id = _T("");
m_name = _T("");
m_sex = _T("");
m_knowledge = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CBmpAccessDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBmpAccessDlg)
DDX_Control(pDX, IDC_PICTURESHOW, m_pictureshow);
DDX_Control(pDX, IDC_LIST1, m_grid);
DDX_Control(pDX, IDC_PICTURE, m_picture);
DDX_Text(pDX, IDC_EDIT1, m_id);
DDX_Text(pDX, IDC_EDIT2, m_name);
DDX_Text(pDX, IDC_EDIT3, m_sex);
DDX_Text(pDX, IDC_EDIT4, m_knowledge);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBmpAccessDlg, CDialog)
//{{AFX_MSG_MAP(CBmpAccessDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTLIULAN, OnButliulan)
ON_BN_CLICKED(IDC_BUTSHOW, OnButshow)
ON_BN_CLICKED(IDC_BUTSAVE, OnButsave)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBmpAccessDlg message handlers
BOOL CBmpAccessDlg::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
::CoInitialize(NULL);
try
{
m_pConnection.CreateInstance("ADODB.Connection");
CString strConnect="Provider=Microsoft.Jet.OLEDB.4.0;\
Data Source=./shujuku.mdb;Persist Security Info=False";
m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox("数据库连接错误",0,0);
}
m_grid.SetExtendedStyle(LVS_EX_FLATSB
|LVS_EX_FULLROWSELECT
|LVS_EX_HEADERDRAGDROP
|LVS_EX_ONECLICKACTIVATE
|LVS_EX_GRIDLINES);
m_grid.InsertColumn(0,"编号",LVCFMT_LEFT,100,0);
m_grid.InsertColumn(1,"",LVCFMT_LEFT,100,1);
m_grid.InsertColumn(2,"性别",LVCFMT_LEFT,100,2);
m_grid.InsertColumn(3,"学历",LVCFMT_LEFT,100,3);
AddToGrid();
m_bExpand=FALSE;
CRect rcDlg, rcMarker;
GetWindowRect(rcDlg);
m_nExpandedHeight = rcDlg.Height();
GetDlgItem(IDC_COMPART)->GetWindowRect(rcMarker);
m_nNormalHeight = (rcMarker.top - rcDlg.top);
Display();
return TRUE; // return TRUE unless you set the focus to a control
}
void CBmpAccessDlg::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 CBmpAccessDlg::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();
}
if (m_hbitmap != NULL)
{
CDC* pDC = m_picture.GetDC();
CRect r;
m_picture.GetClientRect(&r);
//将位图选进设备场景中
CDC memdc;
memdc.CreateCompatibleDC( pDC );
memdc.SelectObject(m_hbitmap);
BITMAP bmp;
GetObject(m_hbitmap,sizeof(bmp),&bmp);
pDC->StretchBlt(r.left,r.top,r.Width(),r.Height(),&memdc,0,0,
bmp.bmWidth,bmp.bmHeight,SRCCOPY);
memdc.DeleteDC();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CBmpAccessDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CBmpAccessDlg::OnButliulan()
{
// TODO: Add your control notification handler code here
CFileDialog m_dialog (true,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"位图文件(*.bmp)|*.bmp",this);
if (m_dialog.DoModal()==IDOK)
{
//取得图片的完整路径
strText = m_dialog.GetPathName();
// HBITMAP m_hBitmap;
m_hbitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),strText,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_DEFAULTCOLOR|LR_DEFAULTSIZE);
if (m_hbitmap != NULL)
{
//使用控件显示图片
// m_picture.SetBitmap(m_hBitmap);
CDC* pDC = m_picture.GetDC();
CRect r;
m_picture.GetClientRect(&r);
//将位图选进设备场景中
CDC memdc;
memdc.CreateCompatibleDC( pDC );
memdc.SelectObject(m_
上一篇:
BmpAccess.cpp
下一篇:
法律专业开题报告范文