Пример #1
0
void
main(int argc, char *argv[])
{
    int
    height,
    width,
    temp;
    Boolean
    GOT_QID = False;
    CONDITION
    cond;

    toplevel = XtAppInitialize(	/* create application context */
                   &app_ctx,
                   "print_server_display",
                   NULL, 0,
#ifdef SOLARIS
                   (Cardinal *) & argc,
#else
                   &argc,
#endif
                   argv,
                   NULL,
                   NULL, 0);

    width = MAX_WIDTH - 10;
    height = MAX_HEIGHT - 10;
    argc--;
    argv++;
    while (argc > 0) {
        if (strcmp(*argv, "-w") == 0) {
            argc--;
            argv++;
            temp = atoi(*argv);
            if (temp < MIN_WIDTH) {
                fprintf(stderr, "Height must be > %d\n", MIN_WIDTH);
                UsageError();
                exit(0);
            }
            if (temp > MAX_WIDTH) {
                fprintf(stderr, "Height must be < %d\n", MAX_WIDTH);
                UsageError();
                exit(0);
            }
            width = temp;
            argc--;
            argv++;
        } else if (strcmp(*argv, "-h") == 0) {
            argc--;
            argv++;
            temp = atoi(*argv);
            if (temp < MIN_HEIGHT) {
                fprintf(stderr, "Height must be > %d\n", MIN_HEIGHT);
                UsageError();
                exit(0);
            }
            if (temp > MAX_HEIGHT) {
                fprintf(stderr, "Height must be < %d\n", MAX_HEIGHT);
                UsageError();
                exit(0);
            }
            height = temp;
            argc--;
            argv++;
        } else if (strcmp(*argv, "-v") == 0) {
            argc--;
            argv++;
            (void) COND_EstablishCallback(cond_CB);
        } else {
            if (argc != 1) {
                fprintf(stderr, "Only the last parameter is a none switch\n");
                UsageError();
                exit(0);
            }
            queue_id = atoi(*argv);
            if (queue_id == 0) {
                fprintf(stderr, "Invalid queueu ID\n");
                UsageError();
                exit(0);
            }
            argc--;
            argv++;
            GOT_QID = True;
        }
    }
    if (GOT_QID == False) {
        fprintf(stderr, "Error: Missing QID\n");
        UsageError();
        exit(0);
    }
    THR_Init();
    /* The print_server_display creates a GQ with the specified ID */
    cond = GQ_InitQueue(queue_id, 128, sizeof(GQ_ELEM));
    if (cond != GQ_NORMAL) {
        fprintf(stderr, "GQ_InitQueue failed to create GQ with ID : %d\n",
                queue_id);
        COND_DumpConditions();
        exit(1);
    }
    /* now get hold of the just created GQ */
    cond = GQ_GetQueue(queue_id, sizeof(GQ_ELEM));
    switch (cond) {
    case GQ_SHAREDMEMORYFAIL:
        fprintf(stderr, "GQ Shared Memory failed\n");
        exit(0);
    case GQ_FILEACCESSFAIL:
        fprintf(stderr, "GQ File Access failed\n");
        exit(0);
    case GQ_BADELEMSIZE:
        fprintf(stderr, "GQ Bad Element Size\n");
        exit(0);
    case GQ_UNIMPLEMENTED:
        fprintf(stderr, "GQ Unimplemented\n");
        exit(0);
    case GQ_NORMAL:
        break;
    }
    session_list = LST_Create();
    printf("width = %d, height = %d\n", width, height);
    createMainWin();
    XtRealizeWidget(toplevel);
    DISP_Initialize(toplevel, width, height);
    /*
        DISP_CreateSession("1.2.840.113654.2.3.1993.9.123.9.3221", "test", &session_list);
        DISP_AddBox("test", "PRN_13674.2", &session_list);
        DISP_AddBox("test2", "PRN_13674.2", &session_list);
        DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.5", &session_list);
        DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3225", "PRN_13674.4", &session_list);
        DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.3", &session_list);
    */
    /*lint -e64*/
    XtAppAddTimeOut(app_ctx, TIMEOUT, pollQueue, NULL);
    /*lint +e64*/
    XtAppMainLoop(app_ctx);
    THR_Shutdown();
}
Пример #2
0
/**   after we define and instantiate our programs components   **/
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
                    LPSTR lpszArgument, int nCmdShow)
{
    UNREFERENCED(lpszArgument);
    UNREFERENCED(hPrevInstance);
    /**   here messages to the application are saved   **/
    MSG messages;

   /**********************************************
    *                                            *
    *   create the main window - width, height   *
    *                                            *
    **********************************************/
    HWND hwnd = createMainWin(hThisInstance, 400, 600);

    /**   if main window handle is invalid alert and quit  **/
    if(!hwnd){
        // using wide string for the Unicode crowd
        MessageBox(NULL, _T(" can not create main window "),
                         _T(" WinBreakoutC++ "), MB_OK);

        /**   this in itself will end the program   **/
        PostQuitMessage(0);
    }

    /**   make the window visible on the screen   **/
    ShowWindow(hwnd, nCmdShow);

/**   some debugging code   **/
/**   with the following statements a Debug build target
      allows us to use printf and cout/printf to display data     **/
#ifdef _DEBUG
    if(!AllocConsole()){
        MessageBox(NULL, _T(" can not create console window "),
                         _T(" WinBreakoutC++ "), MB_OK);
    }
    freopen("CONOUT$","wb",stdout);  // reopen stout handle as console window output
#endif

    /**   get our windows rectangle so we can size things   **/
    GetClientRect(hwnd, &mwinRect);

    createBall(20, mwinRect.right / 2, mwinRect.bottom / 2);

    // TODO:  this needs to be from top with a re-sizable window
    createPaddle(mwinRect.bottom - 60, 40, 10);

    createWall(50);

    /**   run the message loop                        **/
    /**   It will run until GetMessage() returns 0.   **/
    /**   argument two is null we are listening to    **/
    /**   the thread not the window.  we get all      **/
    /**   messages.  this loop is the heart of our    **/
    /**   program pumping messages not blood          **/

    /**   messages is MSG structure that windows passes       **/
    /**   messages to our program defined in top of WinMain   **/
    while(GetMessage(&messages, NULL, 0, 0))
    {
        /**   Translate virtual-key messages into character messages   **/
        TranslateMessage(&messages);

        /**   Send message to WindowProcedure   **/
        DispatchMessage(&messages);
    }

    /**   The program return-value is 0                   **/
    /**   - The value that PostQuitMessage() gave was 0   **/
    /**   that's all folks                                **/
    return messages.wParam;
}