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

📄 playgif.c

📁 基于minigui开发的一套图形控件系统
💻 C
📖 第 1 页 / 共 2 页
字号:
			if (dwStyle & GFS_NORMALGIF)

				SendMessage(hWnd, GFM_SETTIMER, 0, 0);

			return 0;

        }

        break; 

		case GFM_CHANGEGIF:

		{

			PPLAYGIFDATA padddata = (PPLAYGIFDATA)lParam;

			

			KillTimer(hWnd, GetDlgCtrlID(hWnd));

        	CleanPlayGif(pgifctrldata, dwStyle);

			memset(pgifctrldata, 0, sizeof(PLAYGIFCTRLDATA));

			InitPlayGif(pgifctrldata, padddata, dwStyle);

			

			if (dwStyle & GFS_NORMALGIF)

				SendMessage(hWnd, GFM_SETTIMER, 0, 0);

			

			InvalidateRect(hWnd, NULL, TRUE);

			break;

		}

        case MSG_GETDLGCODE:                  

                return DLGC_PUSHBUTTON;

             break;

        case MSG_SIZECHANGING:

        {

             const RECT* rcExpect = (const RECT*)wParam;

             RECT* rcResult = (RECT*)lParam;



             if((rcExpect->right-rcExpect->left) == 0)

             {

             	if(pgifctrldata->gifData)

             	{

             		PBITMAP pbmp = EbGetCurrentGIFBmp(pgifctrldata->gifData);

             		if(pbmp)

             		{

             			rcResult->top = rcExpect->top;

             			rcResult->left = rcExpect->left;

             			rcResult->right = rcResult->left + pgifctrldata->gifData->first->left + pbmp->bmWidth;

             			rcResult->bottom = rcResult->top + pgifctrldata->gifData->first->top + pbmp->bmHeight;

             		}

             	}

             }

        }

        break;

		case MSG_MOUSEMOVE:

		{

			int x, y;

		    RECT cl;

		    

		    if (GetCapture () != hWnd)

		    {

            	SetCapture (hWnd);

                SendMessage(hWnd, MSG_SETFOCUS, 0, 0);

            	break;

	        }

              

            x = LOSWORD(lParam);

            y = HISWORD(lParam);

            ScreenToWindow(GetParent (hWnd), &x, &y);

            GetWindowRect(hWnd,&cl);

            if (PtInRect ((PRECT)&cl, x, y))

            {

                if (GetCapture () == hWnd)

               		break;

             	SetCapture (hWnd);

                SendMessage(hWnd, MSG_SETFOCUS, 0, 0);

            }

            else if (pgifctrldata->status & GFSS_FOCUS) 

			{

            	if (GetCapture () == hWnd)

            		ReleaseCapture ();

				

              	SendMessage(hWnd, MSG_KILLFOCUS, 0, 0);

            }

        }

        break;

		case MSG_SETFOCUS:

		{

			if (dwStyle & GFS_NORMALGIF)

				break;

			

			if (pgifctrldata->status & GFSS_FOCUS)

				break;

			else

			{

				pgifctrldata->status |= GFSS_FOCUS;

				if (GetCapture () != hWnd)

		    		SetCapture (hWnd);

				InvalidateRect(hWnd, NULL, FALSE);

				SendMessage(hWnd, GFM_SETTIMER, 0, 0);

				NotifyParent (hWnd, id, GFN_SETFOCUS);

			}

			break;

		}

		case MSG_KILLFOCUS:

		{

			if (dwStyle & GFS_NORMALGIF)

				break;

			

			if ( pgifctrldata->status & GFSS_FOCUS)

			{

				pgifctrldata->status &= ~GFSS_FOCUS;

				if (GetCapture () == hWnd)

            		ReleaseCapture ();

				InvalidateRect(hWnd, NULL, FALSE);

				SendMessage(hWnd, GFM_KILLTIMER, 0, 0);

				NotifyParent (hWnd, id, GFN_KILLFOCUS);

			}

			break;

		}

        case MSG_DESTROY:

		{

			KillTimer(hWnd, GetDlgCtrlID(hWnd));

			CleanPlayGif(pgifctrldata, dwStyle);

			SetWindowAdditionalData2(hWnd, 0);

        	break;                     

        }

		case MSG_LBUTTONDOWN:

            if (GetCapture () != hWnd)

            {

                SetCapture (hWnd);

            }

			SendMessage(hWnd, MSG_SETFOCUS, 0, 0);

            InvalidateRect (hWnd, NULL, TRUE);

        break;

        case MSG_LBUTTONUP:

        {

            int x, y;

            DWORD dwState;

            RECT cl;

		

            if (GetCapture() != hWnd)

                break;

  

            x = LOSWORD(lParam);

            y = HISWORD(lParam);

            ScreenToWindow(GetParent (hWnd), &x, &y);

            GetWindowRect(hWnd,&cl);



            if (PtInRect (&cl, x, y))

            {               	  

                SendMessage(hWnd, MSG_SETFOCUS, 0, 0);

                NotifyParent (hWnd, id, GFN_CLICKED);

            }

            else

			{

            	ReleaseCapture ();

                SendMessage(hWnd, MSG_KILLFOCUS, 0, 0);

            }

        }

        return 0;



        case MSG_NCPAINT:

        case MSG_ERASEBKGND:

        {

        	return 0;

        }

        break;			

        case GFM_GETTIMES:

        {

			#ifdef DUG_INFO

			PBITMAP pbmp;

			PGIFBITMAPELEMENT pitem;

			HDC hdc = BeginPaint(hWnd);

			int i=1;

			char gifname[24];

			

			fprintf(stderr, "___DUG PLAYGIF save gif begin.\n");

			pitem = pgifctrldata->gifData->first;

			while(pitem)

			{

				fprintf(stderr, "___DUG PLAYGIF save gif%d .\n", i);

				memset(gifname, 0, 24);

				sprintf(gifname, "gif%d.bmp", i++);

				pbmp = &(pitem->Bitmap);

				SaveBitmapToFile(hdc, pbmp, gifname);

				pitem=pitem->next;

			}

			EndPaint(hWnd, hdc);

			fprintf(stderr, "___DUG PLAYGIF save gif end.\n");

			#endif

			

        	if(pgifctrldata->gifData)

        		return pgifctrldata->gifData->delaytime;

			else 

				return 0;

        }

        break;

		

		case GFM_SETTIMER:

			if (!IsTimerInstalled(hWnd, GetDlgCtrlID(hWnd)))

			{

				PGIFBITMAPELEMENT pitem=NULL;

				

				EbRewindGIF (pgifctrldata->gifData);

				pitem = EbGetCurrentGIFItem(pgifctrldata->gifData);				

				SetTimer(hWnd, GetDlgCtrlID(hWnd), pitem->ctrl.delayTime);

			}

			break;

			

		case GFM_KILLTIMER:

			if (IsTimerInstalled(hWnd, GetDlgCtrlID(hWnd)))

				KillTimer(hWnd, GetDlgCtrlID(hWnd));

			SendMessage(hWnd, MSG_PAINT, 0, 0);

			break;

		

		case MSG_TIMER:

        {

        	if(pgifctrldata->gifData)

        	{

        		PGIFBITMAPELEMENT pitem=NULL;

				int delay, olddelay;

				

				//获得原来的延时

				pitem = EbGetCurrentGIFItem(pgifctrldata->gifData);

				olddelay = pitem->ctrl.delayTime;

				

				hdc = BeginPaint(hWnd);



				pitem=NULL;	

				pitem = EbGetNextGIFItem(pgifctrldata->gifData);

				if (dwStyle & GFS_NOLOOPFIRST)

				{

					if (pitem == pgifctrldata->gifData->first)

						pitem = EbGetNextGIFItem(pgifctrldata->gifData);

				}

				

        	    DrawGIF(hWnd, hdc, &(pitem->Bitmap), 0, pitem->left, pitem->top);



				EndPaint(hWnd, hdc);

				ShowCurrentScreen();

				

				//重设定时器

				delay = pitem->ctrl.delayTime;

				if(delay <= 0)

					delay  = 10;

				

				if (delay != olddelay) 

				{

					#if 1

					ResetTimer(hWnd, GetDlgCtrlID(hWnd), delay);

					#else

					KillTimer(hWnd, GetDlgCtrlID(hWnd));

					SetTimer(hWnd, GetDlgCtrlID(hWnd), delay);

					#endif

				}

        	}

        }

        return 0;

        case MSG_PAINT:

        {

			HDC 		hdc = BeginPaint(hWnd);

			char *		szCaption;

			

			SetBrushColor (hdc, GetWindowBkColor(hWnd));

    		SetBkColor (hdc, GetWindowBkColor(hWnd)); 

			SetBkMode(hdc,BM_TRANSPARENT);

			

			if (pgifctrldata->bkfile)

			{

				char szfile[MAX_PATH];

				

				if (dwStyle & GFS_BKSAVEBITMAP)

				{

					if (pgifctrldata->status & GFSS_FOCUS)

						FillBoxWithBitmap(hdc, 0, 0, 0, 0, &(pgifctrldata->fsbmp));

					else

						FillBoxWithBitmap(hdc, 0, 0, 0, 0, &(pgifctrldata->nmbmp));

				}

				else

				{

					memset(szfile, 0, MAX_PATH);

					if (pgifctrldata->status & GFSS_FOCUS)

						PrefixFileName(pgifctrldata->bkfile, "fs", szfile, MAX_PATH);

					else

						PrefixFileName(pgifctrldata->bkfile, "nm", szfile, MAX_PATH);

					

					if (dwStyle & GFS_BKTRANSIMAGE)

						FillWithPicture(hWnd, hdc, szfile, NULL, BMP_TYPE_ALPHARED, dwStyle&BBS_BKALPHA);

					else if(dwStyle & GFS_BKNOTRANSFILE)			

						FillWithPicture(hWnd, hdc, szfile, NULL, BMP_TYPE_ALPHAVALUE, FALSE);

				}

			}

			

            if(pgifctrldata->gifData)

            {   

            	PGIFBITMAPELEMENT pitem;

				PBITMAP pbmp;

				

				if ((dwStyle & GFS_NOLOOPFIRST) && (pgifctrldata->status & GFSS_FOCUS))

					pitem = pgifctrldata->gifData->first->next;

				else

					pitem = pgifctrldata->gifData->first;

	            pbmp = &(pitem->Bitmap);

				

	            if(pbmp)

	       			DrawGIF(hWnd, hdc, pbmp, 0, pitem->left, pitem->top);

            }



			szCaption = GetWindowCaption(hWnd);

			if (szCaption)

			{

				RECT rect;

				PLOGFONT pfont = GetWindowFont(hWnd);

				

				if (pfont)

					SelectFont (hdc, pfont);

				

				GetClientRect(hWnd, &rect);

				GifPaintText(hdc, szCaption, dwStyle, &rect);

			}

			

			EndPaint (hWnd, hdc);

        }

        break;

        default:

            break;

    }

    return DefaultControlProc (hWnd, message, wParam, lParam);

}

⌨️ 快捷键说明

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