www.pudn.com > dwg.rar > MainFrm.cpp


// MainFrm.cpp : implementation of the CMainFrame class 
// 
 
#include "stdafx.h" 
#include "dwgmfc.h" 
 
#include "MainFrm.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame 
 
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) 
 
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 
	//{{AFX_MSG_MAP(CMainFrame) 
	ON_WM_CREATE() 
	ON_COMMAND(ID_DWG, OnDwg) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
static UINT indicators[] = 
{ 
	ID_SEPARATOR,           // status line indicator 
	ID_INDICATOR_CAPS, 
	ID_INDICATOR_NUM, 
	ID_INDICATOR_SCRL, 
}; 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame construction/destruction 
 
CMainFrame::CMainFrame() 
{ 
	// TODO: add member initialization code here 
	 
} 
 
CMainFrame::~CMainFrame() 
{ 
} 
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP 
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || 
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) 
	{ 
		TRACE0("Failed to create toolbar\n"); 
		return -1;      // fail to create 
	} 
 
	if (!m_wndStatusBar.Create(this) || 
		!m_wndStatusBar.SetIndicators(indicators, 
		  sizeof(indicators)/sizeof(UINT))) 
	{ 
		TRACE0("Failed to create status bar\n"); 
		return -1;      // fail to create 
	} 
 
	// TODO: Delete these three lines if you don't want the toolbar to 
	//  be dockable 
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 
	EnableDocking(CBRS_ALIGN_ANY); 
	DockControlBar(&m_wndToolBar); 
 
	return 0; 
} 
 
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	if( !CFrameWnd::PreCreateWindow(cs) ) 
		return FALSE; 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return TRUE; 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame diagnostics 
 
#ifdef _DEBUG 
void CMainFrame::AssertValid() const 
{ 
	CFrameWnd::AssertValid(); 
} 
 
void CMainFrame::Dump(CDumpContext& dc) const 
{ 
	CFrameWnd::Dump(dc); 
} 
 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame message handlers 
//                                DWG.dll测试代码 
///****************************************************************************** 
///****************************************************************************** 
 
void CMainFrame::OnDwg()  
{ 
	// TODO: Add your command handler code here 
 
  #include "dwg.h" 
	 
  char *t="c:\\aaabbb"; 
  
  int n=startdwg(t); 
  if (n==-1){ 
	 AfxMessageBox("不能创建DWG文件,\n请检查此文件是否已打开"); 
	  return; 
  } 
 
 
  setbaseXY(0.0,0.0); 
  setscale(1.0); 
  settextstyle(HZ_CMPLX); 
 
  setlayer("1",Red,HIDDEN); 
  wsolid(100.0,200.0, 200.0,200., 100.0,100.0, 200.0,100.0); 
  w3dface(100.0,200.0, 200.0,200.0, 200.0,100.0,100.0,100.00); 
 
  npline(3,1.0,10.0,    20.0,20.,  100.0,20.0); 
  chgcolor(Blue); 
  chgltype(DOT); 
  wline(1.0,1.0,400.0,402.0); 
 
  chgcolor(Yellow); 
  chgltype(CONTINUOUS); 
 
  ppolygon(4, 25.,10., 584.,10., 584.,410., 25.,410.); 
  colorbylayer(); 
  wcircle(150.0,100.0,40.); 
  wline(0.0,420.0,420.0,0.0); 
  settexthigh(25); 
  settextobliq(15); 
  wtext(10.0,10.0,"aasdsfdsffs"); 
  settextstyle(HZ_ROMS); 
  wtext(50.0,50.0,"kjhgjksfjksgfjsf"); 
  settextrotang(30.0); 
 
  setlayer("zz",Green,HIDDEN); 
  wtext(10.0,10.0,"abcdefa地械棋"); 
 
  setlayer("qq",2,CONTINUOUS); 
  warc(10.0,10.0,50.0,11.0,125.0); 
 
  wpline(0); 
  wvertex(1.5,21.5,1); 
  wvertex(20.4,12.5,1); 
  wvertex(13.7,55.456,0); 
  wvertex(81.5,111.5,1); 
  wvertex(120.4,90.4,1); 
  wseqend(); 
 
  setlayer("ss",1,CONTINUOUS); 
  wline(10.0,10.0,80.0,45.0); 
  wdoughnut(50.0,50.0,10.0,20.0); 
  wdoughnut(80.0,50.0,0.0,30.0); 
 
  setplinew(5.2,5.2); 
 
  wpline(1); 
  setplinew(-1.0,-1.0); 
  wvertex(11.5,11.5,1); 
  wvertex(30.4,32.5,1); 
  wvertex(43.7,25.456,0); 
  wvertex(21.5,11.5,0); 
  wseqend(); 
 
  setlayer("11",Blue,CONTINUOUS); 
  wline(0.0,15.0,100.0,15.0); 
 
  cltextset(); 
  settextstyle(HZ_ROMS); 
  settexthigh( 50); 
 
  wtext(0,200,"DWG图形文件生成函数,作者:朱群."); 
 
 
  wrect(0,0,594,420); 
 
 
  enddwg(); 
  AfxMessageBox("c:\\aaabbb.DWG已生成"); 
  return ; 
	// TODO: Add your control notification handler code here 
	 
	 
}