• 大小: 67.8MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-01-15
  • 语言: 其他
  • 标签: Dev-Cpp  

资源简介

蓝桥杯比赛提供的5.4.0免安装版本

资源截图

代码片段和文件信息

#include 
#include “Main.h“

#define IDC_MAIN_TEXT 1001

BOOL LoadFile(HWND hEdit LPSTR pszFileName) {
HANDLE hFile;
BOOL bSuccess = FALSE;

hFile = CreateFile(pszFileName GENERIC_READ FILE_SHARE_READ NULL OPEN_EXISTING 0 0);
if(hFile != INVALID_HANDLE_VALUE) {
DWORD dwFileSize;
dwFileSize = GetFileSize(hFile NULL);
if(dwFileSize != 0xFFFFFFFF) {
LPSTR pszFileText;
pszFileText = (LPSTR)GlobalAlloc(GPTR dwFileSize + 1);
if(pszFileText != NULL) {
DWORD dwRead;
if(ReadFile(hFile pszFileText dwFileSize &dwRead NULL)) {
pszFileText[dwFileSize] = 0; // Null terminator
if(SetWindowText(hEdit pszFileText))
bSuccess = TRUE; // It worked!
}
GlobalFree(pszFileText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}

BOOL SaveFile(HWND hEdit LPSTR pszFileName) {
HANDLE hFile;
BOOL bSuccess = FALSE;

hFile = CreateFile(pszFileName GENERIC_WRITE 0 0 CREATE_ALWAYS FILE_ATTRIBUTE_NORMAL 0);
if(hFile != INVALID_HANDLE_VALUE) {
DWORD dwTextLength;
dwTextLength = GetWindowTextLength(hEdit);
if(dwTextLength > 0) {
LPSTR pszText;
pszText = (LPSTR)GlobalAlloc(GPTR dwTextLength + 1);
if(pszText != NULL) {
if(GetWindowText(hEdit pszText dwTextLength + 1)) {
DWORD dwWritten;
if(WriteFile(hFile pszText dwTextLength &dwWritten NULL))
bSuccess = TRUE;
}
GlobalFree(pszText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}

BOOL DoFileOpenSave(HWND hwnd BOOL bSave) {
OPENFILENAME ofn;
char szFileName[MAX_PATH];

ZeroMemory(&ofn sizeof(ofn));
szFileName[0] = 0;

ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = “Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0“;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = “txt“;

if(bSave) {
ofn.Flags = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn)) {
if(!SaveFile(GetDlgItem(hwnd IDC_MAIN_TEXT) szFileName)) {
MessageBox(hwnd “Save file failed.“ “Error“MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
}
} else {
ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn)) {
if(!LoadFile(GetDlgItem(hwnd IDC_MAIN_TEXT) szFileName)) {
MessageBox(hwnd “Load of file failed.“ “Error“MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
}
}
return TRUE;
}

LRESULT CALLBACK WndProc(HWND hwnd UINT Message WPARAM wParam LPARAM lParam) {
switch(Message) {
case WM_CREATE:
CreateWindow(“EDIT“ ““WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_WANTRETURNCW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULThwnd (HMENU)IDC_MAIN_TEXT GetModuleHandle(NULL) NULL);
SendDlgItemMessage(hwnd IDC_MAIN_TEXT WM_SETFONT(WPARAM)GetStockobject(DEFAULT_GUI_FONT) MAKELPARAM(TRUE0));
break;
case WM_SIZE:
if(wParam != SIZE

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\
     文件       12800  2013-02-12 03:08  Dev-Cpp-5.4\ConsolePauser.exe
     文件       18581  2002-02-09 13:32  Dev-Cpp-5.4\copying.txt
     文件     4686336  2013-02-14 01:37  Dev-Cpp-5.4\devcpp.exe
     文件         695  2011-08-23 14:07  Dev-Cpp-5.4\devcpp.exe.manifest
     文件     1637915  2013-02-14 01:37  Dev-Cpp-5.4\devcpp.map
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\Examples\
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\Examples\FileEditor\
     文件        1272  2012-03-04 09:54  Dev-Cpp-5.4\Examples\FileEditor\FileEditor.dev
     文件        1126  2002-05-04 19:58  Dev-Cpp-5.4\Examples\FileEditor\FileEditor.ico
     文件        5030  2011-11-28 04:25  Dev-Cpp-5.4\Examples\FileEditor\Main.c
     文件         117  2002-05-04 19:57  Dev-Cpp-5.4\Examples\FileEditor\Main.h
     文件         261  2002-05-04 19:57  Dev-Cpp-5.4\Examples\FileEditor\Menu.rc
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\Examples\Hello\
     文件         440  2003-03-26 00:02  Dev-Cpp-5.4\Examples\Hello\Hello.cpp
     文件         293  2002-06-03 23:23  Dev-Cpp-5.4\Examples\Hello\Hello.dev
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\Examples\Jackpot\
     文件         289  2002-05-19 08:36  Dev-Cpp-5.4\Examples\Jackpot\Jackpot.dev
     文件        2413  2003-03-24 10:16  Dev-Cpp-5.4\Examples\Jackpot\main.cpp
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\Examples\MDIApp\
     文件        1161  2003-03-24 10:16  Dev-Cpp-5.4\Examples\MDIApp\MdiApp.dev
     文件          88  2002-06-03 23:36  Dev-Cpp-5.4\Examples\MDIApp\MdiApp.rc
     文件         738  2002-06-03 23:35  Dev-Cpp-5.4\Examples\MDIApp\mdi_res.rc
     文件       16548  2002-06-03 23:35  Dev-Cpp-5.4\Examples\MDIApp\mdi_unit.c
     文件         460  2002-06-03 23:36  Dev-Cpp-5.4\Examples\MDIApp\mdi_unit.h
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\Examples\OpenGL\
     文件        4043  2004-11-11 23:27  Dev-Cpp-5.4\Examples\OpenGL\Main.cpp
     文件         766  2004-11-11 23:27  Dev-Cpp-5.4\Examples\OpenGL\mainicon.ico
     文件        1045  2004-11-12 05:49  Dev-Cpp-5.4\Examples\OpenGL\OpenGL.dev
     目录           0  2018-02-10 01:25  Dev-Cpp-5.4\Examples\Simpwin\
     文件        3588  2002-06-03 23:43  Dev-Cpp-5.4\Examples\Simpwin\Main.cpp
............此处省略1639个文件信息

评论

共有 条评论