xiaohuaban.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 66KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 38
    下载次数
  • 2005-07-20 01:14
    上传日期
一个用vc做的小画板,简单适用,便于学习,希望能给大家带来帮助
xiaohuaban.rar
  • 复件 (2) Project_Drawer
  • Project_Drawer.dep
    307B
  • Drawer.h
    406B
  • bitmap.bmp
    2.7KB
  • Project_Drawer.mak
    5.4KB
  • toolbar1.bmp
    2.6KB
  • Thumbs.db
    28.5KB
  • Project_Drawer.opt
    54.5KB
  • 新建文.htm
    70B
  • FileIO.h
    5.1KB
  • Project_Drawer.rc
    8.1KB
  • Project_Drawer.dsw
    553B
  • bitmap2.bmp
    106KB
  • larrow.cur
    766B
  • Drawer.cpp
    19KB
  • Project_Drawer.ncb
    57KB
  • FontSetting.h
    1.4KB
  • hnodrop.cur
    766B
  • Project_Drawer.dsp
    4.7KB
  • Project_Drawer.aps
    150.2KB
  • Project_Drawer.plg
    1.3KB
  • 00.bmp
    106KB
  • resource.h
    4.5KB
  • Hearts.ico
    2.2KB
  • www.pudn.com.txt
    218B
