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

📄 call.c

📁 一个在linux平台上基于minigui的minigui皮肤模板程序。
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <minigui/mgext.h>
#include <minigui/skin.h>
#include "project.h"
#define SIID_TIMER        499
#define SIID_TIMER1       500
#define SIID_CLOSE        498
#define SIID_BACK        400
#define SIID_NUM1        401
#define SIID_NUM2        402
#define SIID_NUM3        403
#define SIID_NUM4        404
#define SIID_NUM5        405
#define SIID_NUM6        406
#define SIID_NUM7        407
#define SIID_NUM8        408
#define SIID_NUM9        409
#define SIID_NUM10        410
#define SIID_NUM11        411
#define SIID_NUM12        412
#define SIID_NUM13        413
#define SIID_NUM14        414

#define DEF_WIDTH       320
#define DEF_HEIGHT      240
#define ID_TIME         100    
char buf[12]="";
char buf1[12]="";

/* 定义皮肤元素特定属性 */
static si_bmplabel_t timer          = { "","1234567890*#" };
static si_bmplabel_t timer1         = { "","1234567890*#" };
/* 定义皮肤元素数组 */

static skin_item_t skin_main_items [] =
{	
{SIID_NUM1, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    46, 95, {}, 1, ""},
{SIID_NUM2, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    86, 95, {}, 2, ""},
{SIID_NUM3, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    126, 95, {}, 3, ""},
{SIID_NUM4, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    46, 125, {}, 4, ""},
{SIID_NUM5, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    86, 125, {}, 5, ""},
{SIID_NUM6, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    126, 125, {}, 6, ""},
{SIID_NUM7, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    46, 155, {}, 7, ""},
{SIID_NUM8, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    86, 155, {}, 8, ""},
{SIID_NUM9, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    126, 155, {}, 9, ""},
{SIID_NUM10, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    86, 185, {}, 10, ""},
{SIID_NUM11, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    46, 185, {}, 11, ""},
{SIID_NUM12, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    126, 185, {}, 12, ""},
 {SIID_NUM13, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    220, 110, {}, 13, ""},
{SIID_NUM14, SI_TYPE_CHKBUTTON    | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    220, 150, {}, 14, ""},
{SIID_CLOSE,  SI_TYPE_CHKBUTTON   | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
     245, 190, {}, 15, ""}, 
 {SIID_TIMER,  SI_TYPE_BMPLABEL   | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    30, 33, {}, 16, "",0,&timer},  
 {SIID_TIMER1,  SI_TYPE_BMPLABEL   | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
    30, 58, {}, 17, "",0,&timer1},
 {SIID_BACK,  SI_TYPE_CHKBUTTON   | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE,
     220, 70, {}, 18, ""},    	   	   	 	

};

/* 定义皮肤 */
skin_head_t main2_skin =
{
    " ",
    SKIN_STYLE_TOOLTIP, NULL, NULL, 
    0,18, skin_main_items, FALSE
};

/* 位图数组 */
const char *bmp2_name[] = {
"./call/main.jpg","./call/1.jpg" ,"./call/2.jpg","./call/3.jpg","./call/4.jpg","./call/5.jpg","./call/6.jpg","./call/7.jpg","./call/8.jpg","./call/9.jpg","./call/10.jpg","./call/11.jpg","./call/12.jpg",
"./call/13.jpg","./call/14.jpg","./call/close.jpg","./call/shuzi.jpg","./call/shuzi1.jpg","./call/back.jpg"
};

/* 位图资源装/卸载函数 */
void load2_skin_bmps ( skin_head_t *skin, BOOL load )
{
    int i, bmp_num = sizeof(bmp2_name)/sizeof(char *);
    
    /* 如果load为真,则将位图装载到skin的bmps数组,否则卸载bmps数组中的位图 */
    if ( load )
        skin->bmps = (BITMAP* )calloc ( bmp_num, sizeof(BITMAP) );
    
    for ( i = 0 ; i < bmp_num ; i++ ){
        if ( load )
            LoadBitmapFromFile ( HDC_SCREEN, (PBITMAP)&(skin->bmps[i]), bmp2_name[i] );
        else
            UnloadBitmap ((PBITMAP)&(skin->bmps[i]));
    }

    if ( !load )
        free ( (void*)skin->bmps);
}

