Начальная версия проекта.
- Создана структура меню в ресурсном файле. - Добавлены классы для создания окна и регистрации оконного класса.
This commit is contained in:
commit
4ab9bfee5b
91
src/DonNUEdgeDetector.rc
Normal file
91
src/DonNUEdgeDetector.rc
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Русский (Россия) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
|
||||||
|
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Menu
|
||||||
|
//
|
||||||
|
|
||||||
|
IDR_MENU1 MENU
|
||||||
|
BEGIN
|
||||||
|
POPUP "&Камера"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&Захват кадра\tF10", ID_SNAPSHOT
|
||||||
|
MENUITEM "У&стройство", ID_DEVICE
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Вы&ход\tAlt+F4", ID_EXIT
|
||||||
|
END
|
||||||
|
POPUP "&Вид"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&Робертс\t1", ID_OP_ROBERTS
|
||||||
|
MENUITEM "&Прюитт\t2", ID_OP_PREWITT
|
||||||
|
MENUITEM "&Собель\t3", ID_OP_SOBEL
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "&Оригинал\tCtrl+O", ID_EF_ORIGINAL
|
||||||
|
MENUITEM "О&ттенки серого\tCtrl+G", ID_EF_GRAYSCALE
|
||||||
|
MENUITEM "&Негатив\tCtrl+I", ID_EF_INVERSE
|
||||||
|
END
|
||||||
|
POPUP "&Справка"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&О программе", ID_ABOUT
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // Русский (Россия) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
85
src/Window.cpp
Normal file
85
src/Window.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include "Window.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Конструктор.
|
||||||
|
* Задаёт стиль и размеры окна по умочанию.
|
||||||
|
*/
|
||||||
|
Window::Window() {
|
||||||
|
x = CW_USEDEFAULT;
|
||||||
|
y = CW_USEDEFAULT;
|
||||||
|
w = CW_USEDEFAULT;
|
||||||
|
h = CW_USEDEFAULT;
|
||||||
|
style = WS_OVERLAPPEDWINDOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка класса окна.
|
||||||
|
*/
|
||||||
|
void Window::setClassName(LPCWSTR className) {
|
||||||
|
this->className = className;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение класса окна.
|
||||||
|
*/
|
||||||
|
LPCWSTR Window::getClassName() {
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка размера и положения окна.
|
||||||
|
*/
|
||||||
|
void Window::setBounds(int x, int y, int w, int h) {
|
||||||
|
this->x = x;
|
||||||
|
this->y = y;
|
||||||
|
this->w = w;
|
||||||
|
this->h = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка дескриптора приложения.
|
||||||
|
*/
|
||||||
|
void Window::setInstance(HINSTANCE hInstance) {
|
||||||
|
this->hInstance = hInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка стиля окна.
|
||||||
|
*/
|
||||||
|
void Window::setStyle(int style) {
|
||||||
|
this->style = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Задание заголовка окна.
|
||||||
|
*/
|
||||||
|
void Window::setTitle(LPCWSTR title) {
|
||||||
|
this->title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Создание окна.
|
||||||
|
* Вызывается после задания параметров.
|
||||||
|
* return true - окно успешно создано, false - произошла ошибка.
|
||||||
|
*/
|
||||||
|
bool Window::createWindow() {
|
||||||
|
hWnd = CreateWindow(
|
||||||
|
className, title, style,
|
||||||
|
x, y, w, h,
|
||||||
|
NULL, NULL,
|
||||||
|
hInstance, NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!hWnd) {
|
||||||
|
MessageBox(NULL, L"Cannot create window", L"Error", MB_OK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение дескриптора окна.
|
||||||
|
*/
|
||||||
|
HWND Window::getWindow() {
|
||||||
|
return this->hWnd;
|
||||||
|
}
|
33
src/Window.h
Normal file
33
src/Window.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include "WindowClass.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Класс создания окна
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
class Window {
|
||||||
|
public:
|
||||||
|
Window();
|
||||||
|
|
||||||
|
void setClassName(LPCWSTR className);
|
||||||
|
LPCWSTR getClassName();
|
||||||
|
|
||||||
|
void setBounds(int x, int y, int w, int h);
|
||||||
|
void setInstance(HINSTANCE hInstance);
|
||||||
|
void setStyle(int style);
|
||||||
|
void setTitle(LPCWSTR title);
|
||||||
|
|
||||||
|
bool createWindow();
|
||||||
|
HWND getWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
HWND hWnd;
|
||||||
|
HINSTANCE hInstance;
|
||||||
|
LPCWSTR title, className;
|
||||||
|
int x, y, w, h;
|
||||||
|
int style;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
111
src/WindowClass.cpp
Normal file
111
src/WindowClass.cpp
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
#include "WindowClass.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Конструктор.
|
||||||
|
* Задаёт параметры по умочанию.
|
||||||
|
*/
|
||||||
|
WindowClass::WindowClass() {
|
||||||
|
WndClass.cbClsExtra = 0;
|
||||||
|
WndClass.cbWndExtra = 0;
|
||||||
|
setToDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Регистрация класса окна.
|
||||||
|
* return true - класс зарегистрирован, false - произошла ошибка.
|
||||||
|
*/
|
||||||
|
bool WindowClass::registerClass() {
|
||||||
|
if(!RegisterClass(&WndClass)) {
|
||||||
|
MessageBox(NULL, L"Cannot register class", L"Error", MB_OK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Задать параметры по умочанию.
|
||||||
|
*/
|
||||||
|
void WindowClass::setToDefault() {
|
||||||
|
setStyle( CS_HREDRAW | CS_VREDRAW );
|
||||||
|
setIconType(IDI_APPLICATION);
|
||||||
|
setCursorType(IDC_ARROW);
|
||||||
|
setBackgroundBrushColor(WHITE_BRUSH);
|
||||||
|
setMenuName(L"MyMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка цвета кисти для фона окна.
|
||||||
|
*/
|
||||||
|
void WindowClass::setBackgroundBrushColor(int color) {
|
||||||
|
WndClass.hbrBackground = (HBRUSH) GetStockObject(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка имени класса.
|
||||||
|
*/
|
||||||
|
void WindowClass::setClassName(LPCWSTR className) {
|
||||||
|
WndClass.lpszClassName = className;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка курсора.
|
||||||
|
*/
|
||||||
|
void WindowClass::setCursor(HCURSOR hCursor) {
|
||||||
|
WndClass.hCursor = hCursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Загрузка и установка курсора по его типу.
|
||||||
|
*/
|
||||||
|
void WindowClass::setCursorType(LPCWSTR cursorType) {
|
||||||
|
setCursor( LoadCursor(NULL, cursorType) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка иконки.
|
||||||
|
*/
|
||||||
|
void WindowClass::setIcon(HICON hIcon) {
|
||||||
|
WndClass.hIcon = hIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Загрузка и установка иконки по её типу.
|
||||||
|
*/
|
||||||
|
void WindowClass::setIconType(LPCWSTR iconType) {
|
||||||
|
setIcon( LoadIcon(NULL, iconType) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка дескриптора приложения.
|
||||||
|
*/
|
||||||
|
void WindowClass::setInstance(HINSTANCE hInstance) {
|
||||||
|
WndClass.hInstance = hInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Задать имя меню.
|
||||||
|
*/
|
||||||
|
void WindowClass::setMenuName(LPCWSTR menuName) {
|
||||||
|
WndClass.lpszMenuName = menuName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка стиля.
|
||||||
|
*/
|
||||||
|
void WindowClass::setStyle(int style) {
|
||||||
|
WndClass.style = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Задание оконной процедуры.
|
||||||
|
*/
|
||||||
|
void WindowClass::setWindowProcedure(WNDPROC procedure) {
|
||||||
|
WndClass.lpfnWndProc = procedure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить имя класса.
|
||||||
|
*/
|
||||||
|
LPCWSTR WindowClass::getClassName() {
|
||||||
|
return WndClass.lpszClassName;
|
||||||
|
}
|
32
src/WindowClass.h
Normal file
32
src/WindowClass.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Класс регистрации WNDCLASS
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
class WindowClass {
|
||||||
|
public:
|
||||||
|
WindowClass();
|
||||||
|
|
||||||
|
bool registerClass();
|
||||||
|
|
||||||
|
void setToDefault();
|
||||||
|
void setBackgroundBrushColor(int color);
|
||||||
|
void setCursor(HCURSOR hCursor);
|
||||||
|
void setCursorType(LPCWSTR cursorType);
|
||||||
|
void setClassName(LPCWSTR className);
|
||||||
|
void setIcon(HICON hIcon);
|
||||||
|
void setIconType(LPCWSTR iconType);
|
||||||
|
void setInstance(HINSTANCE hInstance);
|
||||||
|
void setMenuName(LPCWSTR menuName);
|
||||||
|
void setStyle(int style);
|
||||||
|
void setWindowProcedure(WNDPROC procedure);
|
||||||
|
|
||||||
|
LPCWSTR getClassName();
|
||||||
|
|
||||||
|
private:
|
||||||
|
WNDCLASS WndClass;
|
||||||
|
};
|
||||||
|
|
37
src/resource.h
Normal file
37
src/resource.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by DonNUEdgeDetector.rc
|
||||||
|
//
|
||||||
|
#define IDR_MENU1 101
|
||||||
|
#define ID_40001 40001
|
||||||
|
#define ID_40002 40002
|
||||||
|
#define ID_40003 40003
|
||||||
|
#define ID_SNAPSHOT 40004
|
||||||
|
#define ID_EXIT 40005
|
||||||
|
#define ID_ABOUT 40006
|
||||||
|
#define ID_40007 40007
|
||||||
|
#define ID_40008 40008
|
||||||
|
#define ID_40009 40009
|
||||||
|
#define ID_OP_ROBERTS 40010
|
||||||
|
#define ID_OP_PREWITT 40011
|
||||||
|
#define ID_OP_SOBEL 40012
|
||||||
|
#define ID_40013 40013
|
||||||
|
#define ID_40014 40014
|
||||||
|
#define ID_40015 40015
|
||||||
|
#define ID_40016 40016
|
||||||
|
#define ID_DEVICE 40017
|
||||||
|
#define ID_EF_ORIGINAL 40018
|
||||||
|
#define ID_EF_GRAYSCALE 40019
|
||||||
|
#define ID_EF_NEGATIVE 40020
|
||||||
|
#define ID_EF_INVERSE 40021
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40022
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user