⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.cpp

📁 CAD转换工具 CAD转换工具 CAD转换工具 CAD转换工具
💻 CPP
字号:
// Window.cpp: implementation of the CWindow class.
//
//////////////////////////////////////////////////////////////////////
#include "Window.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CWindow::CWindow(LPSTR szClassName, WNDPROC WndProc, HINSTANCE hInst,
                 HICON hIcon, HCURSOR hCursor, LPSTR lpszMenuName,
                 HBRUSH color, UINT style)
{
    WndClass.lpszClassName = szClassName;
    WndClass.lpfnWndProc = WndProc;
    WndClass.hInstance = hInst;
    WndClass.hIcon = hIcon;
    WndClass.hCursor = hCursor;
    WndClass.lpszMenuName = lpszMenuName;
    WndClass.hbrBackground = color;
    WndClass.style = style;
    WndClass.cbClsExtra = 0;
    WndClass.cbWndExtra = 0;	

    RegisterClass(&WndClass);
}

CWindow::~CWindow()
{
	ReleaseDC(this->hWnd, this->hMainWndDC);
}

HWND CWindow::Create(LPSTR lpWindowName,DWORD dwStyle,
                     int x,int y,int nWidth,int nHeight,
                       HMENU hMenu,LPVOID lpParam)
{
	this->nHeight = nHeight;
	this->nWidth = nWidth;
	hWnd = CreateWindow(WndClass.lpszClassName, lpWindowName, dwStyle,
		x, y, nWidth, nHeight, NULL, hMenu, WndClass.hInstance, lpParam);	
	hMainWndDC = GetDC(hWnd);
	return hWnd;
}

int CWindow::GetFile(HWND hwnd, char *fname, char *filter, bool Open)
{
	OPENFILENAME fn;

	memset(&fn, 0, sizeof(OPENFILENAME));
	fn.lStructSize = sizeof(tagOFNA);
	fn.hwndOwner = hwnd;
	fn.hInstance = WndClass.hInstance;
	if (!Open) fn.lpstrDefExt = "jpg";
	fn.lpstrFilter = filter;
	fn.nFilterIndex = 1;
	fn.lpstrFile = (LPSTR)fname;
	fn.nMaxFile = 256;
	fn.nMaxFileTitle = 1;
	fn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;

	if (Open) 
		return GetOpenFileName(&fn);
	else
		return GetSaveFileName(&fn);

}

void CWindow::RePaint()
{
	RECT rect;
	GetClientRect(hWnd, &rect);
	InvalidateRect(hWnd, &rect, FALSE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -