Order of the Butterfly
Posts: 306 from 2005/3/27
From: Poland, Zdzies...
Look how easy is to make a simple MUI program with GUI.
This is a window version of Hello World in C, with a little bit extra thing :-)
It shows you a current system time thanks to Kai Hofmann's custom class Time and TimeText.
I marked with bold the extra parts of code. The rest of code do nothing except of opening and closing window.
This is the power of MUI :-)
----------------------------------------------------------------
#include <stdio.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/muimaster.h>
#include <libraries/mui.h>
#include <mui/Time_mcc.h>
#include <mui/TimeText_mcc.h>BOOL running = TRUE;
static APTR app, mainwindow;
static APTR timetxt_gadget;BOOL initialize(void)
{
BOOL res = TRUE;
if (!(MUIMasterBase = OpenLibrary ("muimaster.library", 16)))
{
printf ("MUI 3.5+ required.\n");
res = FALSE;
}
return res;
}
APTR prepare_gui(void)
{
app = ApplicationObject,
MUIA_Application_Title, "Time test",
SubWindow, mainwindow = WindowObject,
MUIA_Window_Title, "Time test",
WindowContents,
HGroup,
Child, VGroup,
Child, timetxt_gadget=TimeTextObject,
End, End,
End,
End,
End;
return app;
}
int main ()
{
ULONG signal;
BOOL running = TRUE;
if (initialize())
{
if (prepare_gui())
{
SetAttrs (mainwindow, MUIA_Window_Open, TRUE, TAG_END);
DoMethod(mainwindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
DoMethod(timetxt_gadget, MUIM_Time_SetCurrent); while (running)
{
switch (DoMethod(app, MUIM_Application_Input, &signal))
{
case MUIV_Application_ReturnID_Quit:
running = FALSE;
break;
}
if (running && signal)
Wait(signal);
}
SetAttrs (mainwindow, MUIA_Window_Open, FALSE, TAG_END);
MUI_DisposeObject (app);
}
else printf("Error: Can't create MUIC_Application object!\n");
}
CloseLibrary (MUIMasterBase);
return (0);
}
[ Edited by r-tea on 2010/6/20 22:16 ]
Mac mini G4@1,5GHz silent upgrade + Xerox Phaser 3140 + EPSON Perfection 1240U
Commodore C64C + 2 x 1541II + Datasette + SD-Box
I miss draggable screens... and do you? I know I'm in a minority unfortunately.