mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-28 16:17:09 +08:00
126 lines
4.5 KiB
Plaintext
126 lines
4.5 KiB
Plaintext
.\" This manpage is Copyright (C) 2000 Wei Yongming
|
|
.\" 2000 BluePoint Software
|
|
.\"
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
.\" preserved on all copies.
|
|
.\"
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
.\" permission notice identical to this one
|
|
.\"
|
|
.\" Since MiniGUI is constantly changing, this
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
.\" have taken the same level of care in the production of this manual,
|
|
.\" which is licensed free of charge, as they might when working
|
|
.\" professionally.
|
|
.\"
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
.TH "Main" "3" "July 2000" "MiniGUI"
|
|
.SH "NAME"
|
|
Main \- the entrance of MiniGUI based program
|
|
.SH "SYNOPSIS"
|
|
.B #include <minigui/minigui.h>
|
|
.PP
|
|
.BI "int MiniGUIMain" "(int args, const char* arg[]);"
|
|
.br
|
|
.BI "BOOL GUIAPI PreInitGUI" "(int args, const char* arg[], int* retp);"
|
|
.br
|
|
.BI "int GUIAPI PostTerminateGUI" "(int args, const char* arg[], int rcByGUI);"
|
|
.br
|
|
.BI "void GUIAPI ExitGUISafely" "(int exitcode);"
|
|
.br
|
|
.SH "DESCRIPTION"
|
|
.PP
|
|
Usually, \fBMiniGUIMain\fP function is the entrance of each MiniGUI-based program. In this function, you can create one or more threads for specified main windows. Here is a deliberate design, it is very simple:
|
|
.PP
|
|
.nf
|
|
int MiniGUIMain(int args, const char* arg[])
|
|
{
|
|
pthread_t thread1, thread2;
|
|
|
|
CreateThreadForMainWindow(&thread1, NULL, MainWin1, 0);
|
|
CreateThreadForMainWindow(&thread2, NULL, MainWin2, 0);
|
|
|
|
return 0;
|
|
}
|
|
.fi
|
|
.PP
|
|
Here we call function \fBCreateThreadForMainWindow\fR to create a thread for the main window. This function will return zero if success, or else it will return nonzero value.
|
|
.PP
|
|
MiniGUI will call \fBPreInitGUI\fP automaticlly in \fBmain\fP function. Applications should avoid calling this function directly. \fBmain\fP function has been implemented in libminigui as following:
|
|
.PP
|
|
.nf
|
|
int main(int args, char* agr[])
|
|
{
|
|
int iRet = 0;
|
|
|
|
if (!PreInitGUI (args, agr, &iRet))
|
|
return iRet;
|
|
|
|
if (!InitGUI()) return -1;
|
|
|
|
iRet = MiniGUIMain (args, agr);
|
|
TerminateGUI (iRet);
|
|
iRet = PostTerminateGUI (args, agr, iRet);
|
|
return iRet;
|
|
}
|
|
.fi
|
|
.PP
|
|
You must implemente \fBPreInitGUI\fR function by yourself, so you have a chance to do something before starting MiniGUI. If the return value is \fBTRUE\fR, the program will running on, else if the return value is \fBFALSE\fR, the program will terminate.
|
|
.PP
|
|
Before terminating the application, \fBmain\fR function will call \fBPostTerminateGUI\fR function. The return value of \fBPostTerminateGUI\fR is the exit code of program.
|
|
.PP
|
|
You must implemente \fBPostTerminateGUI\fR function by your own, so you have a chance to modify the exit code of the program.
|
|
.PP
|
|
\fBExitGUISafely\fP has been implemented as following:
|
|
.PP
|
|
.nf
|
|
void ExitGUISafely(int exitcode)
|
|
{
|
|
pthread_kill_other_threads_np();
|
|
TerminateLWEvents();
|
|
TerminateGDI();
|
|
exit(exitcode);
|
|
}
|
|
.fi
|
|
.PP
|
|
When the program exiting, it will transfer the value \fBexitcode\fP to the system shell.
|
|
.SH "NOTES"
|
|
You should implemented \fBPreInitGUI, PostTerminateGUI\fP functions by yourself. However, there is a \fBdti.c\fP file, which defines above functions as default actions. You can use these functions in your own \fBdti.c\fP by including this file in your \fBdti.c\fP file, as follows:
|
|
.PP
|
|
.nf
|
|
#include <minigui/dti.c>
|
|
.fi
|
|
.PP
|
|
Or you can use macros to disable the default functions and define your own instances:
|
|
.PP
|
|
.nf
|
|
// Use macro to disable system defined
|
|
// PreInitGUI functions
|
|
|
|
#define DONT_USE_SYS_PREINITGUI
|
|
#include <minigui/dti.c>
|
|
|
|
// Define your own instance here.
|
|
BOOL GUIAPI PreInitGUI (int args, const char* arg[], int* retp)
|
|
{
|
|
if (...)
|
|
return FALSE; // Terminate program immediately.
|
|
|
|
return TRUE; // Startup minigui normally.
|
|
}
|
|
.fi
|
|
|
|
.SH "SEE ALSO"
|
|
.BR miniguiMain "(3), " miniguiInit "(3), " miniguiDTI (3)
|
|
|
|
.SH "AUTHOR"
|
|
.PP
|
|
This manual page was edited by WEI Yongming <ymwei@minigui.org>.
|
|
If you have any problems, comments or found some bugs, please send messages to me.
|