Простой графический редактор

Автор работы: Пользователь скрыл имя, 09 Января 2013 в 09:11, курсовая работа

Описание

Цель курсового проекта: получение навыков по разработке программы на языке C\C++ , с использованием WinAPI, для реализации пользовательского интерфейса, а также реализация простенького графического редактора.
Программный продукт написан на языке программирования С++. Реализация темы курсовой работ

Содержание

Введение 4
1. Анализ задания и постановка задач 5
2. Теоретическая часть 6
3. Проектирование программы 11
4. Реализация программы 12
5. Тестирование программы 14
Заключение 21
Литература 22

Работа состоит из  1 файл

ПЗ СПО.doc

— 1.06 Мб (Скачать документ)

ccColor.rgbResult = LOWORD(wParam) == ID_40011 ? crBrushColor : crBackColor;

ccColor.lpCustColors = &ccArray[0];

ccColor.Flags = CC_FULLOPEN | CC_RGBINIT | CC_ANYCOLOR;

ChooseColor(&ccColor);

if (LOWORD(wParam) == ID_40011)

{

crBrushColor = ccColor.rgbResult;

UpdateMenuBmp(bmpForeMenu, crBrushColor);

}

else

{

crBackColor = ccColor.rgbResult;

UpdateMenuBmp(bmpBackMenu, crBackColor);

}

return TRUE;

case ID_40016:

case ID_40017:

case ID_40018:

case ID_40019:

case ID_40020:

case ID_40021:

case ID_40022:

case ID_40023:

case ID_40024:

case ID_40025:

ClearChecks();

iPenWidth = LOWORD(wParam) - ID_40015 + 1;

CheckMenuItem(mnuMain, LOWORD(wParam), MF_CHECKED);

return TRUE;

case ID_40026:

iPenWidth = 15;

ClearChecks();

CheckMenuItem(mnuMain, LOWORD(wParam), MF_CHECKED);

return TRUE;

case ID_40027:

iPenWidth = 20;

ClearChecks();

CheckMenuItem(mnuMain, LOWORD(wParam), MF_CHECKED);

return TRUE;

case ID_40028:

iPenWidth = 30;

ClearChecks();

CheckMenuItem(mnuMain, LOWORD(wParam), MF_CHECKED);

return TRUE;

case ID_40031:

case ID_40032:

case ID_40033:

case ID_40034:

case ID_40035:

case ID_40036:

case ID_ACCELERATOR40048:

case ID_ACCELERATOR40049:

case ID_ACCELERATOR40050:

case ID_ACCELERATOR40051:

case ID_ACCELERATOR40052:

case ID_ACCELERATOR40053:

if (LOWORD(wParam) < ID_ACCELERATOR40048)

iTool = LOWORD(wParam) - ID_40031;

else

iTool = LOWORD(wParam) - ID_ACCELERATOR40048;

CheckMenuItem(mnuMain, ID_40031, MF_UNCHECKED);

CheckMenuItem(mnuMain, ID_40032, MF_UNCHECKED);

CheckMenuItem(mnuMain, ID_40033, MF_UNCHECKED);

CheckMenuItem(mnuMain, ID_40034, MF_UNCHECKED);

CheckMenuItem(mnuMain, ID_40035, MF_UNCHECKED);

CheckMenuItem(mnuMain, ID_40036, MF_UNCHECKED);

CheckMenuItem(mnuMain, iTool + ID_40031, MF_CHECKED);

return TRUE;

case ID_40041:

case ID_ACCELERATOR40054:

crTmp = crBackColor;

crBackColor = crBrushColor;

crBrushColor = crTmp;

UpdateMenuBmp(bmpForeMenu, crBrushColor);

UpdateMenuBmp(bmpBackMenu, crBackColor);

return TRUE;

case ID_40042:

case ID_ACCELERATOR40044:

BitBlt(dcRedo, 0, 0, CANVASWIDTH, CANVASHEIGHT, dcBack, 0, 0, SRCCOPY);

BitBlt(dcBack, 0, 0, CANVASWIDTH, CANVASHEIGHT, dcUndo, 0, 0, SRCCOPY);

