Пример #1
0
u32 checkbox_proc(MSG *pMsg)
{
    HWND hwnd;
    RECT rc;

    hwnd =pMsg->hwnd;
    switch(pMsg->Code)
    {
        case    MSG_CREATE:
                GetWindowRect(hwnd,&rc);
                printf("checkbox[%04XH]: MSG_CREATE.\r\n",hwnd->WinId);
                return 1;
                ////
        case    MSG_LBUTTON_DOWN:
                {
                    if(hwnd->Style&CBS_SELECTED)
                    {
                        hwnd->Style &= ~CBS_SELECTED;
                        SendMessage(GetParent(hwnd),MSG_NOTIFY,(CBN_UNSELECTED<<16)|(hwnd->WinId),(ptu32_t)hwnd);

                    }
                    else
                    {
                        hwnd->Style |=  CBS_SELECTED;
                        SendMessage(GetParent(hwnd),MSG_NOTIFY,(CBN_SELECTED<<16)|(hwnd->WinId),(ptu32_t)hwnd);

                    }
                    InvalidateWindow(hwnd);
                }
                break;
                ////
        case    MSG_LBUTTON_UP:
                {
//                    int x,y;
//                    x =LO16(pMsg->Param2);
//                    y =HI16(pMsg->Param2);

                //  InvalidateWindow(hwnd);

                }
                break;
                ////

        case    MSG_PAINT:
                checkbox_paint(pMsg);
                return 1;
                ////
        case    MSG_DESTROY:
                printf("checkbox[%04XH]: MSG_DESTROY.\r\n",hwnd->WinId);
                return 1;
                ////

        default:
                return DefWindowProc(pMsg);

    }
    return 0;

}
Пример #2
0
LRESULT CALLBACK WndProc(
	HWND hwnd,
	UINT message,
	WPARAM wparam,
	LPARAM lparam
	)
{
	switch (message)
	{
	case WM_PAINT:
		{
			OnPaint(hwnd);
			return 0;
		}
	case WM_COMMAND:
		{
			switch (LOWORD(wparam))
			{
			case IDC_FILE_EXIT: { DestroyWindow(hwnd); break; }
			case IDC_FILE_OPEN: { OnFileOpenClick(hwnd); break; }
			case IDC_FILTERS_NEGATIVE: { OnFiltersNegativeClick(); InvalidateWindow(hwnd); break; }
			case IDC_FILTERS_NEGATIVE_AMP: { OnFiltersNegativeAMPClick(); InvalidateWindow(hwnd); break;}
			case IDC_FILTERS_BLUR: { OnFiltersBlurClick(); InvalidateWindow(hwnd); break;}
			case IDC_FILTERS_BLUR_AMP: { OnFiltersBlurAMPClick(); InvalidateWindow(hwnd); break;}
			case IDC_FILTERS_BLUR_TEXTURES_AMP: { OnFiltersBlurTextureAMPClick(); InvalidateWindow(hwnd); break; }
			}
			return 0;
		}
	case WM_CREATE:
		{
			OnCreate();
			return 0;
		}
	case WM_DESTROY:
		{
			OnDestroy();
			PostQuitMessage(0);
			return 0;
		}

	default:
		return DefWindowProc(hwnd, message, wparam, lparam);
	}
}
Пример #3
0
//----CheckBox选中响应函数---------------------------------------------------------
//功能:略
//参数:pMsg,消息指针
//返回:固定true
//-----------------------------------------------------------------------------
static bool_t CheckBox_Down(struct WindowMsg *pMsg)
{
     HWND hwnd;
     hwnd =pMsg->hwnd;
     if(hwnd->Style&CBS_SELECTED)
     {
        hwnd->Style &= ~CBS_SELECTED;
//      InvalidateWindow(hwnd,FALSE);   //父窗口消息处理可能导致按钮被删除,
//                                      //InvalidateWindow不能在SendMessage之后调用
        SendMessage(Gdd_GetWindowParent(hwnd),MSG_NOTIFY,(CBN_UNSELECTED<<16)|(hwnd->WinId),(ptu32_t)hwnd);
     }
     else
     {
        hwnd->Style |=  CBS_SELECTED;
        PostMessage(Gdd_GetWindowParent(hwnd),MSG_NOTIFY,(CBN_SELECTED<<16)|(hwnd->WinId),(ptu32_t)hwnd);
     }

     InvalidateWindow(hwnd,FALSE);   //父窗口消息处理可能导致按钮被删除,
                                     //InvalidateWindow不能在SendMessage之后调用
     return true;

}
Пример #4
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 i,x,y;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:
                cfg_idx =0;
                bBorder=TRUE;
                bBKGND=TRUE;
                bColor=TRUE;

                for(i=0;i<8;i++)
                {
                    timer_count[i] =0;
                    timer_run[i]    =FALSE;
                }
                GetClientRect(hwnd,&rc0);
                CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL);

                y=20;
                x=128+8;
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+0*28,60,24,hwnd,ID_START_1,NULL);
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+1*28,60,24,hwnd,ID_START_2,NULL);
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+2*28,60,24,hwnd,ID_START_3,NULL);
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+3*28,60,24,hwnd,ID_START_4,NULL);

                y=20;
                x=128+8+64;
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+0*28,60,24,hwnd,ID_CLR_1,NULL);
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+1*28,60,24,hwnd,ID_CLR_2,NULL);
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+2*28,60,24,hwnd,ID_CLR_3,NULL);
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+3*28,60,24,hwnd,ID_CLR_4,NULL);

                GDD_CreateTimer(hwnd,0,timer_interval[0],0);
                GDD_CreateTimer(hwnd,1,timer_interval[1],0);
                GDD_CreateTimer(hwnd,2,timer_interval[2],0);
                GDD_CreateTimer(hwnd,3,timer_interval[3],0);
                GDD_CreateTimer(hwnd,7,500,TMR_START);

                break;
                ////
        case    MSG_TIMER:
                {
                    i =pMsg->Param1&0xFF;
                    timer_count[i]++;
                    InvalidateWindow(hwnd);
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    switch(event)
                    {
                        case BTN_DOWN:  //按钮按下
                            if(id>=ID_START_1 && id<=ID_START_4)
                            {
                                i =id&0xF;
                                timer_run[i] =TRUE;
                                GDD_ResetTimer(GDD_FindTimer(hwnd,i),timer_interval[i],TMR_START);
                            }

                            if(id>=ID_CLR_1 && id<=ID_CLR_4)
                            {
                                i =id&0xF;
                                timer_count[i] =0;
                                InvalidateWindow(hwnd);
                            }
                            break;
                            ////

                        case BTN_UP:    //按钮弹起
                            if(id==ID_CLOSE)
                            {
                                PostMessage(hwnd,MSG_CLOSE,0,0);
                            }

                            if(id>=ID_START_1 && id<=ID_START_4)
                            {
                                i =id&0xF;
                                timer_run[i] =FALSE;
                                GDD_ResetTimer(GDD_FindTimer(hwnd,i),timer_interval[i],0);
                            }
                            break;
                            ////



                    }

                }
                break;
                ////

        case    MSG_PAINT:
                {
                    char wbuf[32];

                    hdc =BeginPaint(hwnd);
                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(100,100,100));
                    FillRect(hdc,&rc0);

                    SetRect(&rc,4,20,128,24);
                    for(i=0;i<4;i++)
                    {
                        SetTextColor(hdc,DrawText_Color_Tbl[i].text_color);
                        SetDrawColor(hdc,DrawText_Color_Tbl[i].bd_color);
                        SetFillColor(hdc,DrawText_Color_Tbl[i].bk_color);
                        sprintf(wbuf," 定时器%d: %d",i+1,timer_count[i]);

                        if(timer_run[i]!=FALSE)
                        {
                            DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);
                        }
                        else
                        {
                            if(timer_count[7]&0x01)
                            {
                                DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);

                            }
                            else
                            {
                                DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BKGND);
                            }
                        }

                        OffsetRect(&rc,0,28);

                    }

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
Пример #5
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 i;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:
                cfg_idx =0;
                bBorder=TRUE;
                bBKGND=TRUE;
                bColor=TRUE;

                GetClientRect(hwnd,&rc0);
                CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL);

                i=RectH(&rc0)-(3*30);
                CreateWindow(CHECKBOX,"绘制边框",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+0*32,128,24,hwnd,ID_BORDER,NULL);
                CreateWindow(CHECKBOX,"绘制背景",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+1*32,128,24,hwnd,ID_BKGND,NULL);
                CreateWindow(CHECKBOX,"改变颜色",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+2*32,128,24,hwnd,ID_COLOR,NULL);

                GDD_CreateTimer(hwnd,1,3000,TMR_START);
                GDD_CreateTimer(hwnd,2,1000,TMR_START);

                break;
                ////
        case    MSG_TIMER:
                {
                    switch(pMsg->Param1)
                    {
                        case    1:
                                cfg_idx++;
                                if(DrawText_Cfg_Tbl[cfg_idx].text==NULL)
                                {
                                    cfg_idx=0;
                                }
                                InvalidateWindow(hwnd);
                                break;
                                /////
                        case    2:
                                if(bColor!=FALSE)
                                {
                                    color_idx++;
                                    if(color_idx>=8)
                                    {
                                        color_idx=0;
                                    }
                                    InvalidateWindow(hwnd);
                                }
                                break;
                                /////
                    }
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    if(id==ID_CLOSE)
                    {
                    	if(event==BTN_UP)
                    	{
                    		PostMessage(hwnd,MSG_CLOSE,0,0);
                    	}
                    	InvalidateWindow(hwnd);
                    }

                    if(id==ID_BORDER)
                    {
                    	if(event==CBN_SELECTED)
                    	{
                    		bBorder =TRUE;
                    	}
                    	if(event==CBN_UNSELECTED)
                    	{
                    		bBorder =FALSE;
                    	}
                    	InvalidateWindow(hwnd);
                    }

                    if(id==ID_BKGND)
                    {
                    	if(event==CBN_SELECTED)
                    	{
                    		bBKGND =TRUE;
                    	}
                    	if(event==CBN_UNSELECTED)
                    	{
                    		bBKGND =FALSE;
                    	}
                    	InvalidateWindow(hwnd);
                    }

                    if(id==ID_COLOR)
                    {
                    	if(event==CBN_SELECTED)
                    	{
                    		bColor =TRUE;
                    	}
                    	if(event==CBN_UNSELECTED)
                    	{
                    		bColor =FALSE;
                    	}
                    	InvalidateWindow(hwnd);
                    }

                }
                break;
                ////

        case    MSG_PAINT:
                {

                    hdc =BeginPaint(hwnd);
                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(200,200,200));
                    FillRect(hdc,&rc0);


                    SetRect(&rc,4,10,RectW(&rc0)-4*2,60);
                    SetTextColor(hdc,DrawText_Color_Tbl[color_idx].text_color);
                    SetDrawColor(hdc,DrawText_Color_Tbl[color_idx].bd_color);
                    SetFillColor(hdc,DrawText_Color_Tbl[color_idx].bk_color);

                    i=DrawText_Cfg_Tbl[cfg_idx].flag;
                    if(bBorder)
                    {
                        i |= DT_BORDER;
                    }
                    if(bBKGND)
                    {
                        i |= DT_BKGND;
                    }

                    DrawText(hdc,DrawText_Cfg_Tbl[cfg_idx].text,-1,&rc,i);
                   // DrawText(hdc,"DrawText\r\n**绘制字符串**",-1,&rc,DT_BORDER|DT_BKGND|DT_VCENTER|DT_CENTER);

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
Пример #6
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 i;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:

                x1_inc =2;
                y1_inc =1;

                x2_inc =2;
                y2_inc =1;

                bMoveMainWin=FALSE;

                GetClientRect(hwnd,&rc0);
                hwnd_BTN1 =CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL);
                hwnd_BTN2 =CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,4,4,60,24,hwnd,ID_CLOSE,NULL);


                CreateWindow(BUTTON,"移动主窗口",WS_CHILD|BS_HOLD|WS_BORDER|WS_VISIBLE,4,RectH(&rc0)-28,100,24,hwnd,ID_MOVE_1,NULL);


                GDD_CreateTimer(hwnd,0,200,TMR_START);
                GDD_CreateTimer(hwnd,1,150,TMR_START);
                GDD_CreateTimer(hwnd,2,100,TMR_START);

                break;
                ////

        case    MSG_TIMER:
                {

                    switch(pMsg->Param1)
                    {
                    case 0:
                        {
                            static int x_inc=2;
                            static int y_inc=1;

                            if(bMoveMainWin==FALSE)
                            {
                                break;
                            }

                            GetWindowRect(hwnd,&rc);

                            if(rc.left > 320)
                            {
                                x_inc =-3;
                            }

                            if(rc.left <- 200)
                            {
                                x_inc =3;
                            }

                            if(rc.top > 200)
                            {
                                y_inc =-2;
                            }

                            if(rc.top < -100)
                            {
                                y_inc =2;
                            }

                            rc.left+=x_inc;
                            rc.top+=y_inc;

                            ScreenToClient(GetParent(hwnd),(POINT*)&rc,2);
                            MoveWindow(hwnd,rc.left,rc.top);
                        }
                        break;
                        /////

                    case 1:
                    {

                        GetClientRect(hwnd,&rc0);
                        ClientToScreen(hwnd,(POINT*)&rc0,2);

                        GetWindowRect(hwnd_BTN1,&rc);
                        /*
                        GetWindowRect(hwnd_BTN2,&rc0);
                        if(IsIntersectRect(&rc,&rc0))
                        {
                            x1_inc *=-1;
                            y1_inc *=-1;

                            x2_inc *=-1;
                            y2_inc *=-1;
                        }
                         */

                        if((rc.right) >= (rc0.right))
                        {
                            x1_inc =-3;
                        }

                        if(rc.left <= rc0.left)
                        {
                            x1_inc =3;
                        }

                        if((rc.bottom) >= (rc0.bottom))
                        {
                            y1_inc =-2;
                        }

                        if(rc.top <= rc0.top)
                        {
                            y1_inc =2;
                        }

                        rc.left +=x1_inc;
                        rc.top +=y1_inc;

                        ScreenToClient(hwnd,(POINT*)&rc,2);
                        MoveWindow(hwnd_BTN1,rc.left,rc.top);
                    }

                    case 2:
                    {

                        GetClientRect(hwnd,&rc0);
                        ClientToScreen(hwnd,(POINT*)&rc0,2);

                        GetWindowRect(hwnd_BTN2,&rc);
                        /*
                        GetWindowRect(hwnd_BTN1,&rc0);
                        if(IsIntersectRect(&rc,&rc0))
                        {
                            x1_inc *=-1;
                            y1_inc *=-1;

                            x2_inc *=-1;
                            y2_inc *=-1;
                        }
                        */

                        if((rc.right) >= (rc0.right))
                        {
                            x2_inc =-2;
                        }

                        if(rc.left <= rc0.left)
                        {
                            x2_inc =2;
                        }

                        if((rc.bottom) >= (rc0.bottom))
                        {
                            y2_inc =-1;
                        }

                        if(rc.top <= rc0.top)
                        {
                            y2_inc =1;
                        }

                        rc.left +=x2_inc;
                        rc.top +=y2_inc;

                        ScreenToClient(hwnd,(POINT*)&rc,2);
                        MoveWindow(hwnd_BTN2,rc.left,rc.top);
                    }

                    break;
                    ////

                    default:

                        break;

                    }

                    InvalidateWindow(hwnd);
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    switch(event)
                    {

                        case BTN_DOWN:  //按钮按下
                            if(id==ID_MOVE_1)
                            {
                                bMoveMainWin=TRUE;
                            }
                            break;
                            ////

                        case BTN_UP:    //按钮弹起
                            if(id==ID_CLOSE)
                            {
                                PostMessage(hwnd,MSG_CLOSE,0,0);
                            }

                            if(id==ID_MOVE_1)
                            {
                                bMoveMainWin=FALSE;
                            }
                            break;
                            ////

                        default:
                            break;

                    }


                }
                break;
                ////

        case    MSG_PAINT:
                {
                    char wbuf[32];

                    hdc =BeginPaint(hwnd);

                    GetClientRect(hwnd,&rc0);


                    SetTextColor(hdc,RGB(0,240,0));
                    SetFillColor(hdc,RGB(40,40,40));
                    SetDrawColor(hdc,RGB(0,240,0));


                    GetWindowRect(hwnd,&rc);
                    sprintf(wbuf,"当前主窗口位置: %d,%d",rc.left,rc.top);
                    DrawText(hdc,wbuf,-1,&rc0,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
Пример #7
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 i;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:

        		text_align_idx =0;

                prog1_val=0;
                prog2_val=0;

                prog1_inc=1;
                prog2_inc=1;

            	pb1.Flag    =PBF_SHOWTEXT|PBF_ORG_LEFT;
            	pb1.Range	=100;
            	pb1.Pos		=prog1_val;
            	pb1.FGColor =RGB(0,160,0);
            	pb1.BGColor =RGB(10,10,10);
            	pb1.TextColor =RGB(240,240,240);
            	pb1.DrawTextFlag =DT_VCENTER|DT_CENTER;


            	pb2.Flag    =PBF_SHOWTEXT|PBF_ORG_BOTTOM;
            	pb2.Range	=100;
            	pb2.Pos		=prog1_val;
            	pb2.FGColor =RGB(200,0,0);
            	pb2.BGColor =RGB(10,10,200);
            	pb2.TextColor =RGB(1,1,1);
            	pb2.DrawTextFlag =DT_VCENTER|DT_CENTER;

                GetClientRect(hwnd,&rc0);
                CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL);

                i=RectH(&rc0)-(3*30);
                CreateWindow(CHECKBOX,"显示文字",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+0*32,128,24,hwnd,ID_SHOWTEXT,NULL);
                CreateWindow(CHECKBOX,"增长方向",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+1*32,128,24,hwnd,ID_ORG,NULL);
 //               CreateWindow(CHECKBOX,"改变颜色",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+2*32,128,24,hwnd,ID_COLOR,NULL);

                CreateWindow(PROGRESSBAR,"水平进度条1",WS_CHILD|PBS_HOR|WS_VISIBLE,8,16,128,28,hwnd,ID_PROGBAR1,NULL);
                CreateWindow(PROGRESSBAR,"垂直进度条2",WS_CHILD|PBS_VER|WS_VISIBLE,160,16,28,128,hwnd,ID_PROGBAR2,NULL);

                GDD_CreateTimer(hwnd,1,3000,TMR_START);
                GDD_CreateTimer(hwnd,2,100,TMR_START);

                break;
                ////
        case    MSG_TIMER:
                {
                    switch(pMsg->Param1)
                    {
                        case    1:
                        		{
									HWND wnd;

									text_align_idx++;
									if(text_align_idx>=9)
									{
										text_align_idx=0;
									}
									pb1.DrawTextFlag =text_align[text_align_idx];
									pb2.DrawTextFlag =text_align[text_align_idx];

									wnd =GetDlgItem(hwnd,ID_PROGBAR1);
									SendMessage(wnd,PBM_SETDATA,(u32)&pb1,NULL);

									wnd =GetDlgItem(hwnd,ID_PROGBAR2);
									SendMessage(wnd,PBM_SETDATA,(u32)&pb2,NULL);
                        		}
                                break;
                                /////
                        case    2:
                                {
                                	HWND wnd;

                                	if(prog1_val<=0)
                                	{
                                		prog1_val =0;
                                		prog1_inc =1;
                                	}
                                	if(prog1_val>=100)
                                	{
                                		prog1_val =100;
                                		prog1_inc =-1;
                                	}
                                	wnd =GetDlgItem(hwnd,ID_PROGBAR1);
                                	pb1.Pos =prog1_val;
                                	SendMessage(wnd,PBM_SETDATA,(u32)&pb1,NULL);

                                   	sprintf(text_buf,"进度:%d...",pb1.Pos);
                                   	SetWindowText(wnd,text_buf,1000);
                                	prog1_val += prog1_inc;

                                	if(prog2_val<=0)
                                	{
                                		prog2_val =0;
                                		prog2_inc =1;
                                	}
                                	if(prog2_val>=100)
                                	{
                                		prog2_val =100;
                                		prog2_inc =-1;
                                	}
                                	wnd =GetDlgItem(hwnd,ID_PROGBAR2);
                                	pb2.Pos =prog2_val;
                                	SendMessage(wnd,PBM_SETDATA,(u32)&pb2,NULL);

                                	sprintf(text_buf,"%d%%",pb2.Pos);
                                	SetWindowText(wnd,text_buf,1000);
                                	prog2_val += prog2_inc;


                                    InvalidateWindow(hwnd);
                                }
                                break;
                                /////
                    }
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    switch(id)
                    {
                        case ID_CLOSE:
                            if(event==BTN_UP)
                            {
                                PostMessage(hwnd,MSG_CLOSE,0,0);
                            }
                            break;
                            ////

                        case ID_SHOWTEXT:
                        	if(event==CBN_SELECTED)//复选框选中
                        	{
                        		pb1.Flag |= PBF_SHOWTEXT;
                        		pb2.Flag |= PBF_SHOWTEXT;
                			}

                        	if(event==CBN_UNSELECTED)//复选框未选中
                        	{
                        		pb1.Flag &= ~PBF_SHOWTEXT;
                        	 	pb2.Flag &= ~PBF_SHOWTEXT;
                        	}
                        	break;
                        	////
                        case	ID_ORG:
                        	 if(event==CBN_SELECTED)
                        	 {
                        	    pb1.Flag &= ~PBF_ORG_RIGHT;
                        	    pb2.Flag &= ~PBF_ORG_BOTTOM;
                        	 }

                        	 if(event==CBN_UNSELECTED)
                        	 {
                        	     pb1.Flag |= PBF_ORG_RIGHT;
                        	     pb2.Flag |= PBF_ORG_BOTTOM;
                        	 }
                        	 break;
                        	 ////
                    }

                }
                break;
                ////

        case    MSG_PAINT:
                {
                    hdc =BeginPaint(hwnd);

                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(200,200,200));
                    FillRect(hdc,&rc0);

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
Пример #8
0
//----创建窗口------------------------------------------------------------------
//描述: 该函数可以创建主窗口和子窗口(控件)
//参数:proc: 窗口过程回调函数
//      Text: 窗口文字指针
//      Style: 窗口风格(具体参考窗口风格组合说明)
//      x,y,w,h: 桌面窗口位置和大小
//      hParent: 父窗口句柄.如果是NULL,则默认桌面为父窗口.
//      WinId: 窗口Id.如果是主窗口,该参数被忽略.
//      pdata: 用户自定义附加数据.
//返回:窗口句柄.
//------------------------------------------------------------------------------
HWND    CreateWindow(WNDPROC *pfWinProc,
                    const char *Text,u32 Style,
                    s32 x,s32 y,s32 w,s32 h,
                    HWND hParent,u32 WinId,const void *pdata)
{
    WINDOW *pwin=NULL;
    struct tagGkWinRsc *pGkWin=NULL;

    if(NULL==hParent)
    {
        hParent =GetDesktopWindow();
    }

    if(HWND_Lock(hParent))
    {
        pwin =WIN_Alloc();
        if(NULL!=pwin)
        {
            //初始化窗口数据
            _InitWindow(pwin,pfWinProc,Text,Style,x,y,w,h,hParent,WinId);

            x =pwin->WinRect.left;
            y =pwin->WinRect.top;
            w =RectW(&pwin->WinRect);
            h =RectH(&pwin->WinRect);

            pGkWin =(struct tagGkWinRsc*)malloc(sizeof(struct tagGkWinRsc));

            if(Style&WS_CHILD)
            {
                if(!GK_ApiCreateGkwin(pGkWinDesktop, pGkWin,x,y,x+w,y+h,
                                    RGB(0,0,0), CN_WINBUF_BUF, pwin->Name,
                                    CN_SYS_PF_DISPLAY, 0,0,0))
                {
                    free(pGkWin);
                    return NULL;
                }

                pwin->mutex_lock =hParent->mutex_lock;  //子窗口使用父窗口锁
                pwin->pMsgQ      =hParent->pMsgQ;       //子窗口使用父窗口消息队列
                pwin->EventID   =hParent->EventID;
                pwin->Zorder     =hParent->Zorder-1;
                GK_ApiSetPrio(pGkWin,pwin->Zorder,100*mS);

            }
            else
            {
                if(!GK_ApiCreateGkwin(pGkWinDesktop, pGkWin,x,y,x+w,y+h,
                                    RGB(0,0,0), CN_WINBUF_BUF, pwin->Name,
                                    CN_SYS_PF_DISPLAY, 0,0,0))
                {
                    free(pGkWin);
                    return NULL;
                }

                pwin->mutex_lock =Lock_MutexCreate(NULL);
                pwin->pMsgQ      =GUI_CreateMsgQ(32);
                pwin->EventID   =Djy_MyEventId();
                pwin->Zorder     =hParent->Zorder-1;
                GK_ApiSetPrio(pGkWin,pwin->Zorder,100*mS);

            }
            pwin->pGkWin = pGkWin;

            //将新窗口添加到父窗口
            _AddChild(hParent,pwin);

        }
        HWND_Unlock(hParent);

        if(NULL!=pwin)
        {
            SendMessage(pwin,MSG_CREATE,(u32)pdata,0);
            InvalidateWindow(pwin);
        }

    }
    return pwin;
}
Пример #9
0
//定时消息处理函数
static ptu32_t HmiTimer(struct WindowMsg *pMsg)
{
    HWND hwnd;
    hwnd =pMsg->hwnd;
	switch(pMsg->Param1)
	{
		case    1:
				{
					HWND wnd;

					text_align_idx++;
					if(text_align_idx>=9)
					{
						text_align_idx=0;
					}
					pb1.DrawTextFlag =text_align[text_align_idx];
					pb2.DrawTextFlag =text_align[text_align_idx];

					wnd =GetDlgItem(hwnd,ID_PROGBAR1);
					SendMessage(wnd,MSG_ProcessBar_SETDATA,(u32)&pb1,0);

					wnd =GetDlgItem(hwnd,ID_PROGBAR2);
					SendMessage(wnd,MSG_ProcessBar_SETDATA,(u32)&pb2,0);
				}
				break;
		case    2:
				{
					HWND wnd;

					if(prog1_val<=0)
					{
						prog1_val =0;
						prog1_inc =1;
					}
					if(prog1_val>=100)
					{
						prog1_val =100;
						prog1_inc =-1;
					}
					wnd =GetDlgItem(hwnd,ID_PROGBAR1);
					pb1.Pos =prog1_val;
					SendMessage(wnd,MSG_ProcessBar_SETDATA,(u32)&pb1,0);

					printf(text_buf,"进度:%d...",pb1.Pos);
//					SetWindowText(wnd,text_buf,1000);
					prog1_val += prog1_inc;

					if(prog2_val<=0)
					{
						prog2_val =0;
						prog2_inc =1;
					}
					if(prog2_val>=100)
					{
						prog2_val =100;
						prog2_inc =-1;
					}
					wnd =GetDlgItem(hwnd,ID_PROGBAR2);
					pb2.Pos =prog2_val;
					SendMessage(wnd,MSG_ProcessBar_SETDATA,(u32)&pb2,0);

					printf(text_buf,"%d%%",pb2.Pos);
//					SetWindowText(wnd,text_buf,1000);
					prog2_val += prog2_inc;


					InvalidateWindow(hwnd,FALSE);
				}
				break;
	}

    return true;
}
Пример #10
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 x,y;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:
                timer_500ms_count=0;
                memset(ZigBeeTextBuf,0,sizeof(ZigBeeTextBuf));
                memset(ZigBeeTimeBuf,0,sizeof(ZigBeeTimeBuf));
                zigbee_ShowString("Zigbee Text");
                hwndZigBee =hwnd;
                GetClientRect(hwnd,&rc0);
                SetFocusWindow(hwnd);
                CreateWindow(BUTTON,"关闭",WS_BORDER|WS_DLGFRAME|WS_CHILD|BS_SIMPLE|WS_VISIBLE,RectW(&rc0)-60,RectH(&rc0)-60,56,56,hwnd,ID_CLOSE,NULL);

                SetRect(&rcZigBeeString,4,4,RectW(&rc0)-4*2,60);

                x=4;
                y=RectH(&rc0)-70;
                SetRect(&rcGroupBox_LED,x,y,100,66);
                SetRect(&rcGroupBox_CTR,x+100+4,y,100,66);

                x=rcGroupBox_LED.left+12;
                y=rcGroupBox_LED.top+18;
                CreateWindow(BUTTON,"LED1",WS_BORDER|WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+0*24,72,20,hwnd,ID_LED1,NULL);
                CreateWindow(BUTTON,"LED2",WS_BORDER|WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+1*24,72,20,hwnd,ID_LED2,NULL);

                x=rcGroupBox_CTR.left+12;
                y=rcGroupBox_CTR.top+18;
                CreateWindow(BUTTON,"组网",WS_BORDER|WS_CHILD|WS_VISIBLE,x,y+0*24,72,20,hwnd,ID_NET_ON,NULL);
                CreateWindow(BUTTON,"断开",WS_BORDER|WS_CHILD|WS_VISIBLE,x,y+1*24,72,20,hwnd,ID_NET_OFF,NULL);

                CreateWindow(BUTTON,"发送",WS_BORDER|WS_CHILD|BS_SIMPLE|WS_VISIBLE,RectW(&rc0)-60,rcGroupBox_CTR.top-(24+2),56,24,hwnd,ID_SEND,NULL);

                GDD_CreateTimer(hwnd,0,500,TMR_START);

                break;
                ////
        case MSG_KEY_DOWN:
         		break;
         		//////

        case MSG_KEY_UP:
        {
        		u16 key_val;
                hdc =BeginPaint(hwnd);
        		key_val =LO16(pMsg->Param1);
        		sprintf(ZigBeeTextBuf,"KeyVal:%04XH",key_val);
                DrawText(hdc,ZigBeeTextBuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);
                EndPaint(hwnd,hdc);
//        		InvalidateWindow(hwnd);
        }
         		break;
         		//////

        case    MSG_TIMER:
                {
                    timer_500ms_count++;

                    sprintf(ZigBeeTimeBuf,"TIME:%06d",timer_500ms_count);

                    /*
                    i=SendMessage(GetDesktopWindow(),MSG_GET_POS,timer_500ms_count,0);
                    printf("i=%08XH.\r\n",i);
                    */
                    InvalidateWindow(hwnd);
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    switch(event)
                    {
                        case BTN_DOWN:  //按钮按下
                            if(id==ID_LED1)
                            {
                                zigbee_LED1_ON();
                            }

                            if(id==ID_LED2)
                            {
                                zigbee_LED2_ON();
                            }

                            if(id==ID_NET_ON)
                            {
                                zigbee_NET_ON();
                            }

                            if(id==ID_NET_OFF)
                            {
                                zigbee_NET_OFF();
                            }

                            if(id==ID_SEND)
                            {
                                zigbee_send_string(ZigBeeTextBuf);
                            }
                            break;
                            ////

                        case BTN_UP:    //按钮弹起
                            if(id==ID_CLOSE)
                            {
                                PostMessage(hwnd,MSG_CLOSE,0,0);
                            }

                            if(id==ID_LED1)
                            {
                                zigbee_LED1_OFF();
                            }

                            if(id==ID_LED2)
                            {
                                zigbee_LED2_OFF();
                            }


                            break;
                            ////



                    }

                }
                break;
                ////

        case    MSG_PAINT:
                {

                    hdc =BeginPaint(hwnd);
                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(150,150,150));
                    FillRect(hdc,&rc0);

                    SetTextColor(hdc,RGB(0,0,128));
                    SetDrawColor(hdc,RGB(100,100,100));
                    DrawGroupBox(hdc,&rcZigBeeString,"信息接收区");

                    ////
                    SetRect(&rc,
                            rcGroupBox_LED.left,
                            rcGroupBox_LED.top-(24+2),
                            RectW(&rcGroupBox_LED),
                            24);

                    if(zigbee_is_ok())
                    {
                        SetTextColor(hdc,RGB(0,255,0));
                        SetDrawColor(hdc,RGB(0,200,0));
                        SetFillColor(hdc,RGB(0,128,0));
                        DrawText(hdc,"连接成功",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);

                    }
                    else
                    {
                        SetTextColor(hdc,RGB(255,0,0));
                        SetDrawColor(hdc,RGB(200,0,0));
                        SetFillColor(hdc,RGB(100,0,0));
                        if(timer_500ms_count&0x01)
                        {
                            DrawText(hdc,"未连接",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);

                        }
                        else
                        {
                            DrawText(hdc," ",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);
                        }

                    }

                    ////
                    SetRect(&rc,
                            rcGroupBox_CTR.left,
                            rcGroupBox_CTR.top-(24+2),
                            RectW(&rcGroupBox_CTR),
                            24);
                    SetTextColor(hdc,RGB(0,255,255));
                    SetDrawColor(hdc,RGB(0,200,200));
                    SetFillColor(hdc,RGB(0,80,80));
                    DrawText(hdc,ZigBeeTimeBuf,-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);

                    ////
                    SetTextColor(hdc,RGB(0,255,0));
                    SetDrawColor(hdc,RGB(0,200,0));
                    SetFillColor(hdc,RGB(0,80,0));

                    CopyRect(&rc,&rcZigBeeString);
                    InflateRectEx(&rc,-4,-20,-4,-4);
                    DrawText(hdc,ZigBeeTextBuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);

                    SetTextColor(hdc,RGB(0,0,128));
                    SetDrawColor(hdc,RGB(80,80,80));
                    DrawGroupBox(hdc,&rcGroupBox_LED,"LED控制");
                    DrawGroupBox(hdc,&rcGroupBox_CTR,"网络控制");

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
Пример #11
0
void  zigbee_ShowString(const char *buf)
{
    memcpy(ZigBeeTextBuf,buf,256);
    InvalidateWindow(hwndZigBee);
}