main.cpp

来自「频谱分析仪Frequency Analyzer」· C++ 代码 · 共 59 行

CPP
59
字号
#include "main.h"
#include "control.h"
#include "resource.h"
#include "winex.h"
#include <new.h>

int NewHandler (size_t size);

HINSTANCE TheInstance = 0;

// The main window is a modeless dialog box

int WINAPI WinMain
   (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow)
{
    TheInstance = hInst;
    _set_new_handler (&NewHandler);

    HWND hDialog = 0;

    hDialog = CreateDialog (hInst, MAKEINTRESOURCE (DLG_MAIN), 0, DialogProc);

    if (!hDialog)
    {
        char buf [100];
        wsprintf (buf, "Error x%x", GetLastError ());
        MessageBox (0, buf, "CreateDialog", MB_ICONEXCLAMATION | MB_OK);
        return 1;
    }

    MSG  msg;
    while ( GetMessage (&msg, NULL, 0, 0 ) )
    {
        if (!IsDialogMessage (hDialog, &msg))
        {
            TranslateMessage ( &msg );
            DispatchMessage ( &msg );
        }
    }

    return msg.wParam;
}
          
void _wassert ( char* szExpr, char* szFile, int line )
{
    char buf [100];
	wsprintf (buf, "\"%s\" in file %s, line %d", szExpr, szFile, line);
    MessageBox (0, buf, "Assertion Failed", MB_ICONEXCLAMATION | MB_OK );
    FatalExit (-1);
}

// out of memory handler that throws exception
int NewHandler (size_t size)
{
    throw "Out of memory";
    return 0;
}

⌨️ 快捷键说明

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