📄 link_listsview.cpp
字号:
// Link_listsView.cpp : implementation of the CLink_listsView class
//
#include "stdafx.h"
#include "Link_lists.h"
#include "Link_listsDoc.h"
#include "Link_listsView.h"
#include "LINK.h"
#include "INSERT.h"
#include "DEL.h"
#include "DIB.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLink_listsView
IMPLEMENT_DYNCREATE(CLink_listsView, CView)
BEGIN_MESSAGE_MAP(CLink_listsView, CView)
//{{AFX_MSG_MAP(CLink_listsView)
ON_COMMAND(ID_DEL, OnDel)
ON_COMMAND(ID_INSERT, OnInsert)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLink_listsView construction/destruction
CLink_listsView::CLink_listsView()
{
// TODO: add construction code here
head->next= tail ;
}
CLink_listsView::~CLink_listsView()
{
}
BOOL CLink_listsView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CLink_listsView drawing
void CLink_listsView::OnDraw(CDC* pDC)
{
CLink_listsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int pic_x=40;
int pic_y=50;
int text_x=40;
int text_y=150;
int SN_x=40;
int SN_y=30;
CString SN;
Node* temp = head;
pDC->TextOut(0,SN_y,"序号:");
pDC->TextOut(0,text_y,"图片名:") ;
for(int i=0;i<total;i++)
{
temp = temp->next ;
path = temp->Path ;
CDib dib ;
if(!dib.Load(temp->Path))
{
MessageBox("图片读取出错","ERROR",MB_OK|MB_ICONWARNING);
exit(0);
}
dib.Draw(pDC,pic_x,pic_y,-1,-1);
text_x = pic_x + 50 ;
SN_x = text_x ;
pic_x += 150 ;
SN.Format("%d",i+1);
pDC->TextOut(text_x , text_y , temp->name );
pDC->TextOut(SN_x , SN_y , SN );
//图片显示
/*CDC dcComp ;
dcComp.CreateCompatibleDC(pDC) ;
BITMAP bmInfo ;
CBitmap bitmap ;
HBITMAP hbitmap = (HBITMAP) ::LoadImage( NULL , "F:/001.bmp"/*path *///, IMAGE_BITMAP , 0 , 0 , LR_LOADFROMFILE) ;
/* bitmap.Attach(hbitmap) ;
dcComp.SelectObject(&bitmap) ;
bitmap.GetObject(sizeof(bmInfo) , &bmInfo) ;
pDC->BitBlt(pic_x , pic_y , bmInfo.bmWidth , bmInfo.bmHeight , &dcComp , 0 , 0 , SRCCOPY) ;
text_y = (bmInfo.bmHeight + 20);
text_x = pic_x + (bmInfo.bmWidth)/2 ;
pic_x += (bmInfo.bmWidth+20);
pDC->TextOut(text_x , text_y , temp->name );
pDC->TextOut(0,0,path);*/
}
}
/////////////////////////////////////////////////////////////////////////////
// CLink_listsView printing
BOOL CLink_listsView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CLink_listsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CLink_listsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CLink_listsView diagnostics
#ifdef _DEBUG
void CLink_listsView::AssertValid() const
{
CView::AssertValid();
}
void CLink_listsView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CLink_listsDoc* CLink_listsView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLink_listsDoc)));
return (CLink_listsDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLink_listsView message handlers
void CLink_listsView::OnDel()
{
// TODO: Add your command handler code here
DEL dele ;
if(dele.DoModal()==IDOK)
{
del(dele.number);
Invalidate();
}
}
void CLink_listsView::OnInsert()
{
// TODO: Add your command handler code here
INSERT ins ;
if(ins.DoModal()==IDOK)
{
add(ins.Pic , ins.path , ins.name);
Invalidate();
}
}
void CLink_listsView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CView::OnMouseMove(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -