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

📄 applicat.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
📖 第 1 页 / 共 2 页
字号:
    }
    return DfBaseWndProc(DF_APPLICATION, wnd, msg, p1, p2);
}

#ifdef INCLUDE_SHELLDOS
static void SwitchCursor(void)
{
    DfSendMessage(NULL, DFM_SAVE_CURSOR, 0, 0);
    DfSwapCursorStack();
    DfSendMessage(NULL, DFM_RESTORE_CURSOR, 0, 0);
}

/* ------- Shell out to DOS ---------- */
static void ShellDOS(DFWINDOW wnd)
{
	oldFocus = DfInFocus;
    DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
    SwitchCursor();
    printf("To return to %s, execute the DOS exit command.",
                    DFlatApplication);
    fflush(stdout);
    _spawnl(P_WAIT, getenv("COMSPEC"), " ", NULL);
    SwitchCursor();
	DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
    DfSendMessage(oldFocus, DFM_SETFOCUS, TRUE, 0);
}
#endif

/* -------- Create the menu bar -------- */
static void DfCreateMenu(DFWINDOW wnd)
{
    DfAddAttribute(wnd, DF_HASMENUBAR);
    if (wnd->MenuBarWnd != NULL)
        DfSendMessage(wnd->MenuBarWnd, DFM_CLOSE_WINDOW, 0, 0);
    wnd->MenuBarWnd = DfDfCreateWindow(DF_MENUBAR,
                        NULL,
                        DfGetClientLeft(wnd),
                        DfGetClientTop(wnd)-1,
                        1,
                        DfClientWidth(wnd),
                        NULL,
                        wnd,
                        NULL,
                        0);
    DfSendMessage(wnd->MenuBarWnd,DFM_BUILDMENU,
        (DF_PARAM)wnd->extension,0);
    DfAddAttribute(wnd->MenuBarWnd, DF_VISIBLE);
}

/* ----------- Create the status bar ------------- */
static void CreateStatusBar(DFWINDOW wnd)
{
    if (wnd->StatusBar != NULL)    {
        DfSendMessage(wnd->StatusBar, DFM_CLOSE_WINDOW, 0, 0);
        wnd->StatusBar = NULL;
    }
    if (DfTestAttribute(wnd, DF_HASSTATUSBAR))    {
        wnd->StatusBar = DfDfCreateWindow(DF_STATUSBAR,
                            NULL,
                            DfGetClientLeft(wnd),
                            DfGetBottom(wnd),
                            1,
                            DfClientWidth(wnd),
                            NULL,
                            wnd,
                            NULL,
                            0);
        DfAddAttribute(wnd->StatusBar, DF_VISIBLE);
    }
}

#ifdef INCLUDE_MULTI_WINDOWS
/* -------- return the name of a document window ------- */
static char *WindowName(DFWINDOW wnd)
{
    if (DfGetTitle(wnd) == NULL)
    {
        if (DfGetClass(wnd) == DF_DIALOG)
            return ((DF_DBOX *)(wnd->extension))->HelpName;
        else
            return "Untitled";
    }
    else
        return DfGetTitle(wnd);
}

/* ----------- Prepare the Window menu ------------ */
void DfPrepWindowMenu(void *w, struct DfMenu *mnu)
{
    DFWINDOW wnd = w;
    struct DfPopDown *p0 = mnu->Selections;
    struct DfPopDown *pd = mnu->Selections + 2;
    struct DfPopDown *ca = mnu->Selections + 13;
    int MenuNo = 0;
    DFWINDOW cwnd;

	mnu->Selection = 0;
	oldFocus = NULL;

	if (DfGetClass(wnd) != DF_APPLICATION)
	{
		oldFocus = wnd;

		/* point to the DF_APPLICATION window */
		if (DfApplicationWindow == NULL)
			return;

		cwnd = DfFirstWindow(DfApplicationWindow);
		/* get the first 9 document windows */
		while (cwnd != NULL && MenuNo < 9)
		{
			if (DfGetClass(cwnd) != DF_MENUBAR &&
			    DfGetClass(cwnd) != DF_STATUSBAR)
			{
				/* add the document window to the menu */
				strncpy (Menus[MenuNo]+4, WindowName(cwnd), 20);
				pd->SelectionTitle = Menus[MenuNo];
				if (cwnd == oldFocus)
				{
					/* mark the current document */
					pd->Attrib |= DF_CHECKED;
					mnu->Selection = MenuNo+2;
				}
				else
					pd->Attrib &= ~DF_CHECKED;
				pd++;
				MenuNo++;
			}
			cwnd = DfNextWindow(cwnd);
		}
	}

	if (MenuNo)
		p0->SelectionTitle = "~Close all";
	else
		p0->SelectionTitle = NULL;

	if (MenuNo >= 9)
	{
		*pd++ = *ca;
		if (mnu->Selection == 0)
			mnu->Selection = 11;
	}
	pd->SelectionTitle = NULL;
}

