mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2025-05-10 16:42:04 +08:00
77 lines
1.8 KiB
C
77 lines
1.8 KiB
C
/*
|
|
* This is a every simple sample for MiniGUI.
|
|
* It will create a main window and display a string of "Hello, world!" in it.
|
|
*/
|
|
#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>
|
|
|
|
static LRESULT HelloWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
HDC hdc;
|
|
|
|
switch (message) {
|
|
case MSG_PAINT:
|
|
hdc = BeginPaint (hWnd);
|
|
TextOut (hdc, 0, 0, "Hello, world!");
|
|
EndPaint (hWnd, hdc);
|
|
break;
|
|
|
|
case MSG_CLOSE:
|
|
DestroyMainWindow (hWnd);
|
|
PostQuitMessage (hWnd);
|
|
return 0;
|
|
}
|
|
|
|
return DefaultMainWinProc(hWnd, message, wParam, lParam);
|
|
}
|
|
|
|
static void InitCreateInfo (PMAINWINCREATE pCreateInfo)
|
|
{
|
|
pCreateInfo->dwStyle = WS_CAPTION | WS_VISIBLE;
|
|
pCreateInfo->dwExStyle = 0;
|
|
pCreateInfo->spCaption = "Hello, world!" ;
|
|
pCreateInfo->hMenu = 0;
|
|
pCreateInfo->hCursor = GetSystemCursor (0);
|
|
pCreateInfo->hIcon = 0;
|
|
pCreateInfo->MainWindowProc = HelloWinProc;
|
|
pCreateInfo->lx = 0;
|
|
pCreateInfo->ty = 0;
|
|
pCreateInfo->rx = 320;
|
|
pCreateInfo->by = 240;
|
|
pCreateInfo->iBkColor = PIXEL_lightwhite;
|
|
pCreateInfo->dwAddData = 0;
|
|
pCreateInfo->hHosting = HWND_DESKTOP;
|
|
}
|
|
|
|
int MiniGUIMain (int args, const char* arg[])
|
|
{
|
|
MSG Msg;
|
|
MAINWINCREATE CreateInfo;
|
|
HWND hMainWnd;
|
|
|
|
#ifdef _MGRM_PROCESSES
|
|
JoinLayer (NAME_DEF_LAYER, arg[0], 0, 0);
|
|
#endif
|
|
|
|
InitCreateInfo (&CreateInfo);
|
|
|
|
hMainWnd = CreateMainWindow (&CreateInfo);
|
|
if (hMainWnd == HWND_INVALID)
|
|
return -1;
|
|
|
|
while (GetMessage (&Msg, hMainWnd)) {
|
|
DispatchMessage (&Msg);
|
|
}
|
|
|
|
MainWindowThreadCleanup (hMainWnd);
|
|
return 0;
|
|
}
|
|
|
|
|