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

📄 demo-mgdillo.c

📁 飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序
💻 C
字号:
/*** $Id: demo-mgdillo.c,v 1.14 2005/02/19 11:30:24 weiym Exp $**** mgdillo.c: The main entry of MGDillo test program.**** Copyright (C) 2005 Feynman Software.*//***  This source is free software; you can redistribute it and/or**  modify it under the terms of the GNU General Public**  License as published by the Free Software Foundation; either**  version 2 of the License, or (at your option) any later version.****  This software is distributed in the hope that it will be useful,**  but WITHOUT ANY WARRANTY; without even the implied warranty of**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU**  General Public License for more details.****  You should have received a copy of the GNU General Public**  License along with this library; if not, write to the Free**  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,**  MA 02111-1307, USA*/#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>#ifndef WIN32#include <unistd.h>#endif#include "mgdillo/mgdillo.h"#include "mgdillo-res.h"#include "global.h"extern void draw_caption_bar(HDC, HWND);static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data){    HWND parent = GetParent (hwnd);    switch (nc) {    case IDC_NAV_BACKWARD:        SendDlgItemMessage (parent, IDC_DILLO, MGD_NAV_BACKWARD, 0, 0);        break;    case IDC_NAV_FORWARD:        SendDlgItemMessage (parent, IDC_DILLO, MGD_NAV_FORWARD, 0, 0);        break;    case IDC_NAV_HOME:    {        char url_buf [256] = "file://";                    getcwd (url_buf + 7, 256 - 8);#ifdef WIN32
#ifdef MGDEMO_ENGLISH
		strcat (url_buf, "\\eindex.html");
#else
		strcat (url_buf, "\\index.html");
#endif               {            int i = 0;            while (url_buf [i]) {                if (url_buf [i] == '\\')                    url_buf [i] = '/';                i++;            }        }#else
#ifdef MGDEMO_ENGLISH
		strcat (url_buf, "/eindex.html");
#else
		strcat (url_buf, "/index.html");
#endif        #endif        SendDlgItemMessage (parent, IDC_DILLO, MGD_OPENURL, 0, (LPARAM)url_buf);        break;    }    case IDC_NAV_RELOAD:    case IDC_NAV_EXIT:		break;    }}static HWND create_new_toolbar (HWND hWnd){    HWND ntb;    NTBINFO ntb_info;    NTBITEMINFO ntbii;    gal_pixel pixel;    ntb_info.nr_cells = 4;    ntb_info.w_cell  = 0;    ntb_info.h_cell  = 0;    ntb_info.nr_cols = 0;    ntb_info.image = bmp_toolbar;printf ("bmp_toolbar: width=%d, height=%d\n", bmp_toolbar->bmWidth, bmp_toolbar->bmHeight);    ntb = CreateWindow (CTRL_NEWTOOLBAR,                    "",                    WS_CHILD | WS_VISIBLE,                     IDC_TOOLBAR,                    0, 24, 1024, 0,                    hWnd,                    (DWORD) &ntb_info);    if (ntb == HWND_INVALID)        return HWND_INVALID;    SetNotificationCallback (ntb, my_notif_proc);    pixel = GetPixelInBitmap (bmp_toolbar, 0, 0);    SetWindowBkColor (ntb, pixel);    InvalidateRect (ntb, NULL, TRUE);    memset (&ntbii, 0, sizeof (ntbii));    ntbii.flags = NTBIF_PUSHBUTTON;    ntbii.id = IDC_NAV_BACKWARD;    ntbii.bmp_cell = 1;    SendMessage(ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);    ntbii.flags = NTBIF_PUSHBUTTON;    ntbii.id = IDC_NAV_FORWARD;    ntbii.bmp_cell = 2;    SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);    ntbii.flags = NTBIF_PUSHBUTTON;    ntbii.id = IDC_NAV_HOME;    ntbii.bmp_cell = 3;    SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);        ntbii.flags = NTBIF_SEPARATOR;    ntbii.id = 0;    ntbii.bmp_cell = 0;    ntbii.text = NULL;    SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);/*    ntbii.flags = NTBIF_PUSHBUTTON;    ntbii.id = IDC_NAV_RELOAD;    ntbii.bmp_cell = 0;    SendMessage (ntb, TBM_ADDITEM, 0, (LPARAM)&ntbii);*/     UpdateWindow (hWnd, TRUE);    return ntb;}static int MGDilloMainWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    switch (message) {    case MSG_CREATE:    {        HWND ctrl;        RECT rc_tb, rc;		PMAINWINCREATE ci = (PMAINWINCREATE)lParam;        ctrl = create_new_toolbar (hWnd);        if (ctrl == HWND_INVALID)            return -1;        GetWindowRect (ctrl, &rc_tb);        GetClientRect (hWnd, &rc);         ctrl = CreateWindow (CTRL_DILLO,                          ci->dwAddData?((const char*)ci->dwAddData):"about:splash",                          WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL,                           IDC_DILLO,                           rc.left, rc.top + RECTH (rc_tb) + 24,                           rc.right, rc.bottom - RECTH (rc_tb) - 24, hWnd, 0);        if (ctrl == HWND_INVALID)            return -1;        break;    }	case MSG_PAINT:    {        HDC hDC;        hDC = BeginPaint(hWnd);        SetBrushColor (hDC, RGB2Pixel (HDC_SCREEN, 111, 193, 180));        FillBox (hDC, 0, 0, 320, 24);        SetBkMode (hDC, BM_TRANSPARENT);
#ifdef MGDEMO_ENGLISH
		TextOut (hDC, 2, 5, "Help");
