#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <minigui/mgext.h>
#include <minigui/dti.c>
#define IDM_ABOUT_THIS 100
#define IDM_EXIT 101
#define IDM_EDIT 102
static HMENU createpmenuabout (void)
{
HMENU hmnu;
MENUITEMINFO mii;
memset (&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.id = 0;
mii.typedata = (DWORD)"About...";
hmnu = CreatePopupMenu (&mii);
memset (&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING ;
mii.state = 0;
mii.id = IDM_ABOUT_THIS;
mii.typedata = (DWORD)"About MiniGUI Controls...";
InsertMenuItem(hmnu, 0, TRUE, &mii);
return hmnu;
}
static HMENU createpmenufile (void)
{
HMENU hmnu;
MENUITEMINFO mii;
memset (&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.id = 0;
mii.typedata = (DWORD)"File";
hmnu = CreatePopupMenu (&mii);
mii.type = MFT_STRING;
mii.state = 0;
mii.id = IDM_EXIT;
mii.typedata = (DWORD)"Exit";
InsertMenuItem(hmnu, 6, TRUE, &mii);
return hmnu;
}
static HMENU createpmenuobject (void)
{
HMENU hmnu;
MENUITEMINFO mii;
memset (&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.id = 0;
mii.typedata = (DWORD)"Controls";
hmnu = CreatePopupMenu (&mii);
mii.type = MFT_STRING;
mii.state = 0;
mii.id = IDM_EDIT;
mii.typedata = (DWORD)"Edit control";
InsertMenuItem(hmnu, 3, TRUE, &mii);
return hmnu;
}
static HMENU createmenu (void)
{
HMENU hmnu;
MENUITEMINFO mii;
hmnu = CreateMenu();
memset (&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.id = 100;
mii.typedata = (DWORD)"File";
mii.hsubmenu = createpmenufile ();
InsertMenuItem(hmnu, 0, TRUE, &mii);
mii.type = MFT_STRING;
mii.id = 110;
mii.typedata = (DWORD)"Controls";
mii.hsubmenu = createpmenuobject ();
InsertMenuItem(hmnu, 2, TRUE, &mii);
mii.type = MFT_STRING;
mii.id = 120;
mii.typedata = (DWORD)"About";
mii.hsubmenu = createpmenuabout ();
InsertMenuItem(hmnu, 3, TRUE, &mii);
return hmnu;
}
static int CtrlTestWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
switch (message) {
case MSG_COMMAND:
switch (wParam)
{
case IDM_EXIT:
SendMessage (hWnd, MSG_CLOSE, 0, 0L);
break;
case IDM_EDIT:
edit_demo (hWnd);
break;
case IDM_ABOUT_THIS:
MessageBox (hWnd,
"MiniGUI Controls\n"
"Copyright (C) 2003 Feynman Software.\n",
"About MiniGUI Controls",
MB_OK | MB_ICONINFORMATION | MB_BASEDONPARENT);
break;
}
break;
case MSG_CLOSE:
DestroyMainWindow (hWnd);
PostQuitMessage (hWnd);
return 0;
}
return DefaultMainWinProc (hWnd, message, wParam, lParam);
}
static void InitCreateInfo (PMAINWINCREATE pCreateInfo)
{
pCreateInfo->dwStyle = WS_BORDER | WS_CAPTION | WS_VISIBLE;
pCreateInfo->dwExStyle = 0;
pCreateInfo->spCaption = "MiniGUI Controls";
pCreateInfo->hMenu = createmenu();
pCreateInfo->hCursor = GetSystemCursor (IDC_ARROW);
pCreateInfo->hIcon = 0;
pCreateInfo->MainWindowProc = CtrlTestWinProc;
pCreateInfo->lx = 0;
pCreateInfo->ty = 0;
pCreateInfo->rx = pCreateInfo->lx + 320;
pCreateInfo->by = pCreateInfo->ty + 240;
pCreateInfo->iBkColor = PIXEL_lightwhite;
pCreateInfo->dwAddData = 0;
pCreateInfo->hHosting = HWND_DESKTOP;
}
BITMAP bmp_bkgnd;
int MiniGUIMain (int args, const char* arg[])
{
MSG Msg;
MAINWINCREATE CreateInfo;
HWND hMainWnd;
InitCreateInfo (&CreateInfo);
hMainWnd = CreateMainWindow (&CreateInfo);
if (hMainWnd == HWND_INVALID)
return 3;
while (GetMessage (&Msg, hMainWnd)) {
TranslateMessage (&Msg);
DispatchMessage (&Msg);
}
MainWindowThreadCleanup (hMainWnd);
MiniGUIExtCleanUp ();
return 0;
}
- 1
- 2
前往页