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

📄 button.c

📁 一个minigui 工程框架,需要windows 下的minigui 开发环境
💻 C
📖 第 1 页 / 共 4 页
字号:
		free (InAcImage_ImageName);
	if(nFlipPageIndex)
		free (nFlipPageIndex);
	if(groupid)
		free (groupid);
	if(sys_cmd_string)
		free (sys_cmd_string);
	if(usr_cmd_string)
		free (usr_cmd_string);
	if(sys_rev_string)
		free (sys_rev_string);
	if(usr_rev_string)
		free (usr_rev_string);
	
	
	return nReturn;
}



Button* Button_Initialize2
(
 int Position_left,
 int Position_top,
 int Position_right,
 int Position_bottom,
 eShape eShape,	 
 
 
 eBack_Style eBackStyle,
 
 
 STRING AcText_szContent,	
 LOG_FONT AcText_LOG_FONT,	
 BOOL AcText_bFring,		
 eLocation AcText_eLocation,
 COLORREF AcText_dwTextColor,
 
 
 STRING InAcText_szContent,	
 LOG_FONT InAcText_LOG_FONT,	
 BOOL InAcText_bFring,		
 eLocation InAcText_eLocation,
 COLORREF InAcText_dwTextColor,
 
 
 COLORREF AcRect_dwFaceColor,
 COLORREF AcRect_dwFrameColor,
 eFrame AcRect_eFrameThick,
 eFace_Style AcRect_eFaceStyle,
 int AcRect_TopLeft_x,
 int AcRect_TopLeft_y,
 int AcRect_BottomRight_x,
 int AcRect_BottomRight_y,
 
 
 COLORREF InAcRect_dwFaceColor,
 COLORREF InAcRect_dwFrameColor,
 eFrame InAcRect_eFrameThick,
 eFace_Style InAcRect_eFaceStyle,
 int InAcRect_TopLeft_x,
 int InAcRect_TopLeft_y,
 int InAcRect_BottomRight_x,
 int InAcRect_BottomRight_y,
 
 
 STRING   AcImage_ImageName,
 COLORREF AcImage_dwForeColor,					
 COLORREF AcImage_dwBackColor,
 BYTE	 AcImage_bStatus,				
 COLORREF AcImage_dwTransparenceColor,
 
 
 STRING   InAcImage_ImageName,
 COLORREF InAcImage_dwForeColor,					
 COLORREF InAcImage_dwBackColor,
 BYTE	 InAcImage_bStatus,				
 COLORREF InAcImage_dwTransparenceColor,
 
 
 LONG    AcLockRect_left,
 LONG    AcLockRect_top,
 LONG    AcLockRect_right,
 LONG    AcLockRect_bottom,
 
 
 LONG    InAcLockRect_left,
 LONG    InAcLockRect_top,
 LONG    InAcLockRect_right,
 LONG    InAcLockRect_bottom,
 
 int nID,
 
 STRING nFlipPageIndex ,
 int nReturn,
 STRING groupid,
 
 BOOL Comm_Type,	
 eFeedbackType feedback_type, 
 int m_ndelay,
 
 STRING sys_cmd_string,	
 STRING usr_cmd_string, 	
 STRING sys_rev_string,	
 STRING usr_rev_string,	
 int sys_cmd_string_len,
 int usr_cmd_string_len,
 int sys_rev_string_len,
 int usr_rev_string_len,
 
 int nRidus,
 int nActiveFStyle,
 int nActiveFContrans,
 int nInActiveFStyle,
 int nInActiveFContrans,
 int stylemore,
 Page* gpage
 )
{
	Rect Position,AcLockRect,InAcLockRect;
	TextItem AcText,InAcText;
	Point AcRect_BottomRight,AcRect_TopLeft,InAcRect_BottomRight,InAcRect_TopLeft;
	RectItem AcRect,InAcRect;
	ImageItem AcImage,InAcImage;
	
	if(!(Position_right-Position_left)%2) Position_right+=1;
	if(!(Position_bottom-Position_top)%2) Position_bottom+=1;
	
	Position = rect_struct_init(Position_bottom,Position_left,Position_right,Position_top);
	
	AcText = text_struct_init(AcText_szContent,AcText_LOG_FONT,AcText_bFring,AcText_eLocation,AcText_dwTextColor);
	
	InAcText = text_struct_init(InAcText_szContent,InAcText_LOG_FONT,InAcText_bFring,InAcText_eLocation,InAcText_dwTextColor);
	
	AcRect_BottomRight = point_struct_init(AcRect_BottomRight_x,AcRect_BottomRight_y);
	AcRect_TopLeft = point_struct_init(AcRect_TopLeft_x,AcRect_TopLeft_y);
	AcRect 	 = rectitem_struct_init2(AcRect_dwFaceColor,AcRect_dwFrameColor,AcRect_eFrameThick,AcRect_eFaceStyle,AcRect_TopLeft,AcRect_BottomRight,nActiveFStyle,nActiveFContrans);
	
	InAcRect_BottomRight = point_struct_init(InAcRect_BottomRight_x,InAcRect_BottomRight_y);
	InAcRect_TopLeft = point_struct_init(InAcRect_TopLeft_x,InAcRect_TopLeft_y);
	InAcRect= rectitem_struct_init2(InAcRect_dwFaceColor,InAcRect_dwFrameColor,InAcRect_eFrameThick,InAcRect_eFaceStyle,InAcRect_TopLeft,InAcRect_BottomRight,nInActiveFStyle,nInActiveFContrans);
	
	AcImage = imageitem_struct_init(AcImage_ImageName,AcImage_dwForeColor,AcImage_dwBackColor,AcImage_bStatus,AcImage_dwTransparenceColor);
	InAcImage = imageitem_struct_init(InAcImage_ImageName,InAcImage_dwForeColor,InAcImage_dwBackColor,InAcImage_bStatus,InAcImage_dwTransparenceColor);
	
	AcLockRect = rect_struct_init(AcLockRect_bottom,AcLockRect_left,AcLockRect_right,AcLockRect_top);
	InAcLockRect = rect_struct_init(InAcLockRect_bottom,InAcLockRect_left,InAcLockRect_right,InAcLockRect_top);
	
	
	return button_struct_init2(Position,eShape,eBackStyle,AcText,InAcText,AcRect,InAcRect,
		AcImage,InAcImage,AcLockRect,InAcLockRect,nID,nFlipPageIndex,nReturn,groupid,Comm_Type,feedback_type,m_ndelay,
		sys_cmd_string,usr_cmd_string,sys_rev_string,usr_rev_string,
		sys_cmd_string_len,usr_cmd_string_len,sys_rev_string_len,usr_rev_string_len,nRidus,stylemore,gpage);
	
 }
 
 
 
 
 Button*  button_struct_init2(				
	 Rect Position,eShape eShape,eBack_Style eBackStyle,			
	 TextItem ActiveText,TextItem InActiveText,RectItem ActiveRect,RectItem  InActiveRect,
	 ImageItem  ActiveImage,ImageItem  InActiveImage,Rect ActiveLockRect,Rect InActiveLockRect,			
	 int nID,STRING nFlipPageIndex ,int nReturn,
	 STRING groupid,BOOL Comm_Type,eFeedbackType feedback_type,int m_ndelay,			
	 STRING sys_cmd_string,STRING usr_cmd_string,STRING sys_rev_string,STRING usr_rev_string,
	 int sys_cmd_string_len,int usr_cmd_stirng_len,int sys_rev_string_len,int usr_rev_string_len,
	 int ridus,int stylemore,Page* gpage
	 )
 {
	 Button* p_button;
	 int slen;
	 
	 slen=sizeof(Button);
	 p_button = (Button*)malloc(sizeof(Button));
	 if(0 == p_button)
		 return 0;
	 memset(p_button,0,sizeof(Button));
	 
	 
	 // p_button->m_grButtonID;
	 p_button->m_rPosition= Position;
	 p_button->m_eShape = eShape;
	 p_button->m_eBackStyle = eBackStyle;	
	 
	 
	 
	 if(ActiveText.m_szContent == NULL)
		 slen = 0;
	 else
		 slen = strlen(ActiveText.m_szContent);
	 
	 if (slen !=0){
		 
		 p_button->m_tiActiveText.m_szContent = (STRING)malloc(slen+1);
		 if(0 == p_button->m_tiActiveText.m_szContent)
		 {
			 button_free_resource(p_button);
			 return 0;
		 }
		 strcpy(p_button->m_tiActiveText.m_szContent,ActiveText.m_szContent);
	 }
	 else
		 p_button->m_tiActiveText.m_szContent = NULL;
	 
	 if(ActiveText.m_szContent!=NULL)
		 free (ActiveText.m_szContent );
	 
	 
	 p_button->m_tiActiveText.m_bFring = ActiveText.m_bFring;
	 p_button->m_tiActiveText.m_ulTextColor = ActiveText.m_ulTextColor;
	 p_button->m_tiActiveText.m_eLocation = ActiveText.m_eLocation;
	 
	 if(ActiveText.m_LogFont == NULL)
		 slen = 0;
	 else
		 slen = strlen (ActiveText.m_LogFont);
	 
	 if(slen !=0)
	 {
		 
		 p_button->m_tiActiveText.m_LogFont = (STRING)malloc(slen+1);
		 if(0 == p_button->m_tiActiveText.m_LogFont)
		 {
			 button_free_resource(p_button);
			 return 0;
		 }
		 strcpy(p_button->m_tiActiveText.m_LogFont,ActiveText.m_LogFont);
	 }
	 
	 if(ActiveText.m_LogFont !=NULL)
		 free (ActiveText.m_LogFont);
	 
	 
	 if(InActiveText.m_szContent == NULL)
		 slen = 0;
	 else 
		 slen = strlen(InActiveText.m_szContent);
	 
	 if (slen !=0){
		 
		 p_button->m_tiInActiveText.m_szContent = (STRING)malloc(slen+1);
		 if(0 == p_button->m_tiInActiveText.m_szContent)
		 {
			 button_free_resource(p_button);
			 return 0;
		 }	
		 strcpy(p_button->m_tiInActiveText.m_szContent,InActiveText.m_szContent);
	 }
	 else
		 p_button->m_tiInActiveText.m_szContent = NULL;
	 
	 if(InActiveText.m_szContent !=NULL)
		 free (InActiveText.m_szContent );
	 
	 // add.
	 p_button->m_tiInActiveText.m_bFring = InActiveText.m_bFring;
	 p_button->m_tiInActiveText.m_ulTextColor = InActiveText.m_ulTextColor;
	 p_button->m_tiInActiveText.m_eLocation = InActiveText.m_eLocation;
	 
	 if(InActiveText.m_LogFont == NULL)
		 slen = 0;
	 else
		 slen = strlen (InActiveText.m_LogFont );
	 
	 if(slen !=0)
	 {
		 p_button->m_tiInActiveText.m_LogFont = (STRING) malloc(slen+1);
		 if(0 == p_button->m_tiInActiveText.m_LogFont)
		 {
			 button_free_resource(p_button);
			 return 0;
		 }	
		 strcpy(p_button->m_tiInActiveText.m_LogFont,InActiveText.m_LogFont);	
	 }
	 else
		 p_button->m_tiInActiveText.m_LogFont = NULL;
	 
	 if(InActiveText.m_LogFont !=NULL)
		 free (InActiveText.m_LogFont);
	 
	 
	 
	 p_button->m_riActiveRect = ActiveRect;
	 p_button->m_riInActiveRect = InActiveRect;	
	 
	 if(ActiveImage.szImageName ==NULL)
		 slen=0;
	 else
		 slen = strlen(ActiveImage.szImageName);
	 if (slen !=0){
		 
		 p_button->m_iiActiveImage.szImageName  = (STRING)malloc(slen+1);
		 if(0 == p_button->m_iiActiveImage.szImageName)
		 {
			 button_free_resource(p_button);
			 return 0;
		 }
		 strcpy(p_button->m_iiActiveImage.szImageName ,ActiveImage.szImageName);
	 }
	 else
		 p_button->m_iiActiveImage.szImageName = NULL;
	 
	 if(ActiveImage.szImageName !=NULL)
		 free (ActiveImage.szImageName );
	 
	 p_button->m_iiActiveImage.m_bStatus = ActiveImage.m_bStatus;
	 p_button->m_iiActiveImage.m_ulBackColor = ActiveImage.m_ulBackColor;
	 p_button->m_iiActiveImage.m_ulForeColor = ActiveImage.m_ulForeColor;
	 p_button->m_iiActiveImage.m_ulTransparenceColor = ActiveImage.m_ulTransparenceColor;
	 
	 
	 if(InActiveImage.szImageName ==NULL)
		 slen=0;
	 else
		 slen = strlen(InActiveImage.szImageName);
	 if (slen !=0){
		 
		 p_button->m_iiInActiveImage.szImageName = (STRING)malloc(slen+1);
		 if(0 == p_button->m_iiInActiveImage.szImageName)
		 {
			 button_free_resource(p_button);
			 return 0;
		 }	
		 strcpy(p_button->m_iiInActiveImage.szImageName,InActiveImage.szImageName);
	 }
	 else
		 p_button->m_iiInActiveImage.szImageName = NULL;
	 
	 if(InActiveImage.szImageName !=NULL)
		 free (InActiveImage.szImageName );
	 
	 p_button->m_iiInActiveImage .m_bStatus = InActiveImage.m_bStatus;
	 p_button->m_iiInActiveImage .m_ulBackColor = InActiveImage.m_ulBackColor;
	 p_button->m_iiInActiveImage .m_ulForeColor = InActiveImage.m_ulForeColor;
	 p_button->m_iiInActiveImage .m_ulTransparenceColor = InActiveImage.m_ulTransparenceColor;
	 
	 
	 
	 p_button->m_rInActiveLockRect = InActiveLockRect;
	 p_button->m_rActiveLockRect = ActiveLockRect;
	 
	 
	 p_button->m_nID  = nID;
	 
	 if(nFlipPageIndex == NULL)
		 slen = 0;
	 else
		 slen = strlen (nFlipPageIndex);
	 
	 if(slen !=0)
	 {
		 p_button->m_szFlipPageIndex = (STRING) malloc(slen +1);
		 if(0 == p_button->m_szFlipPageIndex )
		 {
			 button_free_resource(p_button);
			 return 0;
		 }	
		 strcpy(p_button->m_szFlipPageIndex,nFlipPageIndex);
	 }
	 else
		 p_button->m_szFlipPageIndex = NULL;
	 
	 p_button->m_nReturn = nReturn;	
	 
	 if(groupid ==NULL)
		 slen = 0;
	 else
		 slen = strlen (groupid);
	 
	 if(slen !=0)
	 {
		 p_button->m_szGroupID = (STRING) malloc(slen +1);
		 if(0 == p_button->m_szGroupID  )
		 {
			 button_free_resource(p_button);
			 return 0;
		 }	
		 strcpy(p_button->m_szGroupID,groupid);
	 }
	 else
		 p_button->m_szGroupID =NULL;
	 
	 p_button->m_bCommType = Comm_Type;		
	 p_button->m_eFeedbackType = feedback_type;
	 
	 p_button->m_nDelay = m_ndelay * 1000;
	 
	 p_button->gpage = gpage;
	 
	 p_button->m_nRidus = ridus;
	 p_button->m_nMoreStyle= stylemore;	 	 p_button->m_activePid = 0;	 p_button->m_inactivePid = 0;
	 
	 p_button ->m_timer = 0;
	 p_button ->isdown = 0;
	 
	 p_button->target_page = 0;
	 p_button->own_page = 0;
	 p_button->sub_page = 0;
	 p_button->m_spec = 0;
	 p_button->roll_dire = 0;
	 p_button->press_timer = 0;	 p_button->release_timer = 0;	 p_button->roll_index = 0;
	 return p_button;
}



void	button_free_resource(Button* pButton)
{
	if (!pButton)
		return ;
		/*
		if(pButton->m_grButtonID)
		GrDestroyWindow(pButton->m_grButtonID);
		if(pButton->m_iiActiveImage.szImageName)
		free(pButton->m_iiActiveImage.szImageName);
		if(pButton->m_iiInActiveImage.szImageName)
		free(pButton->m_iiInActiveImage.szImageName);
		if(pButton->m_tiActiveText.m_szContent)
		free(pButton->m_tiActiveText.m_szContent);
		if(pButton->m_tiActiveText.m_LogFont)
		free(pButton->m_tiActiveText.m_LogFont);
		if(pButton->m_tiInActiveText.m_szContent)
		free(pButton->m_tiInActiveText.m_szContent);
		if(pButton->m_tiInActiveText.m_LogFont)
		free (pButton->m_tiInActiveText.m_LogFont);
		
		  if(pButton->m_szGroupID )
		  free (pButton->m_szGroupID );
		  
			if(pButton->m_szFlipPageIndex)
			free (pButton->m_szFlipPageIndex);
			pButton ->m_timer = 0;
			
	*/
	free(pButton);
	pButton = 0;
	return;
}



BOOL RegisterButtonminiGUI (void)
{
	WNDCLASS MyClass;
	MyClass.spClassName = BUTTON_MINIGUI;
    MyClass.dwStyle     = WS_NONE;
    MyClass.dwExStyle   = WS_EX_NONE;
    MyClass.hCursor     = GetSystemCursor (IDC_ARROW);
    MyClass.iBkColor    = COLOR_lightwhite;
    MyClass.WinProc     = Button_miniGUIProc;
	return RegisterWindowClass (&MyClass);
	
}
void UnRegisterButtonminiGUI (void)
{
	UnregisterWindowClass (BUTTON_MINIGUI);
	
}
int Button_miniGUIProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
	switch (message) 
	{
	case MSG_PAINT:
		{
			Button* button;
			WinInfo* info = 0;
			info = (WinInfo*)SearchInfo(hwnd);
			if(!info)
				return 0;
			button = (Button*)info->obj;
			ExposureButton(button );
		}
		return 0;
	case MSG_LBUTTONDOWN:
		{
			Button* button;
			WinInfo* info = 0;
			info = (WinInfo*)SearchInfo(hwnd);
			if(!info)
				break;
			button = (Button*)info->obj;
			ExecButtonDownButton(button);
		}
		break;
	case MSG_LBUTTONUP:
		{
			Button* button;
			WinInfo* info = 0;
			info = (WinInfo*)SearchInfo(hwnd);
			if(!info)
				break;
			button = (Button*)info->obj;
			ExecButtonUpButton(button);
		}
		break;
	default:
		break;
		
	}
	return DefaultControlProc (hwnd, message, wParam, lParam);
	
}

⌨️ 快捷键说明

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