/* 皮肤事件回调函数 */
static int main2_event_cb (HWND hwnd, skin_item_t* item, int event, void* data)
{   
   
  int size_buf;
  int size_buf1;
  
  if (event ==  SIE_GAIN_FOCUS)           
{   switch (item->id)
	{
		
		}
	}
else	 if (event ==  SIE_LOST_FOCUS)           
{   
			  switch (item->id)
	{
		
		}
	}
else    if (event == SIE_BUTTON_CLICKED) {
        switch (item->id) {
        case SIID_NUM1:       
        	 skin_set_check_status (item->hostskin, SIID_NUM1,FALSE );
           // skin_set_check_status (item->hostskin, SIID_PLAY,TRUE );
           if(strlen(buf)>11)
           	{
           	
           strcat(buf1,"1");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else
           {
           strcat(buf,"1");
           
           printf("%s\n",buf);
           skin_set_item_label(item->hostskin, SIID_TIMER,buf);
          }
            break;
        case SIID_NUM2:       
        	 skin_set_check_status (item->hostskin, SIID_NUM2,FALSE );
        	  if(strlen(buf)>11)
           	{
           	strcat(buf1,"2");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           		printf("%d\n",strlen(buf));
           	printf("%d\n",strlen(buf1));
           strcat(buf,"2");
           printf("%s\n",buf);
           skin_set_item_label(item->hostskin, SIID_TIMER,buf);
          }
           break;
        case SIID_NUM3:       
        	 skin_set_check_status (item->hostskin, SIID_NUM3,FALSE );
        	 if(strlen(buf)>11)
           	{
           	strcat(buf1,"3");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           	printf("%d\n",strlen(buf));
           	printf("%d\n",strlen(buf1));
           strcat(buf,"3");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM4:       
        	 skin_set_check_status (item->hostskin, SIID_NUM4,FALSE );
        	 if(strlen(buf)>11)
           	{
           	strcat(buf1,"4");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	} 
           	else{
           strcat(buf,"4");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM5:       
        	 skin_set_check_status (item->hostskin, SIID_NUM5,FALSE );
        	 if(strlen(buf)>11)
           	{
           	strcat(buf1,"5");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"5");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM6:       
        	 skin_set_check_status (item->hostskin, SIID_NUM6,FALSE );
        	 if(strlen(buf)>11)
           	{
           	strcat(buf1,"6");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"6");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM7:       
        	 skin_set_check_status (item->hostskin, SIID_NUM7,FALSE );
        	 if(strlen(buf)>11)
           	{
           	strcat(buf1,"7");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"7");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM8:       
        	 skin_set_check_status (item->hostskin, SIID_NUM8,FALSE );
        	if(strlen(buf)>11)
           	{
           	strcat(buf1,"8");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"8");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM9:       
        	 skin_set_check_status (item->hostskin, SIID_NUM9,FALSE );
        	 if(strlen(buf)>11)
           	{
           	strcat(buf1,"9");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"9");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM10:       
        	 skin_set_check_status (item->hostskin, SIID_NUM10,FALSE );
          if(strlen(buf)>11)
           	{
           	strcat(buf1,"0");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"0");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM11:       
        	 skin_set_check_status (item->hostskin, SIID_NUM11,FALSE );
        	if(strlen(buf)>11)
           	{
           	strcat(buf1,"*");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"*");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
        case SIID_NUM12:       
           skin_set_check_status (item->hostskin, SIID_NUM12,FALSE );
           if(strlen(buf)>11)
           	{
           	strcat(buf1,"#");
           printf("%s\n",buf1);
           skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);
           	}
           	else{
           strcat(buf,"#");
           printf("%s\n",buf);
          skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
           break;
       
        case SIID_NUM14:       
        	 skin_set_check_status (item->hostskin, SIID_NUM14,FALSE );
        	if(strlen(buf))
        	 {strcpy(buf,"");
        	skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
        	if(strlen(buf1))
           {strcpy(buf1,"");
          skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);}
           break; 
         case SIID_BACK:       
        	 skin_set_check_status (item->hostskin, SIID_BACK,FALSE );
        	 if((size_buf=strlen(buf))<13)
        	{ 	buf[size_buf-1]=0;
        		printf("%s\n",buf);
        skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
        else if((size_buf1=strlen(buf1))<13)
        	{
        		buf1[size_buf1-1]=0;
        		printf("%s\n",buf1);
        		skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);		
        	}
        
           break;        
        case SIID_CLOSE:
      		skin_set_check_status (item->hostskin, SIID_CLOSE,FALSE );
        	if(strlen(buf))
        	 {strcpy(buf,"");
        	skin_set_item_label(item->hostskin, SIID_TIMER,buf);}
        	if(strlen(buf1))
           {strcpy(buf1,"");
          skin_set_item_label(item->hostskin, SIID_TIMER1,buf1);}
      		destroy_skin_window(hwnd);
  	 			PostQuitMessage (hwnd);
          break;

        }
    }
return 1;
}

/* 皮肤窗口消息回调函数 */
static int msg2_event_cb (HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int* result)
{   
	 
    int minute = 0;
    int second = 0;
    char buf[8];
    HDC hdc;
    skin_head_t *hostskin = NULL;
    hostskin = get_window_skin (hwnd);
  
    switch (message) {
        case MSG_TIMER:
       

        break;
        case MSG_PAINT:
   	{
        hdc = BeginPaint (hwnd);//获得客户区的坐标
        SetPenColor(hdc,PIXEL_red);     
     		// Rectangle (hdc, 8,30, 210,230 );
       	EndPaint (hwnd, hdc);                 		
     }
         		break;          
    }
 return 1;
}

call(HWND hmainwnd)
{
    MSG msg;
    HWND hwnd;

    load2_skin_bmps (&main2_skin, TRUE);    /* 装载位图资源 */
         if(flag_call==0)
    {skin_init (&main2_skin, main2_event_cb,msg2_event_cb);
    flag_call=1;
    	printf("chushihua \n");
   } 
   {
         hwnd=create_skin_main_window(&main2_skin,
                        hmainwnd,0, 0,  DEF_WIDTH,  DEF_HEIGHT,
                       TRUE);                
      	 
   
    }
    
    load2_skin_bmps (&main2_skin, FALSE);    /* 卸载位图资源 */

    return 0;
}

⌨️ 快捷键说明

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