Example #1
0
_Use_decl_annotations_
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR commandLine, int showCommand)
{
    MSG msg = {0};
    int result;

    UNREFERENCED_PARAMETER(prevInstance);
    UNREFERENCED_PARAMETER(commandLine);

    result = CreateOutputWindow(instance, 640, 480);
    if (result)
    {
        goto exit;
    }

    result = InitBitmapAndColorTable();
    if (result)
    {
        goto exit;
    }

    result = RastInit(g_bitmapBits);
    if (result)
    {
        goto exit;
    }

    ShowWindow(g_hwnd, showCommand);
    UpdateWindow(g_hwnd);

    while (msg.message != WM_QUIT)
    {
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
        {
            // Frame

            RastView3D(NULL, 0, 0, 0, 0, 0);

            result = ResolveFrame();
            if (result)
            {
                goto exit;
            }
        }
    }

exit:

    RastExit();

    if (g_bitmap)
    {
        DeleteObject(g_bitmap);
    }

    if (g_memDC)
    {
        DeleteDC(g_memDC);
    }

    if (g_hwnd)
    {
        DestroyWindow(g_hwnd);
    }

    return result;
}
Example #2
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    HINSTANCE hInst;
    RECT rect;
    static HCURSOR 	hCursor;
    static BOOL	bSplitterMoving;
    static DWORD dwSplitterPos;

    switch (uMsg)
    {
    case WM_CREATE:
    {
        hInst = ((LPCREATESTRUCT)lParam)->hInstance;
#pragma warning(push)
#pragma warning (disable:4302)
        hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS));
#pragma warning (pop)

        bAssemble = CreateWindowEx(0, "Button", "Assemble (F5)", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, (HMENU)IDM_COMPILE, hInst, 0);
        CreateASMEditor(hWnd, hInst);
        CreateOutputWindow(hWnd, hInst);
        SetWindowsHookEx(WH_KEYBOARD, &hookWndProc, NULL, GetCurrentThreadId());

        bSplitterMoving = FALSE;
        dwSplitterPos = 250;
        return 0;
    } break;
    case WM_SIZE:
    {
        if ((wParam != SIZE_MINIMIZED) && (HIWORD(lParam) < dwSplitterPos))
            dwSplitterPos = HIWORD(lParam) - 10;

        // Adjust the children's size and position
        MoveWindow(bAssemble,  0,  0, LOWORD(lParam), 25, TRUE);
        MoveWindow(hWinInput,  0, 25, LOWORD(lParam), dwSplitterPos - 1, TRUE);
        MoveWindow(hWinOutput, 0, 25 + dwSplitterPos + 2, LOWORD(lParam), HIWORD(lParam) - dwSplitterPos - 2 - 25, TRUE);
        return 0;
    }break;
    case WM_MOUSEMOVE:
        if (HIWORD(lParam) > 10) // do not allow above this mark
        {
            SetCursor(hCursor);
            if (wParam == MK_LBUTTON && bSplitterMoving)
            {
                GetClientRect(hWnd, &rect);
                if (HIWORD(lParam) > rect.bottom)
                    return 0;

                dwSplitterPos = HIWORD(lParam);
                SendMessage(hWnd, WM_SIZE, 0, MAKELPARAM(rect.right, rect.bottom));
            }
        }
        return 0;
    case WM_COMMAND:
        if (wParam == IDM_COMPILE)
            FasmCompile();
        break;
    case WM_LBUTTONDOWN:
        SetCursor(hCursor);
        bSplitterMoving = TRUE;
        SetCapture(hWnd);
        return 0;
    case WM_LBUTTONUP:
        ReleaseCapture();
        bSplitterMoving = FALSE;
        return 0;
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}