前提是已经安装好了minigui在系统上的环境
框架还是从helloworld开始
#include
#include
#include
#include
#include
#include
static int main_text(HWND hWnd, int nMessage, WPARAM wParam, LPARAM lParam)
{
HWND mHwnd1, mHwnd2;
HDC hdc;
switch(nMessage){
case MSG_CREATE:
break;
case MSG_PAINT:
hdc = BeginPaint (hWnd);
TextOut (hdc, 60, 60, "Hello world!");
EndPaint (hWnd, hdc);
return 0;
case MSG_TIMER: {
break;
}
case MSG_LBUTTONDOWN: {
break;
}
case MSG_LBUTTONUP: {
break;
}
case MSG_ERASEBKGND: {
break;
}
case MSG_DESTROY:{
break;
}
case MSG_CLOSE:
DestroyMainWindow (hWnd);
PostQuitMessage (hWnd);
return 0;
}
return DefaultMainWinProc(hWnd, nMessage, wParam, lParam);
}
int MiniGUIMain(int argc, const char* argv[])
{
MSG Msg;
MAINWINCREATE CreateInfo;
#ifdef _MGRM_PROCESSES
JoinLayer(NAME_DEF_LAYER , MAIN_TITLE , 0 , 0);
#endif
CreateInfo.dwStyle = WS_NONE;
CreateInfo.dwExStyle = WS_EX_NONE;
CreateInfo.spCaption = "hay";
CreateInfo.hMenu = 0;
CreateInfo.hCursor = GetSystemCursor (IDC_ARROW);
CreateInfo.hIcon = 0;
CreateInfo.MainWindowProc = main_text;
CreateInfo.lx = 0;
CreateInfo.ty = 0;
CreateInfo.rx = g_rcScr.right;
CreateInfo.by = g_rcScr.bottom;
CreateInfo.iBkColor = PIXEL_lightgray;
CreateInfo.dwAddData = 0;
CreateInfo.dwReserved = 0;
CreateInfo.hHosting = HWND_DESKTOP;
HWND 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;
}
自己用的垃圾 Makefile
TARGET = demo
CONFIG_PREFIX = `pwd`
LOCAL_CFLAGS = 需要写minigui头文件的位置
LIBSPATH=-需要写minigui库文件的位置
LOCAL_LDFLAGS = -lminigui_ths -ldl -lts -lasound -ljpeg -lpng -lm -pthread
SRC += ${wildcard src/*.c}
OBJS = $(patsubst %.c, %.c.o, $(SRCS))
CC = gcc
$(TARGET):$(OBJS)
gcc -o $@ demo.c $(LOCAL_CFLAGS $(LOCAL_LDFLAGS) $(LIBSPATH)
clean:
-rm -rf $(OBJS) $(TARGET)
.PHONY:all clean $(TARGET) install
执行: ./demo