⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colormessagetext.c

📁 VC++和Tilcon软件编写的一个小的界面程序
💻 C
字号:
/***********************************************************************
**      ColorMessageText.c
***********************************************************************/

/*----------------------------------------------------------------------
**      Define the Main TWD window filename.
**
**      To use a filename other than "ColorMessageText.twd", you can give the name
**      of your TWD file on the command line as the first argument or
**      change the following line:
*/

#define MAIN_WINDOW_FILE  "File_Sys.twd"
#define MAIN_WINDOW_ID    "File_Sys_Test"

/*----------------------------------------------------------------------
**      Change the following lines if you are going beyond a simple application
**
**      Each engine can work with many applications but APPNAME should be unique
**      unless the applications cooperate to share the same objects.
**
**      Each application can open many channels to other applications and
**      engines but each channel's USERPROG in the application must be unique.
*/

#define APPNAME                 "File_Sys"
#define USERPROG                "File_Sys"


/*----------------------------------------------------------------------
**      INCLUDE FILES
*/

#include <time.h>               /*Standard head file define here*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h> 

#include <tilcon/TRTAPI.h>      /*Tilcon API head file define here */
//#include "File_Sys.twh"
#include "Callback.h"
#include "No_Callback.h"

#if defined (CC_TRT_DOS)
#include <windows.h>
#endif


/*----------------------------------------------------------------------
**      define TRT_OS_ENV 
**      
**      NOTE: do not change the order
**            CC_TRT_WCE has CC_TRT_DOS defined as well and must follow it
**
**      That means telling the Tilcon Engine the OS envrioment. 
*/       
#ifdef          CC_TRT_VXWORKS
#define TRT_OS_ENV TRT_VXWORKS
#endif

#ifdef          CC_TRT_NTO
#define TRT_OS_ENV TRT_NTO_PHOTON
#endif

#ifdef          CC_TRT_DOS
#define TRT_OS_ENV TRT_MS_WINDOWS
#endif

#ifdef          CC_TRT_WCE
#define TRT_OS_ENV TRT_WCE
#endif

#ifdef          CC_TRT_LINUX
#define TRT_OS_ENV TRT_LNX_X11R6
#endif


/*----------------------------------------------------------------------
**      GLOBALS
*/

pid_t TRT_cid;                             /* Identifies Tilcon Runtime */
TRT_ReceiveData rec_data;                  /* Record from API */
char *main_window_file = MAIN_WINDOW_FILE; /* twd filename */
char  main_window_id[TRT_MAX_ID_LENGTH];   /* window id inside file */


/*----------------------------------------------------------------------
**      On Error Exit With Message Box
*/

void ExitBox(char *ErrorMessage)
{
    TRT_MessageBox( TRT_cid, NULL, APPNAME,
            ErrorMessage, NULL, "OK", NULL,
            TRT_MessageBox_FontHelvetica, 14,
            TRT_MessageBox_Exclamation|TRT_MessageBox_Wait,
            0, NULL, NULL);
    TRT_Exit (TRT_cid);
    exit(0);
}




/*----------------------------------------------------------------------
**      Warn about unhandled notifications
*/
/*


/***********************************************************************
**************************  Main Entry Point  **************************
***********************************************************************/

int PASCAL WinMain ( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow )
{


    /*----------------------------------------------
    **  variables
    */
    long           errorcode = 0;
    int            c;
    int            ContinueLooping = TRUE;
    TRT_StartData  StartData;


    /*----------------------------------------------
    **  Initialize the StartData structure
    */
    StartData.Os_Env    = TRT_OS_ENV;
    StartData.Display   = NULL;
    StartData.IPAddr    = NULL;
    StartData.AppName   = APPNAME;
    StartData.Userprog  = USERPROG;
    StartData.Flags     = 0;

    /*----------------------------------------------
    **  Start the Embedded Engine and connect to it
    */
    errorcode = TRT_StartEx (0, &StartData);
    TRT_cid   = StartData.TRT_CID;

    if(errorcode)
    {
            printf("Cannot Start Runtime\n");
            exit(0);
    }

    /*----------------------------------------------
    **  force all API commands to be synchronous
    */
    errorcode = TRT_Debug(TRT_cid, 3);

    if(errorcode) ExitBox("Cannot run TRT_Debug");

    /*----------------------------------------------
    **  Load Main Window
    */
    errorcode  = TRT_WindowLoad(TRT_cid, main_window_file );

    if(errorcode) ExitBox("Cannot load the Main Window! File NOT found");

     /*----------------------------------------------
    **  Active the Callback mechanizime.
    */
     errorcode = TRT_WindowCallbacks(TRT_cid,
								MAIN_WINDOW_ID,
								(char*)Callback_Function_callback, 
								sizeof(Callback_Function_callback));
    /*----------------------------------------------
    **  Get the name of the Window
    */
    errorcode = TRT_GetWindowID(TRT_cid,main_window_id);

    if(errorcode) ExitBox("Cannot Get Main Window ID");

    /*----------------------------------------------
    **  Display Main Window
    */
    errorcode = TRT_WindowDisplay(TRT_cid,main_window_id);

    if(errorcode) ExitBox("Cannot Display Main Window");
    /*----------------------------------------------
    **  Main Loop
    **  Wait for communication from Engine
    **  Act on notification
    */
    Load_File_System();
   
    while(ContinueLooping)
    {

        /* Wait for a notification */
        c = TRT_GetInput(NULL, 0, NULL, 0, &rec_data, TRT_BLOCK);

        switch(c)
        {
            /*------------------
            **  Received a standard notification
            */
            case 0:
            {
                /*
		** what type of object is notifying us?
                */
		    switch (rec_data.code)
                {
                  
                    case TRT_window:                            /*If click the "X",Window will be closed.and Main loop will be closed*/
                    if (rec_data.state == TRT_window_quit)  
                    {
                        ContinueLooping = FALSE;
                        continue;
                    }
                    break;

                    default:
                   
                    break;
                }
            }
            break;

            /*------------------
            **  A Callback function was called inside TRT_GetInput
            */
            case 1:
            break;

            /*------------------
            **  Non-blocking mode -- no new events or a critical error
            **  Blocking mode -- a critical error
            */
            case -1:
            break;

            /*------------------
            **  should never happen
            */
            default:
            break;

        }
    }

    /*----------------------------------------------
    **  Cleanup and exit
    */
    TRT_WindowDelete (TRT_cid, main_window_id ); /* Close Window */
    TRT_Exit (TRT_cid);                          /* Notify Runtime to exit */
    return(0);
}

/********************** end of file ColorMessageText.c ********************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -