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

📄 mscroll.cpp

📁 飞虹 vision仿windows开发
💻 CPP
字号:
#include"\sunshine\include\mscroll.h"
#include"\sunshine\include\define.h"
#include"\sunshine\include\app.h"
#include"\sunshine\include\mapp.h"
#define SW 14
#define HH 15
HMPButton::HMPButton(int x,int y,char *filename)
 : MPButton(x,y,HH,HH,filename,"BUT","NOS",0)
 {
 }
MHScroll::MHScroll(int xx,int yy,int l,int inc1,int pageinc1,
 char *idname):MObj(xx,yy,l,HH,idname)
  {
	button1= new HMPButton(x(),y(),"HS1.bmp");
	button2= new HMPButton(x()+w()-SW-1,y(),"HS2.bmp");
	count=0;
	inc=inc1;pageinc=pageinc1;
	maxcount=0;
	while((x()+HH+maxcount*inc+SW)<(x()+w()-1-HH)) maxcount++;
	firstrun=1;
  }
 MHScroll::~MHScroll()
  {
	delete button1;
	delete button2;
  }
void MHScroll::UnFocus()
  {
	Mouse am(1);
	setcolor(BLACK);
	rectangle(x(),y(),x()+w()-1,y()+h()-1);
	setfillstyle(SOLID_FILL,LIGHTGRAY);
	bar(x()+1,y()+1,x()+w()-2,y()+h()-2);
	button1->UnFocus();button2->UnFocus();
	SetSumble(x()+button1->w(),y()+1);
  }
void MHScroll::SetSumble(int xx,int yy)
 {
	MBmp ab("sumb.bmp");
	setfillstyle(SOLID_FILL,LIGHTGRAY);
	bar(x()+HH,y()+1,x()+w()-1-HH,y()+h()-2);
	ab.BitBlt(xx,yy);
 }
void MHScroll::GetFocus()
 {
  Mouse am(1);
  int sl=x()+HH+count*inc;
  if(count==maxcount) sl=x()+w()-HH-SW;
  SetSumble(sl,y()+1);
 }
int MHScroll::F(char *idname)
 {
  if(!idname) return 1;
  (MApp::Application->GetObj(idname)).TransMes(CLICK,NULL,(long)(count/maxcount*100));
  return 1;
 }
int MHScroll::Process()
 {
  Mouse am;
  if(firstrun){UnFocus();firstrun=0;return 1;}
  if(!am.lp()) return 1;
  if(am.x()<x()||am.y()<y()||am.x()>(x()+w()-1)||
	  am.y()>(y()+h()-1)) return 1;
  if(button1->Process()==CLICK)
	{
	 count--;
	 if(count<0) count=0;
	 GetFocus();
	 return F();
	}
  if(button2->Process()==CLICK)
	{
	 count++;
	 if(count>maxcount) count=maxcount;
	 GetFocus();
	 return F();
	}
  if(am.x()>(x()+HH)&&am.x()<(x()+HH+count*inc))
	{
	 count-=pageinc;
	 if(count<0) count=0;
	 GetFocus();
	 while(am.lp()) am.Reset();
	 return F();
	}
  if(am.x()>(x()+HH+count*inc+SW)&&am.x()<(x()+w()-1-HH))
	{
	 count+=pageinc;
	 if(count>maxcount) count=maxcount;
	 GetFocus();
	 while(am.lp()) am.Reset();
	 return F();
	}
  return 1;
 }

⌨️ 快捷键说明

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