MINI GUI繪圖

來源:互聯網
上載者:User
/* ** $Id: painter.c,v 1.6 2004/09/29 05:35:24 suowei Exp $**** Listing 15.1**** painter.c: Sample program for MiniGUI Programming Guide**      Painting by using mouse.**** Copyright (C) 2004 Feynman Software.**** License: GPL*/#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>static int PainterWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    HDC hdc;    static BOOL bdraw = FALSE;    static int pre_x, pre_y;    switch (message) {    case MSG_LBUTTONDOWN:        SetCapture(hWnd);        bdraw = TRUE;        pre_x = LOWORD (lParam);        pre_y = HIWORD (lParam);        break;    case MSG_MOUSEMOVE:    {        int x = LOWORD (lParam);        int y = HIWORD (lParam);        if (bdraw) {            ScreenToClient(hWnd, &x, &y);            hdc = GetClientDC(hWnd);            SetPenColor(hdc, PIXEL_red);            MoveTo(hdc, pre_x, pre_y);            LineTo(hdc, x, y);            ReleaseDC(hdc);            pre_x = x;            pre_y = y;        }        break;    }    case MSG_LBUTTONUP:    {        int x = LOWORD (lParam);        int y = HIWORD (lParam);        if (bdraw) {            ScreenToClient(hWnd, &x, &y);            hdc = GetClientDC(hWnd);            SetPixel (hdc, x, y, PIXEL_red);            ReleaseDC(hdc);            bdraw = FALSE;            ReleaseCapture();        }        break;    }    case MSG_RBUTTONDOWN:        InvalidateRect(hWnd, NULL, TRUE);        break;    case MSG_CLOSE:        DestroyAllControls (hWnd);        DestroyMainWindow (hWnd);        PostQuitMessage (hWnd);        return 0;    }    return DefaultMainWinProc (hWnd, message, wParam, lParam);}int MiniGUIMain (int args, const char* arg[]){    MSG Msg;    HWND hMainWnd;    MAINWINCREATE CreateInfo;#ifdef _LITE_VERSION    SetDesktopRect(0, 0, 1024, 768);#endif        CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;    CreateInfo.dwExStyle = WS_EX_NONE;    CreateInfo.spCaption = "Painter";    CreateInfo.hMenu = 0;    CreateInfo.hCursor = GetSystemCursor(0);    CreateInfo.hIcon = 0;    CreateInfo.MainWindowProc = PainterWinProc;    CreateInfo.lx = 0;    CreateInfo.ty = 0;    CreateInfo.rx = 240;    CreateInfo.by = 320;    CreateInfo.iBkColor = COLOR_lightwhite;    CreateInfo.dwAddData = 0;    CreateInfo.hHosting = HWND_DESKTOP;        hMainWnd = CreateMainWindow (&CreateInfo);        if (hMainWnd == HWND_INVALID)        return -1;    ShowWindow(hMainWnd, SW_SHOWNORMAL);    while (GetMessage(&Msg, hMainWnd)) {        TranslateMessage(&Msg);        DispatchMessage(&Msg);    }    MainWindowThreadCleanup (hMainWnd);    return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.