BitBlt(dcUndo, 0, 0, CANVASWIDTH, CANVASHEIGHT, dcRedo, 0, 0, SRCCOPY);

InvalidateRect(GetDlgItem(hDlg, IDC_STATICPAINT), NULL, FALSE);

return TRUE;

}

return (FALSE);

case WM_DRAWITEM:

disItem = (LPDRAWITEMSTRUCT)lParam;

dcItemPaint = GetDC(GetDlgItem(hDlg, IDC_STATICPAINT));

BitBlt(dcItemPaint, disItem->rcItem.left, disItem->rcItem.top, disItem->rcItem.right - disItem->rcItem.left, disItem->rcItem.bottom - disItem->rcItem.top, dcBack, disItem->rcItem.left + px, disItem->rcItem.top + py, SRCCOPY);

ReleaseDC(GetDlgItem(hDlg, IDC_STATICPAINT), dcItemPaint);

break;

case WM_SIZE:

SetWindowPos(GetDlgItem(hDlg, IDC_STATICPAINT), NULL, 0, 0, LOWORD(lParam), HIWORD(lParam), SWP_NOMOVE);

GetClientRect(GetDlgItem(hDlg, IDC_STATICPAINT), &rcTmp);

 

sinfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_DISABLENOSCROLL;

GetScrollInfo(hDlg, SB_HORZ, &sinfo);

sinfo.nPage = 10;

sinfo.nMax = CANVASWIDTH - rcTmp.right;

if (sinfo.nPos > sinfo.nMax)

sinfo.nPos = sinfo.nMax;

SetScrollInfo(hDlg, SB_HORZ, &sinfo, TRUE);

SendMessage(hDlg, WM_HSCROLL, SB_THUMBPOSITION | sinfo.nPos << 16, NULL);

 

sinfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_DISABLENOSCROLL;

GetScrollInfo(hDlg, SB_VERT, &sinfo);

sinfo.nPage = 10;

sinfo.nMax = CANVASHEIGHT - rcTmp.bottom;

if (sinfo.nPos > sinfo.nMax)

sinfo.nPos = sinfo.nMax;

SetScrollInfo(hDlg, SB_VERT, &sinfo, TRUE);

SendMessage(hDlg, WM_VSCROLL, SB_THUMBPOSITION | sinfo.nPos << 16, NULL);

break;

}

return (FALSE);

}

 

int __stdcall WMain()

{

HWND hMain;

MSG msg;

InitCommonControls();

HACCEL hAccel = LoadAccelerators(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_ACCELERATOR1));

hMain = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGBAR), NULL, &DlgProc);

while (GetMessage(&msg, hMain, 0, 0) && IsWindow(hMain))

{

if (!IsWindow(hMain) || !IsDialogMessage(hMain, &msg))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

PeekMessage(&msg, GetDlgItem(hMain, IDC_STATICPAINT), 0, 0, PM_REMOVE);

TranslateAccelerator(hMain, hAccel, &msg);

}

return 0;

}

 

#ifndef NDEBUG

 

int __stdcall WinMain(__in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )

{

return WMain();

}

 

#endif

 

Paint.rc

 

// Microsoft Visual C++ generated resource script.

//

#include "resource.h"

 

#define APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 2 resource.

//

#include "afxres.h"

 

/////////////////////////////////////////////////////////////////////////////

#undef APSTUDIO_READONLY_SYMBOLS

 

/////////////////////////////////////////////////////////////////////////////

// Russian resources

 

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)

#ifdef _WIN32

LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT

#pragma code_page(1251)

#endif //_WIN32

 

#ifdef APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

// TEXTINCLUDE

//

 

1 TEXTINCLUDE

BEGIN

    "resource.h\0"

END

 

2 TEXTINCLUDE

BEGIN

    "#include ""afxres.h""\r\n"

    "\0"

END

 

3 TEXTINCLUDE

BEGIN

    "\r\n"

    "\0"

END

 

#endif    // APSTUDIO_INVOKED

 

 

/////////////////////////////////////////////////////////////////////////////

//

// Dialog

//

 

IDD_DIALOGBAR DIALOGEX 0, 0, 420, 258

STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE | WS_CAPTION | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU | WS_THICKFRAME

EXSTYLE WS_EX_APPWINDOW

CAPTION "MicroPaint"

MENU IDR_MENU1

FONT 8, "MS Shell Dlg", 0, 0, 0x0

BEGIN

    CONTROL         "",IDC_STATICPAINT,"Static",SS_OWNERDRAW,0,0,419,257

END

 

 

/////////////////////////////////////////////////////////////////////////////

//

// Menu

//

 

IDR_MENU1 MENU

BEGIN

    POPUP "Файл"

    BEGIN

        MENUITEM "Новый\tCtrl+N",               ID_40005

        MENUITEM SEPARATOR

        MENUITEM "Открыть\tCtrl+O",             ID_40006

        MENUITEM "Сохранить\tCtrl+S",           ID_40007

        MENUITEM "Сохранить как...",            ID_40008, GRAYED

        MENUITEM SEPARATOR

        MENUITEM "Выход\tAlt+X",                ID_40009

    END

    POPUP "Правка"

    BEGIN

        MENUITEM "Отмена\tCtrl+Z",              ID_40042

    END

    POPUP "Цвет"

    BEGIN

        MENUITEM "Кисти...",                    ID_40011

        MENUITEM SEPARATOR

        MENUITEM "Фона...",                     ID_40100

        MENUITEM SEPARATOR

        MENUITEM "Обменять\tShift+X",           ID_40041

    END

    POPUP "Толщина кисти"

    BEGIN

        MENUITEM "1",                           ID_40016

        MENUITEM "2",                           ID_40017

        MENUITEM "3",                           ID_40018

        MENUITEM "4",                           ID_40019

        MENUITEM "5",                           ID_40020

        MENUITEM "6",                           ID_40021

        MENUITEM "7",                           ID_40022

        MENUITEM "8",                           ID_40023

        MENUITEM "9",                           ID_40024

        MENUITEM "10",                          ID_40025

        MENUITEM "15",                          ID_40026

        MENUITEM "20",                          ID_40027

        MENUITEM "30",                          ID_40028

    END

    POPUP "Инструмент"

    BEGIN

        MENUITEM "Кисть\tCtrl+Q",               ID_40031

        MENUITEM "Прямоугольник\tCtrl+W",       ID_40032

        MENUITEM "Окружность\tCtrl+E",          ID_40033

        MENUITEM "Прямая\tCtrl+D",              ID_40034

        MENUITEM "Заливка\tCtrl+F",             ID_40035

        MENUITEM "Распылитель\tCtrl+R",         ID_40036

    END

    MENUITEM "О программе...",              ID_40010

END

 

 

/////////////////////////////////////////////////////////////////////////////

//

// Accelerator

//

 

IDR_ACCELERATOR1 ACCELERATORS

BEGIN

    "^Z",           ID_ACCELERATOR40044,    ASCII,  NOINVERT

    "^Q",           ID_ACCELERATOR40048,    ASCII,  NOINVERT

    "^W",           ID_ACCELERATOR40049,    ASCII,  NOINVERT

    "^E",           ID_ACCELERATOR40050,    ASCII,  NOINVERT

    "^D",           ID_ACCELERATOR40051,    ASCII,  NOINVERT

    "^F",           ID_ACCELERATOR40052,    ASCII,  NOINVERT

    "^R",           ID_ACCELERATOR40053,    ASCII,  NOINVERT

    "X",            ID_ACCELERATOR40054,    ASCII,  NOINVERT

    "^N",           ID_ACCELERATOR40055,    ASCII,  NOINVERT

    "^O",           ID_ACCELERATOR40056,    ASCII,  NOINVERT

    "^S",           ID_ACCELERATOR40057,    ASCII,  NOINVERT

    "x",            ID_ACCELERATOR40058,    ASCII,  ALT, NOINVERT

END

 

#endif    // Russian resources

/////////////////////////////////////////////////////////////////////////////

 

 

 

#ifndef APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 3 resource.

//

 

 

/////////////////////////////////////////////////////////////////////////////

#endif    // not APSTUDIO_INVOKED

 

 

 


Информация о работе Простой графический редактор