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

📄 opensave.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
#include <precomp.h>

static OPENFILENAME ofn;

/*
 * Initialize file open / save structure
 */
VOID FileInitialize(HWND hwnd)
{
    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize   = sizeof(OPENFILENAME);
    ofn.hwndOwner     = hwnd;
    ofn.nMaxFile      = MAX_PATH;
    ofn.nMaxFileTitle = MAX_PATH;
    ofn.lpstrDefExt   = _T("bmp");
}


static BOOL
DoWriteFile(LPCTSTR pszFileName)
{
    return TRUE;
}


BOOL
DoOpenFile(HWND hwnd,
           LPTSTR szFileName,
           LPTSTR szTitleName)
{
    DWORD err;
    /*static TCHAR Filter[] = _T("All image files (*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png)\0*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png\0") \
                            _T("All files (*.*)\0*.*\0") \
                            _T("Graphics Interchange format (*gif)\0*.gif\0") \
                            _T("Windows Bitmap (*bmp)\0*.bmp\0") \
                            _T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \
                            _T("TAG Image File Format (*tif)\0*.tif\0") \
                            _T("Portable Network Graphics (*png)\0*.png\0\0");*/

    static TCHAR Filter[] = _T("Windows Bitmap (*.bmp)\0*.bmp\0");

    ofn.lpstrFilter = Filter;
    ofn.lpstrFile = szFileName;
    ofn.lpstrFileTitle = szTitleName;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;

    if (GetOpenFileName(&ofn))
    {
        return TRUE;
    }

    err = CommDlgExtendedError();

    if (err != CDERR_GENERALCODES)
        MessageBox(NULL, _T("Open file failed"), NULL, 0);

    return FALSE;
}



BOOL
DoSaveFile(HWND hwnd)
{
    TCHAR szFileName[MAX_PATH] = _T("");
    static TCHAR Filter[] = _T("Graphics Interchange format (*gif)\0*.gif\0") \
                            _T("Windows Bitmap (*bmp)\0*.bmp\0") \
                            _T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \
                            _T("TAG Image File Format (*tif)\0*.tif\0") \
                            _T("Portable Network Graphics (*png)\0*.png\0\0");

    ofn.lpstrFilter = Filter;
    ofn.lpstrFile = szFileName;
    ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;

    if (GetSaveFileName(&ofn))
    {
        if (DoWriteFile(szFileName))
            return TRUE;
    }

    if (CommDlgExtendedError() != CDERR_GENERALCODES)
        MessageBox(NULL, _T("Save to file failed"), NULL, 0);

    return FALSE;
}

⌨️ 快捷键说明

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