⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo_icon_desktop.c

📁 飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序
💻 C
字号:
/*** $Id: demo_icon_desktop.c,v 1.8 2005/02/16 06:40:21 zxh Exp $**** desktop-large.c: Desktop management of FHAS for large screen terminals.**** Copyright (C) 2002, 2003 Feynman Software, all rights reserved.**** Use of this source package is subject to specific license terms** from Beijing Feynman Software Technology Co., Ltd.**** URL: http://www.minigui.com**** Current maintainer: <panweiguo> (<panweiguo@minigui.org>).***//* =========================================================================  * Desktop display and management of FHAS.   ========================================================================= */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <minigui/mgext.h>#include "../global.h"#define DESKTOP_ICON_H  50#define DESKTOP_ICON_W  50static int ngCurAppIndex=-1;static int ngOldAppIndex=-1;static int buttondown_index = -1;static const char *desktop_bmpname [] = {    "s_game.bmp",       "s_file.bmp",       "s_camera.bmp",     "s_setup.bmp",      "s_music.bmp",      "s_video.bmp",      "s_picture.bmp",    "s_recorder.bmp",    "s_help.bmp"   };/*static const char *desktop_bmpname1 [] = {    "s_game1.bmp",    "s_file1.bmp",    "s_camera1.bmp",    "s_setup1.bmp",    "s_music1.bmp",    "s_video1.bmp",    "s_picture1.bmp",    "s_recorder1.bmp",    "s_help1.bmp"};static const char *desktop_text_bmpname []= {    "b_game.bmp",    "b_file.bmp",    "b_camera.bmp",    "b_setup.bmp",    "b_music.bmp",    "b_video.bmp",    "b_picture.bmp",    "b_recorder.bmp",    "b_help.bmp"};*/const POINT smallapps_pos[] = {    {45, 76},    {100, 28},    {183, 20},    {257, 40},    {245, 103},    {203, 153},    {136, 172},    {68,  172},    {18,  136}};const POINT largeapps_pos[] = {    {45, 76},    {100, 28},    {183, 20},    {257, 40},    {245, 103},    {203, 153},    {136, 172},    {68,  172},    {18,  136}};#define DESKTOP_BMP_NUM     TABLESIZE(desktop_bmpname) static BITMAP *desktop_bmp [DESKTOP_BMP_NUM] = {    bmp_s_game,    bmp_s_file,    bmp_s_camera,    bmp_s_setup,    bmp_s_music,    bmp_s_video,    bmp_s_picture,    bmp_s_recorder,    bmp_s_help};static BITMAP *desktop_bmp1 [DESKTOP_BMP_NUM] = {    bmp_s_game1,    bmp_s_file1,    bmp_s_camera1,    bmp_s_setup1,    bmp_s_music1,    bmp_s_video1,    bmp_s_picture1,    bmp_s_recorder1,    bmp_s_help1};static BITMAP *desktop_text_bmp [DESKTOP_BMP_NUM] = {    bmp_b_game,    bmp_b_file,    bmp_b_camera,    bmp_b_setup,    bmp_b_music,    bmp_b_video,    bmp_b_picture,    bmp_b_recorder,    bmp_b_help};static void load_desktop_bmp (void){    int i;    gal_pixel pixel;            for (i = 0; i < DESKTOP_BMP_NUM; i ++) {        pixel = GetPixelInBitmap (desktop_bmp1[i], 0, 0);        desktop_bmp1[i]->bmType = BMP_TYPE_COLORKEY;        desktop_bmp1[i]->bmColorKey = pixel;    }    for (i = 0; i < DESKTOP_BMP_NUM; i ++) {        pixel = GetPixelInBitmap (desktop_bmp[i], 0, 0);        desktop_bmp[i]->bmType = BMP_TYPE_COLORKEY;        desktop_bmp[i]->bmColorKey = pixel;    }    for (i = 0; i < DESKTOP_BMP_NUM; i ++) {        pixel = GetPixelInBitmap (desktop_text_bmp[i], 0, 0);        desktop_text_bmp[i]->bmType = BMP_TYPE_COLORKEY;        desktop_text_bmp[i]->bmColorKey = pixel;    }    pixel = GetPixelInBitmap (bmp_b_default, 0, 0);    bmp_b_default->bmType = BMP_TYPE_COLORKEY;    bmp_b_default->bmColorKey = pixel;}static int get_index_by_pos (int x, int y){    int i;    for (i = 0; i < DESKTOP_BMP_NUM; i ++) {        if (x > largeapps_pos [i].x  && x < largeapps_pos [i].x + DESKTOP_ICON_W              && y > largeapps_pos [i].y   && y < largeapps_pos [i].y + DESKTOP_ICON_H)         return i;    }    return -1;    }static int position (int *x, int *y, int index){    if (index < 0 || index >= DESKTOP_BMP_NUM)        return -1;    *x = largeapps_pos [index].x;     *y = largeapps_pos [index].y;     return 0;}extern void create_iconview_win (HWND hParent);extern void create_sound_set_win (HWND hWnd);extern void audioMain(HWND hWnd);extern void pictureMain(HWND hWnd);extern HWND create_mgdillo_win (HWND hwnd, const char* file);void start_demo_app (HWND hwnd, int index){    switch (index) {    case 0:        break;    case 1:        create_iconview_win (hwnd);        break;    case 2:        break;    case 3:        create_sound_set_win (hwnd);        break;    case 4:        audioMain (hwnd);         break;    case 5:        break;    case 6:        pictureMain (hwnd);        break;    case 7:        break;    case 8:	{		create_mgdillo_win (hwnd, "demo-help.html");         break;	}    }}/****************************************************************************/static int desktopWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    switch (message) {    case MSG_CREATE:        ShowWindow (hDesktop, SW_HIDE);        load_desktop_bmp ();        break;    case MSG_MOUSEMOVE:    {        int x, y;        x = LOWORD(lParam);        y = HIWORD(lParam);        buttondown_index = get_index_by_pos (x, y);        switch (buttondown_index) {        case 1:        case 3:        case 4:        case 6:        case 8:            SetCursor (GetSystemCursor(IDC_HAND_POINT));            break;        default:            SetCursor (GetSystemCursor(0));            break;        }    }    case MSG_LBUTTONDOWN:    {        int x, y;        if (GetCapture() == hWnd)            break;        SetCapture (hWnd);        x = LOWORD(lParam);        y = HIWORD(lParam);                buttondown_index = get_index_by_pos (x, y);        break;    }    case MSG_LBUTTONUP:    {        int x, y;        int index;        if (GetCapture() != hWnd)            break;        ReleaseCapture ();        x = LOWORD(lParam);        y = HIWORD(lParam);        ScreenToClient (hWnd, &x, &y);        index = get_index_by_pos (x, y);        if (index != buttondown_index || index < 0 || index > DESKTOP_BMP_NUM-1) {            buttondown_index = -1;            break;        }        //buttondown_index = -1;        //ngCurAppIndex = -1;        ngCurAppIndex = index;        start_demo_app (hWnd, index);        InvalidateRect (hWnd, NULL, TRUE);        break;    }    case MSG_PAINT:    {        HDC hdc = BeginPaint(hWnd);        int i, x, y;        SetBkMode (hdc, BM_TRANSPARENT);        FillBoxWithBitmap (hdc, 0, 0, 320, 240, bmp_desktop_map);        for (i = 0; i < DESKTOP_BMP_NUM; i++) {            if (ngCurAppIndex == i) {                if (position (&x, &y, i) < 0) continue;                FillBoxWithBitmap (hdc, x, y, 0, 0, desktop_bmp[i]);                FillBoxWithBitmap (hdc, 130, 90, 0, 0, desktop_text_bmp[i]);            }            else {                if (position (&x, &y, i) < 0) continue;                FillBoxWithBitmap (hdc, x, y, 0, 0, desktop_bmp1[i]);            }        }        if (ngCurAppIndex == -1) {            FillBoxWithBitmap (hdc, 130, 90, 0, 0, bmp_b_default);        }                   EndPaint(hWnd, hdc);        return 0;    }    case MSG_KEYDOWN:        switch (wParam) {        case SCANCODE_CURSORBLOCKRIGHT:            ngOldAppIndex = ngCurAppIndex;            ngCurAppIndex = (ngCurAppIndex + 1) % DESKTOP_BMP_NUM;            InvalidateRect (hWnd, NULL, TRUE);            break;        case SCANCODE_CURSORBLOCKLEFT:            ngOldAppIndex = ngCurAppIndex;            if (ngCurAppIndex == -1)                ngCurAppIndex = 0;            else if (ngCurAppIndex == 0)                ngCurAppIndex = DESKTOP_BMP_NUM - 1;            else                ngCurAppIndex = (ngCurAppIndex -1)% DESKTOP_BMP_NUM;            InvalidateRect (hWnd, NULL, TRUE);            break;/*        case SCANCODE_CURSORBLOCKUP:            ngOldAppIndex = ngCurAppIndex;            if (ngCurAppIndex == -1)                ngCurAppIndex = 0;            else if (ngCurAppIndex == 0)                ngCurAppIndex = 3;            else if (ngCurAppIndex < 4)                ngCurAppIndex = ngCurAppIndex + 3;            else                 ngCurAppIndex = ngCurAppIndex -4;            InvalidateRect (hWnd, NULL, TRUE);            break;        case SCANCODE_CURSORBLOCKDOWN:            ngOldAppIndex = ngCurAppIndex;            if (ngCurAppIndex == -1)                ngCurAppIndex = 0;            else if (ngCurAppIndex == 3)                ngCurAppIndex = 0;            else if (ngCurAppIndex < 4)                ngCurAppIndex = ngCurAppIndex + 4;            else                 ngCurAppIndex = ngCurAppIndex - 3;            InvalidateRect (hWnd, NULL, TRUE);            break;*/        case SCANCODE_ENTER:            start_demo_app (hWnd, ngCurAppIndex);            break;        case SCANCODE_ESCAPE:            SendMessage (hWnd, MSG_CLOSE, 0, 0);            break;        }        break;    case MSG_CLOSE:         DestroyMainWindow (hWnd);         ShowWindow (hDesktop, SW_SHOWNORMAL);         //PostQuitMessage (hWnd);         return 0;    }    return DefaultMainWinProc(hWnd, message, wParam, lParam);}/**************************************************************************/void create_icon_desktop (HWND hparent){    HWND hwnd;    MAINWINCREATE CreateInfo;    CreateInfo.dwStyle = WS_VISIBLE | WS_MAXIMIZEBOX ;    CreateInfo.dwExStyle = WS_EX_TOPMOST;    CreateInfo.spCaption = "演示桌面";    CreateInfo.hMenu = 0;    CreateInfo.hCursor = GetSystemCursor(0);    CreateInfo.hIcon = 0;    CreateInfo.MainWindowProc = desktopWinProc;    CreateInfo.lx = 0;    CreateInfo.ty = 0;    CreateInfo.rx = SCR_WIDTH;    CreateInfo.by = SCR_HEIGHT;    CreateInfo.iBkColor = RGB2Pixel(HDC_SCREEN, 111, 193, 180);    CreateInfo.dwAddData = 0;    CreateInfo.hHosting = hparent;    hwnd = CreateMainWindow (&CreateInfo);    if(hwnd == HWND_INVALID) {        printf ("--------create_display_win failure\n");        return;    }        ShowWindow(hwnd, SW_SHOWNORMAL);    return;}

⌨️ 快捷键说明

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