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

📄 mybutton.cpp

📁 挖金子大家都不陌生吧
💻 CPP
字号:
#include "stdafx.h"
#include "mybutton.h"

int MYBUTTON::MouseOut(int x,int y)
{
	if(x<xpos || x>(xpos+width) || y<ypos || y>(ypos+height))
		framenow=0;

	return 1;
}
int MYBUTTON::MouseOver(int x,int y)
{
	if(x<xpos || x>(xpos+width) || y<ypos || y>(ypos+height))
		return 0;

	framenow=1;
	return 1;
}

int MYBUTTON::DetectMouseMove(int x,int y)
{
	MouseOver(x,y);
	MouseOut(x,y);
	return 0;
}

int MYBUTTON::DetectMouseUp(int x,int y)
{
	if(x<xpos || x>(xpos+width) || y<ypos || y>(ypos+height))
		return 0;
	return 1;
}

void MYBUTTON::SetDC(HDC hdest,HDC hsrc)
{
	hdcdest=hdest;
	hdcsrc=hsrc;
}

void MYBUTTON::Show(int x,int y,int iFrame)
{
	HBRUSH hback;
	//当前坐标
	xpos=x;
	ypos=y;

	SelectObject(hdcdest,hf);
	GetTextExtentPoint32(hdcdest,ptext,strlen(ptext),&size);
	width=size.cx+10;
	height=size.cy+10;
	//画背景矩形
	hback=(HBRUSH)CreateSolidBrush(color[iFrame]);
	SelectObject(hdcdest,hback);
	Rectangle(hdcdest,xpos,ypos,xpos+width,ypos+height);
	//按钮文字	
	SetTextColor(hdcdest,color[iFrame+2]);
	SetBkColor(hdcdest,color[iFrame]);
	TextOut(hdcdest,xpos+5,ypos+5,ptext,strlen(ptext));	
}

void MYBUTTON::Show(int x,int y)
{
	HBRUSH hback;
	//当前坐标
	xpos=x;
	ypos=y;

	SelectObject(hdcdest,hf);
	GetTextExtentPoint32(hdcdest,ptext,strlen(ptext),&size);
	width=size.cx+10;
	height=size.cy+10;
	//画背景矩形
	hback=(HBRUSH)CreateSolidBrush(color[framenow]);
	SelectObject(hdcdest,hback);
	Rectangle(hdcdest,xpos,ypos,xpos+width,ypos+height);
	//按钮文字	
	SetTextColor(hdcdest,color[framenow+2]);
	SetBkColor(hdcdest,color[framenow]);
	TextOut(hdcdest,xpos+5,ypos+5,ptext,strlen(ptext));	
}

void MYBUTTON::Init(char *p,COLORREF cback1,COLORREF cback2,
		COLORREF ctext1,COLORREF ctext2,HFONT h)
{
	strcpy(ptext,p);
	color[0]=cback1;
	color[1]=cback2;
	color[2]=ctext1;
	color[3]=ctext2;	
	hf=h;
}

⌨️ 快捷键说明

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