内容介绍
#include "Drawer.h" static HPEN hPen[6]; static HBRUSH hbrush[6]; static COLORREF col[6]; static int width = 0; static int psstyle; #define WM_STATUSBAR 60 static OPENFILENAME ofn; typedef struct { POINT begin; POINT end; int width; COLORREF color; int psstyle; int Kind; }shape; static vector<shape> shapes; static list<shape> stacks; static TCHAR szStatus[] = TEXT("就绪"); static TCHAR szFileName[MAX_PATH], szTitleName[MAX_PATH] ; static TCHAR szFilter[] = TEXT ("Text Files (*.00)\0*.00\0")\ TEXT ("All Files (*.*)\0*.*\0\0") ; LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); HINSTANCE g_hInstance = NULL; HINSTANCE hInst; //HWND hStatusWnd; int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR IpCmdLine,int nCmdShow) { static TCHAR szAppName[] = TEXT("HelloWin"); HWND hwnd; MSG msg; WNDCLASS wndclass; g_hInstance = hInstance; hInst = hInstance; HACCEL hAccel; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon (hInstance,(LPCTSTR)IDI_HEART); wndclass.hCursor = LoadCursor (hInstance,(LPCTSTR)IDC_HAND); wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wndclass.lpszMenuName = (LPCTSTR)IDR_MENU; wndclass.lpszClassName =szAppName; if (!RegisterClass (&wndclass)) { MessageBox(NULL,TEXT("Wrong"),TEXT("WARNING"),MB_ICONERROR); return 0; } hwnd = CreateWindow (szAppName, TEXT ("简易小画板---高文涛"), WS_OVERLAPPEDWINDOW, 200, 110, 650, 500, NULL, NULL, hInstance, NULL); hAccel = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR)); ShowWindow (hwnd,nCmdShow); UpdateWindow (hwnd); while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; } void DrawBitmap(HDC hdc,int xStart,int yStart,HBITMAP hBitmap) { BITMAP bm; HDC hMemDC; POINT pt; hMemDC=CreateCompatibleDC(hdc); SelectObject(hMemDC,hBitmap); GetObject(hBitmap,sizeof(BITMAP),&bm); pt.x=bm.bmWidth; pt.y=bm.bmHeight; BitBlt(hdc,xStart,yStart,pt.x,pt.y,hMemDC,0,0,SRCCOPY); DeleteDC(hMemDC); } double Distance(POINT pt,POINT line1,POINT line2) { double s1,s2,s3,s,d; s1 = sqrt((double) (line1.x - pt.x)*(line1.x - pt.x) +(line1.y - pt.y)*(line1.y - pt.y)); s2 = sqrt((double) (line2.x - pt.x)*(line2.y - pt.x) +(line2.y- pt.y)*(line2.y - pt.y)); s3 = sqrt((double) (line1.x - line2.x)*(line1.x - line2.x) +(line1.y - line2.y)*(line1.y - line2.y)); s = (s1 + s2 + s3) / 2; return d = sqrt( s*(s-s1)*(s-s2)*(s-s3) / s3 ); } LRESULT CALLBACK WndProc (HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) { HDC hdc; HPEN hpen; HBRUSH hBr; PAINTSTRUCT ps; HWND hToolsWindow; HBITMAP hBitmap; RECT rect; GetClientRect(hwnd,&rect); LPNMTTDISPINFO TTtext; static HWND hwndEdit; static HINSTANCE hInstance; static int cxChar,cxCaps,cyChar,cxClient, cyClient; static int count=0,st = 0; static int flag; static bPress = 0; static BOOL FD = false,SX = false,SAVED = TRUE,bKEY = FALSE,choose = FALSE; static POINT begin,end,pchoose; static DWORD dwCharSet = DEFAULT_CHARSET ; static BOOL curf = false; static HDC hdcmem; static HBITMAP hmap; static HPEN Hpen; static CHOOSECOLOR cc; static COLORREF crCustColors[16]; static shape pb,pstack; static double dis; static int i,j; int iReturn; cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hwnd; cc.hInstance = NULL; cc.rgbResult = RGB(0x80,0x80,0x80); cc.lpCustColors = crCustColors; cc.Flags = CC_RGBINIT |CC_FULLOPEN; cc.lCustData = 0; cc.lpfnHook = NULL; cc.lpTemplateName = NULL; ofn.lStructSize = sizeof (OPENFILENAME) ; ofn.hwndOwner = hwnd ; ofn.hInstance = NULL ; ofn.lpstrFilter = szFilter ; ofn.lpstrCustomFilter = NULL ; ofn.nMaxCustFilter = 0 ; ofn.nFilterIndex = 0 ; ofn.lpstrFile = szFileName ; // Set in Open and Close functions ofn.nMaxFile = MAX_PATH ; ofn.lpstrFileTitle = szTitleName ; // Set in Open and Close functions ofn.nMaxFileTitle = MAX_PATH ; ofn.lpstrInitialDir = NULL ; ofn.lpstrTitle = NULL ; ofn.Flags = 0 ; // Set in Open and Close functions ofn.nFileOffset = 0 ; ofn.nFileExtension = 0 ; ofn.lpstrDefExt = TEXT ("00") ; ofn.lCustData = 0L ; ofn.lpfnHook = NULL ; ofn.lpTemplateName = NULL ; switch (message) { //////////////////////////// case WM_CREATE: //////////////////////////////////////// case WM_CREATE: { ////////////////////////////////// 起始屏 ///////////////////////////////////////// hInstance=(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE); hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL); hBitmap=LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BITMAP1)); DrawBitmap(hdc,320,230,hBitmap); DeleteDC(hdc); Sleep(1500); ///////////////////////////// 创建工具条 /////////////////////////////////// TBBUTTON ColorToolBar[21]; for (i = 0; i < 21; i ++) { ColorToolBar[i].iBitmap = i; ColorToolBar[i].idCommand = i; ColorToolBar[i].fsState = TBSTATE_ENABLED; ColorToolBar[i].fsStyle = TBSTYLE_CHECKGROUP; ColorToolBar[i].dwData = 0; ColorToolBar[i].iString = 0; } ColorToolBar[0].fsStyle = TBSTYLE_BUTTON; ColorToolBar[1].fsStyle = TBSTYLE_BUTTON; ColorToolBar[2].fsStyle = TBSTYLE_BUTTON; ColorToolBar[3].fsStyle = TBSTYLE_BUTTON; ColorToolBar[4].fsStyle = TBSTYLE_BUTTON; ColorToolBar[5].fsStyle = TBSTYLE_BUTTON; ColorToolBar[6].fsStyle = TBSTYLE_BUTTON; ColorToolBar[7].fsStyle = TBSTYLE_BUTTON; ColorToolBar[13].fsStyle = TBSTYLE_BUTTON; ColorToolBar[14].fsStyle = TBSTYLE_BUTTON; ColorToolBar[20].fsStyle = TBSTYLE_BUTTON; hToolsWindow=::CreateToolbarEx( hwnd, WS_VISIBLE|CCS_ADJUSTABLE|TBSTYLE_WRAPABLE |TBSTYLE_TOOLTIPS, IDR_TOOLBAR, 22, g_hInstance, IDR_COLORTOOLBAR, ColorToolBar, 21, 16, 16, 16, 16, sizeof(TBBUTTON)); TBADDBITMAP ToolBarBitmap; ToolBarBitmap.hInst = g_hInstance; ToolBarBitmap.nID = IDR_COLORTOOLBAR; ::SendMessage(hToolsWindow,TB_ADDBITMAP,(WPARAM)3,(LPARAM)&ToolBarBitmap); //////////////////////////////// 创建状态栏//////////////////////////////////////////// /*hStatusWnd = CreateStatusWindow( WS_CHILD | WS_VISIBLE, szStatus, hwnd, WM_STATUSBAR );*/ } return 0; ///////////////////////////// case WM_COMMAND: //////////////////////////////// case WM_COMMAND: bPress = wParam; hdc = GetDC(hwnd); switch(wParam) { case IDM_FILE_NEW: case 0: if(SAVED == FALSE) iReturn = MessageBox(hwnd,TEXT("文档没有保存,保存吗?"),TEXT("提示"), MB_YESNOCANCEL|MB_APPLMODAL|MB_ICONQUESTION); if(iReturn == IDYES) { SendMessage (hwnd, WM_COMMAND, 2, 0); return 0; } if(iReturn == IDNO) { shapes.clear(); InvalidateRect(hwnd,NULL,true); SAVED = TRUE; } if(iReturn == IDCANCEL) return 0; break; case IDM_FILE_OPEN: case 1: { DWORD dwByteRead; HANDLE hFile; shape temp; ofn.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT ; iReturn = GetOpenFileName (&ofn) ; if(iReturn == TRUE) { hFile=CreateFile(ofn.lpstrFile,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,NULL); shapes.clear(); while(ReadFile
评论
    相关推荐
    • MVC 画板通信
      MVC 画板通信
    • 仿windows的画板
      Visual Studio 2005(MFC)仿windows系统自带的画板,在其基础上有添加了一些功能,如复制粘贴移动等。
    • windows画板
      使用MFC开发的windows平台的画板,实现基本功能无误。
    • 模拟windows画板
      模拟windows的画板,绘图,选择颜色,缩放,还支持矢量图(可以选中某个图形进行删除),还利用sengmessage进行进程间的同步通信,等功能
    • windows画板程序
      利用windows原生API开发的画板程序源代码
    • C++ 画板工具
      用C++编写的画图工具,类似于Window的画板,可以画圆,方形等各种几何图形,和选择颜色,还有保存,修改,删除功能。
    • MFC简易画板
      用VC开发工具编写的MFC简易画板,可以实现类似与windows自带画板的一些功能
    • MFC简单画板
      本人用C++简单做了个画板,里面还有很多问题待解决,传到网上交流交流!
    • Windows小画板
      用C++实现的Windows小画板,包含源码,文档说明,是个很不错的例子~
    • MFC 画板
      MFC 画板