Thanks jacadcaps for this info.
#include <exec/types.h>
#include <libraries/mui.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/muimaster.h>
#include <proto/utility.h>
#include <clib/alib_protos.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
// Définition des identifiants de menu
#define MENUID_ABOUT 1
#define MENUID_QUIT 2
struct Library *MUIMasterBase;
static BOOL Open_Libs(void)
{
if (!(MUIMasterBase = OpenLibrary("muimaster.library", 0)))
return FALSE;
return TRUE;
}
static void Close_Libs(void)
{
if (MUIMasterBase)
CloseLibrary(MUIMasterBase);
}
int main(int argc, char *argv[])
{
Object *app, *window, *button, *text, *aboutwin;
ULONG signals;
BOOL running = TRUE;
if (!Open_Libs())
{
printf("Cannot open libsn");
return 0;
}
app = ApplicationObject,
MUIA_Application_Title, "Mon Application MUI",
MUIA_Application_Version, "$VER: MonApp 1.0 (01.01.24)",
MUIA_Application_Copyright, "©2024 Yannick BUCHY",
MUIA_Application_Author, "Yannick BUCHY",
MUIA_Application_Description, "Une application MUI simple",
MUIA_Application_Base, "MONAPP",
MUIA_Application_UseRexx, FALSE,
SubWindow, window = WindowObject,
MUIA_Window_Title, "Ma Fenêtre MUI",
MUIA_Window_ID, MAKE_ID('M','A','I','N'),
MUIA_Window_Width, 400,
MUIA_Window_Height, 200,
MUIA_Window_MenuStrip, MenustripObject,
Child, MenuObject,
MUIA_Menu_Title, "Fichier",
Child, MenuitemObject,
MUIA_Menuitem_Title, "À propos",
MUIA_Menuitem_CopyStrings, TRUE,
MUIA_Menuitem_Shortcut, "A",
MUIA_UserData, MENUID_ABOUT,
End,
Child, MenuitemObject,
MUIA_Menuitem_Title, "Quitter",
MUIA_Menuitem_CopyStrings, TRUE,
MUIA_Menuitem_Shortcut, "Q",
MUIA_UserData, MENUID_QUIT,
End,
End,
End,
MUIA_Unicode, TRUE,
WindowContents, VGroup,
Child, VSpace(20),
Child, HGroup,
Child, HSpace(20),
Child, VGroup,
Child, HGroup,
Child, HSpace(0),
Child, button = SimpleButton("Cliquez-moi!"),
Child, HSpace(0),
End,
Child, text = TextObject,
MUIA_Text_Contents, "",
MUIA_Text_PreParse, "33c",
MUIA_Frame, MUIV_Frame_None,
MUIA_Text_Copy, TRUE,
MUIA_Unicode, TRUE,
End,
End,
Child, HSpace(20),
End,
Child, VSpace(20),
End,
End,
SubWindow, aboutwin = WindowObject,
MUIA_Window_Title, "À propos",
MUIA_Window_ID, MAKE_ID('A','B','O','U'),
MUIA_Unicode, TRUE,
WindowContents, VGroup,
Child, TextObject,
MUIA_Text_Contents, "33cnMon Application MUInn"
"Version: 1.0n"
"©2024 Yannick BUCHYnn"
"Une application MUI simple",
MUIA_Text_PreParse, "33c",
MUIA_Unicode, TRUE,
End,
Child, HGroup,
Child, HSpace(0),
Child, SimpleButton("OK"),
Child, HSpace(0),
End,
End,
End,
End;
if (!app)
{
printf("Cannot create application.n");
Close_Libs();
return 0;
}
SetAttrs(button,
MUIA_Unicode, TRUE,
MUIA_FixWidth, 120,
TAG_DONE);
SetAttrs(text, MUIA_FixWidthTxt, "Bienvenue dans votre première application MUI !", TAG_DONE);
DoMethod(button, MUIM_Notify, MUIA_Pressed, FALSE,
text, 3, MUIM_Set, MUIA_Text_Contents, "Bienvenue dans votre première application MUI !");
DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
DoMethod(aboutwin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
aboutwin, 3, MUIM_Set, MUIA_Window_Open, FALSE);
set(window, MUIA_Window_Open, TRUE);
while (running)
{
ULONG id = DoMethod(app, MUIM_Application_Input, &signals);
switch (id)
{
case MUIV_Application_ReturnID_Quit:
case MENUID_QUIT:
if ((MUI_RequestA(app, 0, 0, "Quitter ?", "_Oui|_Non", "Êtes-vous sûr ?", 0)) == 1)
running = FALSE;
break;
case MENUID_ABOUT:
set(aboutwin, MUIA_Window_Open, TRUE);
break;
}
if (running && signals) Wait(signals);
}
set(window, MUIA_Window_Open, FALSE);
if (app) MUI_DisposeObject(app);
Close_Libs();
return 0;
}
UTF-8 seems only supported in the text string, not in title window and requester, menu doesn't work but he don't know the MorphOS SDK.