[Altia Forum] Minimizing the Altia Runtime window from code

Here is some sample code for minimizing the Altia Runtime window using the Altia API and Windows WIN32 API. This might be useful if it is desirable to start Altia Runtime minimized. This code might be executed following a call to the Altia API AtStartInterface() function.

 

#include <windows.h>
#include <altia.h>
...
    AtConnectId id;
    HWND mainWin;
    HWND topWin;
    BOOL result;

    // Some code required here or earlier to assign a valid Altia
    // connection id to the id variable.  A connection id comes from
    // a call to AtStartInterface() or AtOpenConnection().

    // Now get the top-level window for the Altia Runtime.
    AtGetViewWindowId(id, 0, (int *) &mainWin);
    while ((topWin = GetParent(mainWin)) != NULL)
    {
        // printf("Parent of 0x%x is 0x%x\n", mainWin, topWin);
        mainWin = topWin;
    }

    // Minimize Altia Runtime top-level window with WIN32 API call.
    result = CloseWindow(mainWin);

    // If minimize failed, put up Windows MessageBox with the error.
    if (!result)
    {
        char lpBuffer[256];
        DWORD errorVal = GetLastError();
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
               errorVal, LANG_SYSTEM_DEFAULT, lpBuffer, 256, NULL);
        MessageBox(NULL, lpBuffer, NULL, MB_OK);
    }

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.