/*========================================================================================*/ void GDD_Demo_Progressbar(void) { struct WindowMsg msg; RECT rc; GetClientRect(GetDesktopWindow(),&rc); //创建主窗口 s_gHmiMsgLink.LinkNext = NULL; s_gHmiMsgLink.MsgNum = sizeof(s_gHmiMsgDemoTable) / sizeof(struct MsgProcTable); s_gHmiMsgLink.myTable = (struct MsgProcTable *)&s_gHmiMsgDemoTable; g_ptMainHwnd = CreateWindow("进度条控件演示",WS_MAIN_WINDOW, rc.left,rc.top,RectW(&rc),RectH(&rc), NULL,0x0000, CN_WINBUF_PARENT,NULL,&s_gHmiMsgLink); SetFocusWindow(g_ptMainHwnd);//设置为焦点窗口 SetWindowShow(g_ptMainHwnd); while(GetMessage(&msg,g_ptMainHwnd)) { DispatchMessage(&msg); } printf("win2_exit progress bar.\r\n"); }
//----销毁一个窗口-------------------------------------------------------------- //描述: 可以是主窗口和子窗口,除了删除自身窗口结构,还将发送WSG_DESTROY消息给父窗口. //参数:hwnd:需要销毁的窗口句柄 //返回:无. //------------------------------------------------------------------------------ void DestroyWindow(HWND hwnd) { if(IsFocusWindow(hwnd)) { SetFocusWindow(NULL); } UpdateDisplay(); GDD_Lock(); if(HWND_Lock(hwnd)) { _DestroyChildWindow(hwnd); SendMessage(hwnd,MSG_DESTROY,0,0); if(hwnd->Style&WS_CHILD) { _DeleteChildWindowData(hwnd); } HWND_Unlock(hwnd); } GDD_Unlock(); }
/* When a window is unmapped (or destroyed) this function takes care of * adjusting the focus window appropriately. */ void restore_focus_after_unmap( FvwmWindow *tmp_win, Bool do_skip_marked_transients) { extern FvwmWindow *colormap_win; FvwmWindow *t = NULL; FvwmWindow *set_focus_to = NULL; if (tmp_win == get_focus_window()) { if (tmp_win->transientfor != None && tmp_win->transientfor != Scr.Root) { for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) { if (t->w == tmp_win->transientfor && t->Desk == tmp_win->Desk && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { set_focus_to = t; break; } } } if (!set_focus_to && (HAS_CLICK_FOCUS(tmp_win) || HAS_SLOPPY_FOCUS(tmp_win))) { for (t = tmp_win->next; t != NULL; t = t->next) { if (t->Desk == tmp_win->Desk && !DO_SKIP_CIRCULATE(t) && !(IS_ICONIFIED(t) && ( DO_SKIP_ICON_CIRCULATE(t) || IS_ICON_SUPPRESSED(t))) && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { /* If it is on a different desk we have to look for another window */ set_focus_to = t; break; } } } if (set_focus_to && set_focus_to != tmp_win && set_focus_to->Desk == tmp_win->Desk) { /* Don't transfer focus to windows on other desks */ SetFocusWindow(set_focus_to, 1); } if (tmp_win == get_focus_window()) { DeleteFocus(1); } } if (tmp_win == Scr.pushed_window) Scr.pushed_window = NULL; if (tmp_win == colormap_win) { InstallWindowColormaps(set_focus_to); } return; }
static FvwmWindow *__restore_focus_after_unmap( const FvwmWindow *fw, Bool do_skip_marked_transients) { FvwmWindow *t = NULL; FvwmWindow *set_focus_to = NULL; t = get_transientfor_fvwmwindow(fw); if (t != NULL && FP_DO_RELEASE_FOCUS_TRANSIENT(FW_FOCUS_POLICY(fw)) && !FP_DO_OVERRIDE_RELEASE_FOCUS(FW_FOCUS_POLICY(t)) && t->Desk == fw->Desk && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { set_focus_to = t; } else if (t == NULL && FP_DO_RELEASE_FOCUS(FW_FOCUS_POLICY(fw))) { for (t = fw->next; t != NULL && set_focus_to == NULL; t = t->next) { if (!FP_DO_OVERRIDE_RELEASE_FOCUS( FW_FOCUS_POLICY(t)) && t->Desk == fw->Desk && !DO_SKIP_CIRCULATE(t) && !(IS_ICONIFIED(t) && (DO_SKIP_ICON_CIRCULATE(t) || IS_ICON_SUPPRESSED(t))) && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { /* If it is on a different desk we have to look * for another window */ set_focus_to = t; } } } if (set_focus_to && set_focus_to != fw && set_focus_to->Desk == fw->Desk) { /* Don't transfer focus to windows on other desks */ SetFocusWindow(set_focus_to, True, FOCUS_SET_FORCE); } if (focus_is_focused(fw)) { DeleteFocus(True); } return set_focus_to; }
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; }