#else	
		TextOut (hDC, 2, 5, "帮助信息");
#endif                 draw_caption_bar (hDC, hWnd);        EndPaint(hWnd, hDC);        return 0;    }    case MSG_KEYDOWN:        if (wParam == SCANCODE_ESCAPE)            SendMessage (hWnd, MSG_CLOSE, 0, 0);        break;    case MSG_LBUTTONDOWN:         if (LOWORD(lParam) > 298 && HIWORD(lParam) < 24)              SendMessage (hWnd, MSG_CLOSE, 0, 0);         break;    case MSG_DESTROY:        break;    case MSG_CLOSE:        DestroyAllControls (hWnd);        DestroyMainWindow (hWnd);        //UnregisterDilloControl ();        //PostQuitMessage (hWnd);        return 0;    }    return DefaultMainWinProc (hWnd, message, wParam, lParam);}static void InitCreateInfo (PMAINWINCREATE pCreateInfo, HWND hparent){    pCreateInfo->dwStyle = WS_THINFRAME;    pCreateInfo->dwExStyle = WS_EX_TOPMOST;    pCreateInfo->spCaption = "Dillo on MiniGUI";    pCreateInfo->hMenu = 0;    pCreateInfo->hCursor = GetSystemCursor (IDC_ARROW);    pCreateInfo->hIcon = 0;    pCreateInfo->MainWindowProc = MGDilloMainWinProc;    pCreateInfo->lx = 0;     pCreateInfo->ty = 0;    pCreateInfo->rx = 320;    pCreateInfo->by = 240;    pCreateInfo->iBkColor = COLOR_lightwhite;     pCreateInfo->dwAddData = 0;    pCreateInfo->hHosting = hparent;}HWND create_mgdillo_win (HWND hwnd, const char* file){	char url_buf [256] = "file://";    MAINWINCREATE CreateInfo;    HWND hMainWnd;    RegisterDilloControl ();    InitCreateInfo (&CreateInfo, hwnd);	if (file) {		getcwd (url_buf + 7, 256 - 8);#ifdef WIN32		{			int i = 0;			while (url_buf [i]) {				if (url_buf [i] == '\\')					url_buf [i] = '/';				i++;			}		}#endif		strcat (url_buf, "/");		strcat (url_buf, file);		CreateInfo.dwAddData = url_buf;	}    hMainWnd = CreateMainWindow (&CreateInfo);    if (hMainWnd == HWND_INVALID)        return 3;    ShowWindow (hMainWnd, SW_SHOWNORMAL);	printf ("---------hMainWnd:=%x\n", hMainWnd);    return hMainWnd;}

⌨️ 快捷键说明

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