欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

minigui(一) -helloworld

程序员文章站 2022-06-11 22:24:24
...

昨天安装完minigui  今天自己动手写helloworld


代码:

#include <stdio.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>

static int HelloWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	switch (message) 
	{
		case MSG_PAINT:
			hdc = BeginPaint (hWnd);
			TextOut (hdc, 60, 60, "Hello world!");
			EndPaint (hWnd, hdc);
			return 0;
		case MSG_CLOSE:
			DestroyMainWindow (hWnd);
			PostQuitMessage (hWnd);
			return 0;
	}		
	return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

int MiniGUIMain (int argc, const char* argv[])
{
	MSG Msg;
	HWND hMainWnd;
	MAINWINCREATE CreateInfo;
	
	#ifdef _MGRM_PROCESSES
	JoinLayer (NAME_DEF_LAYER , "helloworld" , 0 , 0);
	#endif
	
	CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;
	CreateInfo.dwExStyle = WS_EX_NONE;
	CreateInfo.spCaption = "HelloWorld";
	CreateInfo.hMenu = 0;
	CreateInfo.hCursor = GetSystemCursor (0);
	CreateInfo.hIcon = 0;
	CreateInfo.MainWindowProc = HelloWinProc;
	CreateInfo.lx = 0;
	CreateInfo.ty = 0;
	CreateInfo.rx = 240;
	CreateInfo.by = 180;
	CreateInfo.iBkColor = COLOR_lightwhite;
	CreateInfo.dwAddData = 0;
	CreateInfo.hHosting = HWND_DESKTOP;
	hMainWnd = CreateMainWindow (&CreateInfo);
	if (hMainWnd == HWND_INVALID)
		return -1;

	ShowWindow (hMainWnd, SW_SHOWNORMAL);
	while (GetMessage (&Msg, hMainWnd)) 
	{
		TranslateMessage (&Msg);
		DispatchMessage (&Msg);
	}
	MainWindowThreadCleanup (hMainWnd);
	return 0;
}

#ifndef _MGRM_PROCESSES
#include <minigui/dti.c>
#endif

代码摘自《MiniGUI 编 程 指 南》

编译:

gcc -o hello helloworld.c -L/usr/local/lib -lminigui_ths -lpciaccess -ljpeg -lpng -ldl -lm -lpthread

其中安装路径为默认路径


编译成功

执行

./hello

minigui(一) -helloworld


编译成功