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

📄 taskbar.c

📁 详细的MiniGUI源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*	Copyright (C) 2004-2005 Li Yudong*//*** This program 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 program 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 program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include "../include/common.h"#include "../include/taskbar.h"#include "../include/regclass.h"#include "../include/hdc.h"#include "../include/gdi.h"#include "../include/rect.h"#include "../include/message.h"#include "../include/blockheap.h"#include "../include/invalidregion.h"#include "../include/clipregion.h"#include "../include/caret.h"#include "../include/winnc.h"#include "../include/winbase.h"#include "../include/window.h"#include "../include/mledit.h"#include "../include/scrollbar.h"#include "../include/keyboard_pro.h"#include "../include/skbwin.h"#include "../include/text.h"#include "../include/imewin.h"#include "../include/startmenu.h"#define ID_TIMER	1000PWindowsTree _lGUI_pTaskBarWindow;extern int _lGUI_iBytesDataType;//process Pen down message of taskbarstatic void ProcessTaskbarPenDown(	HWND hWnd, 	int x, 	int y);static void TaskBar_StartButtonPressed(	HWND hWnd,	PTaskBarItem pItem);static void TaskBar_SkbPressed(	HWND hWnd,	PTaskBarItem pItem);static void TaskBar_DbcPressed(	HWND hWnd,	PTaskBarItem pItem);static void TaskBar_ImePressed(	HWND hWnd,	PTaskBarItem pItem);static void TaskBar_ClockPressed(	HWND hWnd,	PTaskBarItem pItem);static void ClearTaskBarData(	HWND hWnd);static BOOL InitFixTaskBarData(	HWND hWnd);static void* GetBmpBufAddress(	int iCounter,	void* pOrgPointer, 	int iNumber);static void* GetStartButtonBmpBufAddress(	void* pOrgPointer,	int iNumber);static void* GetSkbBmpBufAddress(	void* pOrgPointer,	int iNumber);static void* GetDbcBmpBufAddress(	void* pOrgPointer,	int iNumber);static void* GetImeBmpBufAddress(	void* pOrgPointer,	int iNumber);static void GetCurrentTime(	char* pString);static BOOL OutputTime(	HWND hWnd,	HDC hDC); BOOL RegisterTaskBar(){ 	WNDCLASSEX wcex;	wcex.cbSize			= sizeof(WNDCLASSEX);	wcex.style			= 0;	wcex.lpfnWndProc	= (WNDPROC)TaskBarControlProc;	wcex.cbClsExtra		= 0;	wcex.cbWndExtra		= 0;	wcex.hInstance		= 0;	wcex.hIcon			= 0;	wcex.hCursor		= 0;	wcex.hbrBackground	= CreateSolidBrush(RGB(198,239,229));	wcex.lpszMenuName	= NULL;	wcex.lpszClassName	= "taskbar";	wcex.hIconSm		= 0;		RegisterClass(&wcex);				return true;}LRESULT TaskBarControlProc(	HWND hWnd, 	int iMsg, 	WPARAM wParam, 	LPARAM lParam){	POINT point;	PWindowsTree pWin;	RECT rc;	HDC hDC;	unsigned long iRetMsg;		PAINTSTRUCT ps;	int iWidth,iHeight;	HPEN hPen;		HBRUSH hBrush;	COLORREF crColor;	PWNDCLASSEX pWndClass;	LRESULT res;	char* pString;	int iLen;	PTaskBarItem pTaskBarItem;	PTaskBar pTaskBar;	pWin=(PWindowsTree)hWnd;		switch(iMsg)	{		case LMSG_CREATE:			_lGUI_pTaskBarWindow = (PWindowsTree)hWnd;			InitFixTaskBarData(hWnd);			SetTimer(hWnd,ID_TIMER,6000);			break;		case LMSG_TIMER:		{			PTaskBar pTaskBar;			PTaskBarItem pItem;			pTaskBar = (PTaskBar)(pWin->dwAddData);			pItem = pTaskBar->pItemHead;			while(1){				if(pItem->id == TASKBAR_OBJID_CLOCK)					break;				pItem = pItem->pNext;			}			if(!pItem)				return false;			InvalidateRect(hWnd,&(pItem->rect),true);			break;		}			case LMSG_COMMAND:			break;		case LMSG_PENDOWN:		{			int x, y;			CaptureMouse(hWnd,BYCLIENT);				x = (int)wParam;			y = (int)lParam;			ProcessTaskbarPenDown(hWnd, x, y);			break;		}				case LMSG_PENMOVE:			break;		case LMSG_PENUP:			DisCaptureMouse();			break;		case LMSG_ERASEBKGND:						pWndClass=GetRegClass(pWin->lpszClassName);			if(!pWndClass)				return (LRESULT)NULL;			hBrush=pWndClass->hbrBackground;			crColor=((BRUSH*)hBrush)->crBrushColor;			((BRUSH*)hBrush)->crBrushColor=RGB_SYSTEMHIBRIGHT;			res=DefWindowProc(hWnd, iMsg, wParam, lParam);			((BRUSH*)hBrush)->crBrushColor=crColor;			return res;					case LMSG_PAINT:		{			int iHeight,iWidth;			HPEN hPenWhite;			PBITMAP pBitmap;			PTaskBarItem pItem;			ps.bPaintDirect=false;			hDC=BeginPaint(hWnd, &ps);			if(!hDC){				return true;			}						GetClientRect(hWnd,&rc);			SetRect(&rc,0,0,rc.right-rc.left,rc.bottom-rc.top);			iWidth	=rc.right - rc.left + 1;			iHeight	=rc.bottom - rc.top + 1;						hPenWhite 	=CreatePen(PS_SOLID,1,RGB_SYSTEMWHITE);						SelectObject(hDC,hPenWhite);			MoveToEx(hDC,rc.left,rc.top,&point);			LineTo(hDC,rc.right,rc.top);			DeleteObject(hPenWhite);			//output those bitmaps			pBitmap = malloc(sizeof(BITMAP));			if(!pBitmap)				return;			memset(pBitmap,0,sizeof(BITMAP));			pTaskBar = (PTaskBar)(pWin->dwAddData);			pItem = pTaskBar->pItemHead;			iWidth = pWin->rect.right - pWin->rect.left + 1;			iHeight = pWin->rect.bottom - pWin->rect.top + 1;						while(pItem){				if(pItem->bShow){					pBitmap->bmHeight = pItem->rect.bottom - pItem->rect.top + 1;					pBitmap->bmWidth = pItem->rect.right - pItem->rect.left + 1;					pBitmap->bmBits = GetBmpBufAddress(pItem->id,pItem->pData,pItem->iCurValue);					OutputBmpObj(hDC,pItem->rect.left,pItem->rect.top,						iWidth,iHeight,(HBITMAP)pBitmap);				}				pItem = pItem->pNext;			}			OutputTime(hWnd,hDC);			free(pBitmap);			EndPaint(hWnd, &ps);			break;		}		case LMSG_DESTROY:			ClearTaskBarData(hWnd);			KillTimer(hWnd,ID_TIMER);			break;		default:			return DefWindowProc(hWnd, iMsg, wParam, lParam);	}	return true;}static BOOL OutputTime(	HWND hWnd,	HDC hDC){	char pString[20];	PWindowsTree pWin;	PTaskBar pTaskBar;	PTaskBarItem pItem;	HFONT hFont;	pWin = (PWindowsTree)hWnd;	pTaskBar = (PTaskBar)(pWin->dwAddData);	pItem = pTaskBar->pItemHead;	while(pItem){		if(pItem->id == TASKBAR_OBJID_CLOCK)			break;		pItem = pItem->pNext;	}	if(!pItem)		return false;	hFont = GetStockObject(FONT_12_12);	SelectObject(hDC,hFont);	GetCurrentTime(pString);	DrawText(hDC,pString,strlen(pString),&(pItem->rect),DT_CENTER|DT_VCENTER);	DeleteObject(hFont);	return true;}static void GetCurrentTime(	char* pString){	time_t current;	struct tm *timeptr;	current = time(NULL);	timeptr = localtime(&current);	sprintf(pString,"%02d:%02d",timeptr->tm_hour,timeptr->tm_min);	}			static void ProcessTaskbarPenDown(	HWND hWnd, 	int x, 	int y){	PWindowsTree pWin;	PTaskBarItem pItem;	PTaskBar pTaskBar;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return;	pTaskBar = (PTaskBar)(pWin->dwAddData);	ScreenToClient(hWnd,&x,&y);	pItem = pTaskBar->pItemHead;	if(!pItem)		return;		while(pItem){		if(PtInRect(&(pItem->rect),x,y)){			switch(pItem->id){			case TASKBAR_OBJID_STARTBUTTON:				TaskBar_StartButtonPressed(hWnd, pItem);				break;			case TASKBAR_OBJID_SKB:				TaskBar_SkbPressed(hWnd, pItem);				break;			case TASKBAR_OBJID_DBC:				TaskBar_DbcPressed(hWnd,pItem);

⌨️ 快捷键说明

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