/* window processing module for the More Windows dialog box */
static int WindowPrep(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
{
    switch (msg)    {
        case DFM_INITIATE_DIALOG:    {
            DFWINDOW wnd1;
            DFWINDOW cwnd = DfControlWindow(&Windows,DF_ID_WINDOWLIST);
            int sel = 0;
            if (cwnd == NULL)
                return FALSE;
			wnd1 = DfFirstWindow(DfApplicationWindow);
			while (wnd1 != NULL)	{
                if (wnd1 != wnd && DfGetClass(wnd1) != DF_MENUBAR &&
                        DfGetClass(wnd1) != DF_STATUSBAR)    {
                    if (wnd1 == oldFocus)
                        WindowSel = sel;
                    DfSendMessage(cwnd, DFM_ADDTEXT,
                        (DF_PARAM) WindowName(wnd1), 0);
                    sel++;
                }
				wnd1 = DfNextWindow(wnd1);
            }
            DfSendMessage(cwnd, DFM_LB_SETSELECTION, WindowSel, 0);
            DfAddAttribute(cwnd, DF_VSCROLLBAR);
            DfPostMessage(cwnd, DFM_SHOW_WINDOW, 0, 0);
            break;
        }
        case DFM_COMMAND:
            switch ((int) p1)    {
                case DF_ID_OK:
                    if ((int)p2 == 0)
                        WindowSel = DfSendMessage(
                                    DfControlWindow(&Windows,
                                    DF_ID_WINDOWLIST),
                                    DFM_LB_CURRENTSELECTION, 0, 0);
                    break;
                case DF_ID_WINDOWLIST:
                    if ((int) p2 == DFM_LB_CHOOSE)
                        DfSendMessage(wnd, DFM_COMMAND, DF_ID_OK, 0);
                    break;
                default:
                    break;
            }
            break;
        default:
            break;
    }
    return DfDefaultWndProc(wnd, msg, p1, p2);
}

/* ---- the More Windows command on the Window menu ---- */
static void MoreWindows(DFWINDOW wnd)
{
    if (DfDialogBox(wnd, &Windows, TRUE, WindowPrep))
        ChooseWindow(wnd, WindowSel);
}

/* ----- user chose a window from the Window menu
        or the More Window dialog box ----- */
static void ChooseWindow(DFWINDOW wnd, int WindowNo)
{
    DFWINDOW cwnd = DfFirstWindow(wnd);
	while (cwnd != NULL)
	{
        if (DfGetClass(cwnd) != DF_MENUBAR &&
                DfGetClass(cwnd) != DF_STATUSBAR)
            if (WindowNo-- == 0)
                break;
		cwnd = DfNextWindow(cwnd);
    }
    if (cwnd != NULL)    {
        DfSendMessage(cwnd, DFM_SETFOCUS, TRUE, 0);
        if (cwnd->condition == DF_ISMINIMIZED)
            DfSendMessage(cwnd, DFM_RESTORE, 0, 0);
    }
}

/* ----- Close all document windows ----- */
static void CloseAll(DFWINDOW wnd, int closing)
{
	DFWINDOW wnd1, wnd2;

	DfSendMessage(wnd, DFM_SETFOCUS, TRUE, 0);
	wnd1 = DfLastWindow(wnd);
	while (wnd1 != NULL)
	{
		wnd2 = DfPrevWindow(wnd1);
		if (DfGetClass(wnd1) != DF_MENUBAR && DfGetClass(wnd1) != DF_STATUSBAR)
		{
			DfClearVisible(wnd1);
			DfSendMessage(wnd1, DFM_CLOSE_WINDOW, 0, 0);
		}
		wnd1 = wnd2;
	}
	if (!closing)
		DfSendMessage(wnd, DFM_PAINT, 0, 0);
}

#endif    /* #ifdef INCLUDE_MULTI_WINDOWS */

static void DoWindowColors(DFWINDOW wnd)
{
	DFWINDOW cwnd;

	DfInitWindowColors(wnd);
	cwnd = DfFirstWindow(wnd);
	while (cwnd != NULL)
	{
		DoWindowColors(cwnd);
		if (DfGetClass(cwnd) == DF_TEXT && DfGetText(cwnd) != NULL)
			DfSendMessage(cwnd, DFM_CLEARTEXT, 0, 0);
		cwnd = DfNextWindow(cwnd);
	}
}

/* set up colors for the application window */
static void SelectColors(DFWINDOW wnd)
{
	memcpy(DfCfg.clr, DfColor, sizeof DfColor);
	DoWindowColors(wnd);
}


#ifdef INCLUDE_WINDOWOPTIONS

/* ----- select the screen texture ----- */
static void SelectTexture(void)
{
    DfCfg.Texture = DfCheckBoxSetting(&Display, DF_ID_TEXTURE);
}

/* -- select whether the application screen has a border -- */
static void SelectBorder(DFWINDOW wnd)
{
    DfCfg.Border = DfCheckBoxSetting(&Display, DF_ID_BORDER);
    if (DfCfg.Border)
        DfAddAttribute(wnd, DF_HASBORDER);
    else
        DfClearAttribute(wnd, DF_HASBORDER);
}

/* select whether the application screen has a status bar */
static void SelectStatusBar(DFWINDOW wnd)
{
    DfCfg.StatusBar = DfCheckBoxSetting(&Display, DF_ID_STATUSBAR);
    if (DfCfg.StatusBar)
        DfAddAttribute(wnd, DF_HASSTATUSBAR);
    else
        DfClearAttribute(wnd, DF_HASSTATUSBAR);
}

/* select whether the application screen has a title bar */
static void SelectTitle(DFWINDOW wnd)
{
    DfCfg.Title = DfCheckBoxSetting(&Display, DF_ID_TITLE);
    if (DfCfg.Title)
        DfAddAttribute(wnd, DF_HASTITLEBAR);
    else
        DfClearAttribute(wnd, DF_HASTITLEBAR);
}

#endif

/* EOF */

⌨️ 快捷键说明

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