Skip to content

App Template

A minimal Win32 dialog application skeleton with single-instance mutex and a spinning OpenGL logo about box.

Published May 24, 1997

My go-to starting point for a small Win32 dialog app. WinMain enforces a single running instance with a named mutex, then hands off to one main dialog; the project also carries a self-contained OpenGL control (LogoControl.H) that renders a rotating textured cube on its own thread and is used as an animated About box. Use it as scaffolding whenever you want a working dialog shell with version/about menu items in five minutes.

/////////////////////////////////////////////////////////////////////

#include <Windows.H>
#include <WindowsX.H>
#include <ShellAPI.H>
#include <Stdio.H>
#include <Stdlib.H>

#include "Headers/LogoControl.H"

#include "Headers/Definitions.H"
#include "Headers/Functions.H"
#include "Dialogs/MainDialog.H"

/////////////////////////////////////////////////////////////////////

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevious, LPSTR CommandLine, int CmdShow)
{
    HANDLE xMutex;

    if( (xMutex = OpenMutex(SYNCHRONIZE, FALSE, MutexName)) )
    {
        MessageBox (NULL, "Only One Instance Can Run At A Time!" , TitleCaption, 0 + MB_ICONASTERISK + MB_SYSTEMMODAL);
        ReleaseMutex(xMutex);
        CloseHandle(xMutex);
        return 1;
    }
    xMutex = CreateMutex(0, 0, MutexName);

    MainInstance = hInstance;

    DialogBox(MainInstance, MAKEINTRESOURCE(100), 0, MainDialog);

    ReleaseMutex(xMutex);
    CloseHandle(xMutex);

    return 0;
}

/////////////////////////////////////////////////////////////////////
An unhandled error has occurred. Reload 🗙