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

📄 applicat.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ------------- applicat.c ------------- */

#include "dflat.h"

static BOOL DisplayModified = FALSE;
DFWINDOW DfApplicationWindow;

extern DF_DBOX Display;
extern DF_DBOX Windows;

#ifdef INCLUDE_LOGGING
extern DF_DBOX Log;
#endif

#ifdef INCLUDE_SHELLDOS
static void ShellDOS(DFWINDOW);
#endif
static void DfCreateMenu(DFWINDOW);
static void CreateStatusBar(DFWINDOW);
static void SelectColors(DFWINDOW);

#ifdef INCLUDE_WINDOWOPTIONS
static void SelectTexture(void);
static void SelectBorder(DFWINDOW);
static void SelectTitle(DFWINDOW);
static void SelectStatusBar(DFWINDOW);
#endif

static DFWINDOW oldFocus;
#ifdef INCLUDE_MULTI_WINDOWS
static void CloseAll(DFWINDOW, int);
static void MoreWindows(DFWINDOW);
static void ChooseWindow(DFWINDOW, int);
static int WindowSel;
static char Menus[9][26] =
{
	"~1.                      ",
	"~2.                      ",
	"~3.                      ",
	"~4.                      ",
	"~5.                      ",
	"~6.                      ",
	"~7.                      ",
	"~8.                      ",
	"~9.                      "
};
#endif

/* --------------- DFM_CREATE_WINDOW Message -------------- */
static int CreateWindowMsg(DFWINDOW wnd)
{
	int rtn;

	DfApplicationWindow = wnd;
#ifdef INCLUDE_WINDOWOPTIONS
    if (DfCfg.Border)
        DfSetCheckBox(&Display, DF_ID_BORDER);
    if (DfCfg.Title)
        DfSetCheckBox(&Display, DF_ID_TITLE);
    if (DfCfg.StatusBar)
        DfSetCheckBox(&Display, DF_ID_STATUSBAR);
    if (DfCfg.Texture)
        DfSetCheckBox(&Display, DF_ID_TEXTURE);
#endif
    SelectColors(wnd);
#ifdef INCLUDE_WINDOWOPTIONS
    SelectBorder(wnd);
    SelectTitle(wnd);
    SelectStatusBar(wnd);
#endif
    rtn = DfBaseWndProc(DF_APPLICATION, wnd, DFM_CREATE_WINDOW, 0, 0);
    if (wnd->extension != NULL)
        DfCreateMenu(wnd);
    CreateStatusBar(wnd);
    return rtn;
}

/* --------- DFM_ADDSTATUS Message ---------- */
static void AddStatusMsg(DFWINDOW wnd, DF_PARAM p1)
{
    if (wnd->StatusBar != NULL)    {
        if (p1 && *(char *)p1)
            DfSendMessage(wnd->StatusBar, DFM_SETTEXT, p1, 0);
        else
            DfSendMessage(wnd->StatusBar, DFM_CLEARTEXT, 0, 0);
        DfSendMessage(wnd->StatusBar, DFM_PAINT, 0, 0);
    }
}

/* -------- DFM_SETFOCUS Message -------- */
static void SetFocusMsg(DFWINDOW wnd, BOOL p1)
{
    if (p1)
        DfSendMessage(DfInFocus, DFM_SETFOCUS, FALSE, 0);
    DfInFocus = p1 ? wnd : NULL;
	if (DfIsVisible(wnd))
	    DfSendMessage(wnd, DFM_BORDER, 0, 0);
	else
	    DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
}

/* ------- SIZE Message -------- */
static void SizeMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
{
    BOOL WasVisible;
    WasVisible = DfIsVisible(wnd);
    if (WasVisible)
        DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
    if (p1-DfGetLeft(wnd) < 30)
        p1 = DfGetLeft(wnd) + 30;
    DfBaseWndProc(DF_APPLICATION, wnd, DFM_DFM_SIZE, p1, p2);
    DfCreateMenu(wnd);
    CreateStatusBar(wnd);
    if (WasVisible)
        DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
}

/* ----------- DFM_KEYBOARD Message ------------ */
static int KeyboardMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
{
    if (DfWindowMoving || DfWindowSizing || (int) p1 == DF_F1)
        return DfBaseWndProc(DF_APPLICATION, wnd, DFM_KEYBOARD, p1, p2);
    switch ((int) p1)    {
        case DF_ALT_F4:
            DfPostMessage(wnd, DFM_CLOSE_WINDOW, 0, 0);
            return TRUE;
#ifdef INCLUDE_MULTI_WINDOWS
        case DF_ALT_F6:
            DfSetNextFocus();
            return TRUE;
#endif
        case DF_ALT_HYPHEN:
            DfBuildSystemMenu(wnd);
            return TRUE;
        default:
            break;
    }
    DfPostMessage(wnd->MenuBarWnd, DFM_KEYBOARD, p1, p2);
    return TRUE;
}

/* --------- DFM_SHIFT_CHANGED Message -------- */
static void ShiftChangedMsg(DFWINDOW wnd, DF_PARAM p1)
{
	extern BOOL AltDown;
    if ((int)p1 & DF_ALTKEY)
        AltDown = TRUE;
    else if (AltDown)    {
        AltDown = FALSE;
        if (wnd->MenuBarWnd != DfInFocus)
            DfSendMessage(NULL, DFM_HIDE_CURSOR, 0, 0);
        DfSendMessage(wnd->MenuBarWnd, DFM_KEYBOARD, DF_F10, 0);
    }
}

/* -------- COMMAND Message ------- */
static void CommandMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
{
    switch ((int)p1)    {
        case DF_ID_HELP:
            DfDisplayHelp(wnd, DFlatApplication);
            break;
        case DF_ID_HELPHELP:
            DfDisplayHelp(wnd, "HelpHelp");
            break;
        case DF_ID_EXTHELP:
            DfDisplayHelp(wnd, "ExtHelp");
            break;
        case DF_ID_KEYSHELP:
            DfDisplayHelp(wnd, "KeysHelp");
            break;
        case DF_ID_HELPINDEX:
            DfDisplayHelp(wnd, "HelpIndex");
            break;
#ifdef TESTING_DFLAT
        case DF_ID_LOADHELP:
            DfLoadHelpFile();
            break;
#endif
#ifdef INCLUDE_LOGGING
        case DF_ID_LOG:
            DfMessageLog(wnd);
            break;
#endif
#ifdef INCLUDE_SHELLDOS
        case DF_ID_DOS:
            ShellDOS(wnd);
            break;
#endif
        case DF_ID_EXIT:
        case DF_ID_SYSCLOSE:
            DfPostMessage(wnd, DFM_CLOSE_WINDOW, 0, 0);
            break;
        case DF_ID_DISPLAY:
            if (DfDialogBox(wnd, &Display, TRUE, NULL))    {
				if (DfInFocus == wnd->MenuBarWnd || DfInFocus == wnd->StatusBar)
					oldFocus = DfApplicationWindow;
				else
					oldFocus = DfInFocus;
                DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
                SelectColors(wnd);
#ifdef INCLUDE_WINDOWOPTIONS
                SelectBorder(wnd);
                SelectTitle(wnd);
                SelectStatusBar(wnd);
                SelectTexture();
#endif
                DfCreateMenu(wnd);
                CreateStatusBar(wnd);
                DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
			    DfSendMessage(oldFocus, DFM_SETFOCUS, TRUE, 0);
            }
            break;
        case DF_ID_SAVEOPTIONS:
            DfSaveConfig();
            break;
#ifdef INCLUDE_MULTI_WINDOWS
        case DF_ID_WINDOW:
            ChooseWindow(wnd, (int)p2-2);
            break;
        case DF_ID_CLOSEALL:
            CloseAll(wnd, FALSE);
            break;
        case DF_ID_MOREWINDOWS:
            MoreWindows(wnd);
            break;
#endif
#ifdef INCLUDE_RESTORE
        case DF_ID_SYSRESTORE:
#endif
        case DF_ID_SYSMOVE:
        case DF_ID_SYSSIZE:
#ifdef INCLUDE_MINIMIZE
        case DF_ID_SYSMINIMIZE:
#endif
#ifdef INCLUDE_MAXIMIZE
        case DF_ID_SYSMAXIMIZE:
#endif
            DfBaseWndProc(DF_APPLICATION, wnd, DFM_COMMAND, p1, p2);
            break;
        default:
            if (DfInFocus != wnd->MenuBarWnd && DfInFocus != wnd)
                DfPostMessage(DfInFocus, DFM_COMMAND, p1, p2);
            break;
    }
}

/* --------- DFM_CLOSE_WINDOW Message -------- */
static int CloseWindowMsg(DFWINDOW wnd)
{
    int rtn;
#ifdef INCLUDE_MULTI_WINDOWS
    CloseAll(wnd, TRUE);
	WindowSel = 0;
#endif
    DfPostMessage(NULL, DFM_STOP, 0, 0);
    rtn = DfBaseWndProc(DF_APPLICATION, wnd, DFM_CLOSE_WINDOW, 0, 0);
    DfUnLoadHelpFile();
	DisplayModified = FALSE;
	DfApplicationWindow = NULL;
    return rtn;
}

/* --- DF_APPLICATION Window Class window processing module --- */
int DfApplicationProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
{
    switch (msg)
    {
        case DFM_CREATE_WINDOW:
            return CreateWindowMsg(wnd);
        case DFM_HIDE_WINDOW:
            if (wnd == DfInFocus)
                DfInFocus = NULL;
            break;
        case DFM_ADDSTATUS:
            AddStatusMsg(wnd, p1);
            return TRUE;
        case DFM_SETFOCUS:
            if ((int)p1 == (DfInFocus != wnd))    {
                SetFocusMsg(wnd, (BOOL) p1);
                return TRUE;
            }
            break;
        case DFM_DFM_SIZE:
            SizeMsg(wnd, p1, p2);
            return TRUE;
#ifdef INCLUDE_MINIMIZE
        case DFM_MINIMIZE:
            return TRUE;
#endif
        case DFM_KEYBOARD:
            return KeyboardMsg(wnd, p1, p2);
        case DFM_SHIFT_CHANGED:
            ShiftChangedMsg(wnd, p1);
            return TRUE;
        case DFM_PAINT:
            if (DfIsVisible(wnd))    {
#ifdef INCLUDE_WINDOWOPTIONS
                int cl = DfCfg.Texture ? DF_APPLCHAR : ' ';
#else
                int cl = DF_APPLCHAR;
#endif
                DfClearWindow(wnd, (DFRECT *)p1, cl);
            }
            return TRUE;
        case DFM_COMMAND:
            CommandMsg(wnd, p1, p2);
            return TRUE;
        case DFM_CLOSE_WINDOW:
            return CloseWindowMsg(wnd);
        default:
            break;

⌨️ 快捷键说明

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