📄 win_locset.c
字号:
/*win_locSet.c*//*** COMPANY NAME: 国星** FILE NAME: win_locSet.c** FILE PATH: Interface/win_locSet.c** WINDOWS NAME: 定位设置** WINDOWS PATH: 定位 / 定位设置** OTHER INFORMATION; 无** CREATER NAME: LiWencheng,JiangYuanqing** MENDER NAME: LiWencheng,JiangYuanqing** CHANGE TIME: 11/14/2007 */#include "sysSrcInfo.h"#include "MobileSystem.h"static HWND hWndMainlocSet; //flagLocSet=1返回单次,2返回连续,3返回紧急,4返回win_locate static int flagLocSet;static BITMAP bmp_locSet; //缓存中间状态栏图片static HWND locFrequency;static HWND highMethodCombox;static HWND highDirectionCombox;static HWND editboxCon[4];/* 位图数组 */static long GetGeWei(long num){ return (long)(num%10);}static const char *bmp_name_locSet[] = { "./Pictures/b_windowsbackground_1.PNG", "./Pictures/OK.PNG", "./Pictures/c_hide.PNG", "./Pictures/return.PNG" };/* 定义皮肤元素数组 *///三个button 为左中右,并不表示它就一定指OK或MENUstatic skin_item_t skin_items_locSet [] ={ {SIID_OK, SI_TYPE_CHKBUTTON | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, BUTTONLEFT_X, BUTTON_Y, {}, 1 ,"" }, {SIID_MENU, SI_TYPE_CHKBUTTON | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, BUTTONCENTER_X, BUTTON_Y, {}, 2, "" }, {SIID_RETURN, SI_TYPE_CHKBUTTON | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, BUTTONRIGHT_X, BUTTON_Y, {}, 3, "" }};/* 定义皮肤 */skin_head_t skin_locSet ={ "main", //const BITMAP* bmps; SKIN_STYLE_TOOLTIP, NULL, NULL, 0, 3, skin_items_locSet, FALSE /** The number of the items in this skin. */ /* 定义皮肤元素数组 */};static const char *icon_labels_locSet[] = { "定位频度", "测高方式", "高程指示", "高 程", "天 线", "气 压", "温 度" };static const char *icon_labelsDanWei_locSet[] = { " 秒", "", "", " 米", " 米", "百帕", " ℃" };static const char *highMethod_locSet[] = { "有高程", "无测高", "测高1", "测高2",};static const char *highDirection_locSet[] = { "普通", "高空",};static void CloseWindow_locSet(){ LoadSkinBmps( &skin_locSet, FALSE ,bmp_name_locSet ,(sizeof (bmp_name_locSet))/sizeof(char *) ); ShowWindow ( hWndMainlocSet, SW_HIDE); UnloadBitmap( &bmp_locSet );}static int main_event_cb_locSet (HWND hwnd, skin_item_t* item, int event, void* data){ char buff[9]; LOCSET theLocSet; int hMSel = SendMessage (highMethodCombox, CB_GETCURSEL, 0, 0 ); int hDc = SendMessage (highDirectionCombox, CB_GETCURSEL, 0, 0 ); int num; if (event == SIE_BUTTON_CLICKED) { switch (item->id) { //按的那个图片 case SIID_OK: printf("-------- main_event_cb_locSet ----------\n"); GetWindowText (locFrequency, buff ,9); num = atoi(buff); if ( num <= GetServFreq ()) { theLocSet.locFrequency = GetServFreq (); SetMutiReportFreq( GetServFreq () ); sprintf(buff,"%d",GetServFreq ()); SetWindowText (locFrequency, buff); } else { theLocSet.locFrequency = num; SetMutiReportFreq( num ); } theLocSet.ceGaoMode = SendMessage (highMethodCombox, CB_GETCURSEL, 0, 0 ); theLocSet.heightMode = SendMessage (highDirectionCombox, CB_GETCURSEL, 0, 0 ); GetWindowText (editboxCon[0], buff ,9); if ( atol(buff) >= 0) { theLocSet.loc_AltitudeSign = 0; theLocSet.height = atol(buff); } else { theLocSet.loc_AltitudeSign = 1; theLocSet.height = -atol(buff); } GetWindowText (editboxCon[1], buff ,9); if (hMSel == 1 && hDc==1 && atol(buff) < 400) { SetWindowText(editboxCon[1] ,"400"); } GetWindowText (editboxCon[1], buff ,9); theLocSet.tianXian = atol(buff); GetWindowText (editboxCon[2], buff ,9); theLocSet.qiYa = atof(buff)*10; printf("atof(buff)*10--------%f-\n",atof(buff)*10); printf("(long)atof(buff)*10--------%ld-\n",(long)(atof(buff)*10)); GetWindowText (editboxCon[3], buff ,9); printf("--------theLocSet.temper---------%f-\n",atof(buff)); if (atof(buff) >= 0) { theLocSet.temperatureValSign = 0; theLocSet.temper = atof(buff)*10; } else { theLocSet.temperatureValSign = 1; theLocSet.temper = -atof(buff)*10; } printf("--------theLocSet.temper---------%ld-\n",theLocSet.temper); SetLocSet (theLocSet); break;//case SIID_OK: case SIID_RETURN://right if (flagLocSet>=1 && flagLocSet<=3) { win_loclocate (hWndMain,flagLocSet); } else { win_locate (hWndMain); } CloseWindow_locSet(); break; } } return 1;}static void SwitchMode( void ){ char buff[10]; int hMSel = SendMessage (highMethodCombox, CB_GETCURSEL, 0, 0 ); int hDc = SendMessage (highDirectionCombox, CB_GETCURSEL, 0, 0 ); printf("==========Enter SwitchMode=============\n"); switch (hMSel) { case 0://"有高程", if(hDc==0)//"普通", { EnableWindow( editboxCon[0],TRUE); EnableWindow( editboxCon[1],TRUE); } else//"高空", { printf("==========Enter else//gaokong,=============\n"); EnableWindow( editboxCon[0],TRUE); EnableWindow( editboxCon[1],FALSE); } break; case 1://"无测高", if(hDc==0)//"普通", { EnableWindow( editboxCon[1],TRUE); EnableWindow( editboxCon[0],TRUE); } else//"高空", { EnableWindow( editboxCon[0],FALSE); EnableWindow( editboxCon[1],TRUE); SetWindowText(editboxCon[2],"0"); SetWindowText(editboxCon[3],"0"); } break; case 2://"测高1", if(hDc==0)//"普通", { EnableWindow( editboxCon[0],TRUE); EnableWindow( editboxCon[1],TRUE); } else//"高空", { EnableWindow( editboxCon[0],TRUE); EnableWindow( editboxCon[1],TRUE); } break; case 3://"测高2", if(hDc==0)//"普通", { EnableWindow( editboxCon[0],TRUE); EnableWindow( editboxCon[1],TRUE); GetWindowText (editboxCon[0], buff ,9); } else//"高空", { EnableWindow( editboxCon[0],TRUE); EnableWindow( editboxCon[1],TRUE); EnableWindow( editboxCon[2],TRUE); EnableWindow( editboxCon[3],TRUE); } break; }}static void CheckVal( void ){ char buff[10]; int hMSel = SendMessage (highMethodCombox, CB_GETCURSEL, 0, 0 ); int hDc = SendMessage (highDirectionCombox, CB_GETCURSEL, 0, 0 ); switch (hMSel) { case 0://"有高程", if(hDc==0)//"普通", { GetWindowText (editboxCon[0], buff ,9); if ( atol(buff) > 32700) { SetWindowText (editboxCon[0], "32700"); SetFocusChild(editboxCon[1]); } if ( atol(buff) < -16384) { SetWindowText (editboxCon[0], "-16384"); SetFocusChild(editboxCon[1]); } } else//"高空", { GetWindowText (editboxCon[0], buff ,9); if ( atol(buff) > 134217727) { SetWindowText(editboxCon[0], "134217727"); SetFocusChild(editboxCon[2]); } if ( atol(buff) < -67108863) { SetWindowText(editboxCon[0],"-67108863"); SetFocusChild(editboxCon[2]); } } break; case 1://"无测高", if(hDc==0)//"普通", { GetWindowText (editboxCon[1], buff ,9); printf(" Currwent val atol(buff) is %d\n",atol(buff) ); if ( atol(buff) > 400) { SetWindowText(editboxCon[1], "400"); SetFocusChild(editboxCon[2]); } if ( atol(buff) < 0) { SetWindowText(editboxCon[1],"0"); SetFocusChild(editboxCon[2]); } } else//"高空", { //SetFocusChild(editboxCon[1]); GetWindowText (editboxCon[1], buff ,9); if ( atol(buff) > 67108863) { SetWindowText(editboxCon[1], "67108863"); // SetFocusChild(locFrequency); } if ( atol(buff) < 400) { //SetWindowText(editboxCon[1] ,"400"); //SetFocusChild(locFrequency); } } break; case 2://"测高1", if(hDc==0)//"普通", { } else//"高空", { } break; case 3://"测高2", if(hDc==0)//"普通", { GetWindowText (editboxCon[0], buff ,9); if ( atol(buff) > 32767) { SetWindowText(editboxCon[0], "32767"); SetFocusChild(editboxCon[1]); } else if ( atol(buff) < -16383) { SetWindowText(editboxCon[0],"-16383"); SetFocusChild(editboxCon[1]); } GetWindowText (editboxCon[1], buff ,9); if ( atol(buff) > 400) { SetWindowText(editboxCon[1], "400"); SetFocusChild(editboxCon[2]); } if ( atol(buff) < 0) { SetWindowText(editboxCon[1], "0"); SetFocusChild(editboxCon[2]); } } else//"高空", { GetWindowText (editboxCon[0], buff ,9); if ( atol(buff) > 134217727) { SetWindowText(editboxCon[0], "134217727"); SetFocusChild(editboxCon[1]); } else if ( atol(buff) < 0) { SetWindowText(editboxCon[0], "0"); SetFocusChild(editboxCon[1]); } } break; }}static void editboxCon0_notif_proc( HWND hwnd, int id, int nc, DWORD add_data ){ if( nc ==EN_CHANGE ) { printf(" Enter editboxCon0_notif.\n"); CheckVal(); } }static void editboxCon1_notif_proc( HWND hwnd, int id, int nc, DWORD add_data ){ if( nc ==EN_CHANGE ) { printf(" Enter editboxCon1_notif.\n"); CheckVal(); } }static void editboxCon2_notif_proc( HWND hwnd, int id, int nc, DWORD add_data ){ if( nc ==EN_CHANGE ) { printf(" Enter editboxCon2_notif.\n"); CheckVal( ); } }static void editboxCon3_notif_proc( HWND hwnd, int id, int nc, DWORD add_data ){ if( nc ==EN_CHANGE ) CheckVal( ); }static void highMethodCombox_notif_proc(HWND hwnd, int id, int nc, DWORD add_data){ //printf("==========Enter highMethodCombox=============\n"); if(nc==CBN_SELCHANGE) { printf("==========Enter CBN_SELCHANGE=============\n"); SwitchMode( ); }}static void highDirection_notif_proc(HWND hwnd, int id, int nc, DWORD add_data){ if(nc==CBN_SELCHANGE) { SwitchMode( ); }}static int msg_event_cb_locSet (HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int* result){ HDC hdc; int i; long num; char buff[9]; LOCSET *pLocSet; IVITEMINFO ivii_child; gal_pixel pixel = RGB2Pixel (HDC_SCREEN, 0xFF, 0xFF, 0xFF); switch (message) { case MSG_CREATE: //pLocSet = (LOCSET *)GetLocSet(); GetLocSet( &pLocSet); printf("&pLocSet ==%X\n",pLocSet); LoadBitmap (HDC_SCREEN, &bmp_locSet, "Pictures/a_location_5.PNG"); locFrequency = CreateWindow( CTRL_SLEDIT, "0", WS_VISIBLE | WS_CHILD | WS_BORDER ,//|ES_READONLY ,// | ES_AUTOWRAP, 631, 65, 22,65 , 15, hwnd, 0); sprintf(buff,"%d",pLocSet->locFrequency ); SetWindowText (locFrequency , buff); highMethodCombox = CreateWindow( CTRL_COMBOBOX, "", WS_CHILD | WS_VISIBLE | CBS_EDITNOBORDER|CBS_NOTIFY| CBS_READONLY|CBS_SPINARROW_LEFTRIGHT |CBS_SPINLIST, 2343,65, 38,77 , 18, hwnd, 0); //SetWindowBkColor (highMethodCombox, pixel); for (i = 0;i<4;i++) { SendMessage (highMethodCombox, CB_ADDSTRING, 0, (LPARAM)highMethod_locSet[i]); } SetNotificationCallback (highMethodCombox, highMethodCombox_notif_proc); SendMessage (highMethodCombox, CB_SETCURSEL, pLocSet->ceGaoMode,0); highDirectionCombox = CreateWindow( CTRL_COMBOBOX, "", WS_CHILD | WS_VISIBLE | CBS_EDITNOBORDER|CBS_NOTIFY| CBS_READONLY|CBS_SPINARROW_LEFTRIGHT |CBS_SPINLIST, 2343,65, 54,77 , 18, hwnd, 0); //SetWindowBkColor (highDirectionCombox, pixel); for (i = 0;i<2;i++) { SendMessage (highDirectionCombox, CB_ADDSTRING, 0, (LPARAM)highDirection_locSet[i]); } SetNotificationCallback (highDirectionCombox, highDirection_notif_proc); SendMessage (highDirectionCombox, CB_SETCURSEL, pLocSet->heightMode,0); for (i = 0;i<4;i++) { editboxCon[i] = CreateWindow( CTRL_SLEDIT, "0", WS_VISIBLE | WS_CHILD | WS_BORDER , 633, 65, 70+ i*16 , 65 , 16, hwnd, 0); } SendMessage (editboxCon[0], EM_LIMITTEXT, 9,0L);//set length of SendMessage (editboxCon[1], EM_LIMITTEXT, 8,0L);//set length of SendMessage (editboxCon[2], EM_LIMITTEXT, 5,0L);//set length of SendMessage (editboxCon[3], EM_LIMITTEXT, 5,0L);//set length of if (pLocSet->loc_AltitudeSign == 0) { sprintf(buff,"%d",pLocSet->height); SetWindowText (editboxCon[0] , buff); } else if(pLocSet->loc_AltitudeSign == 1) { sprintf(buff,"-%d",pLocSet->height); SetWindowText (editboxCon[0] , buff); }else printf("err loc_AltitudeSign"); sprintf(buff,"%ld",pLocSet->tianXian); SetWindowText (editboxCon[1] , buff); //sprintf(buff,"%-6.2f",(pLocSet->qiYa)*0.1); num = GetGeWei(pLocSet->qiYa); printf ("pLocSet->qiYa ------%ld\n",pLocSet->qiYa); printf ("num ------%ld\n",num); printf ("((pLocSet->qiYa - num)*0.1 ------%f\n",(pLocSet->qiYa - num)*0.1); printf ("((pLocSet->qiYa - num)*0.1 ------%ld\n",(long)((pLocSet->qiYa - num)*0.1)); sprintf(buff,"%ld.%ld",(long)((pLocSet->qiYa - num)*0.1),num); SetWindowText (editboxCon[2] , buff); printf("--------theLocSet.qiYa---------%d-\n",pLocSet->qiYa); if (pLocSet->temperatureValSign == 0) { sprintf(buff,"%-5.3f",(pLocSet->temper)*0.1); SetWindowText (editboxCon[3] , buff); } else if (pLocSet->temperatureValSign == 1) { sprintf(buff,"-%-5.3f",(pLocSet->temper)*0.1); SetWindowText (editboxCon[3] , buff); } SetNotificationCallback (editboxCon[0] , editboxCon0_notif_proc); SetNotificationCallback (editboxCon[1] , editboxCon1_notif_proc); SetNotificationCallback (editboxCon[2] , editboxCon2_notif_proc); SetNotificationCallback (editboxCon[3] , editboxCon3_notif_proc); break; case MSG_PAINT : hdc=BeginPaint (hwnd); SetBkMode (hdc, BM_TRANSPARENT); FillBoxWithBitmap (hdc, ZTL_PIC_X,ZTL_PIC_Y, ZTL_PIC_W,ZTL_PIC_H, &bmp_locSet); TextOut (hdc, WZ_ZTL_X4, WZ_ZTL_Y, "定位设置" ); for (i=0;i<7;i++) { TextOut (hdc, RJ_X ,20+i * 17, icon_labels_locSet[i]); TextOut (hdc, 129 ,20+i * 17, icon_labelsDanWei_locSet[i]); } EndPaint (hwnd,hdc); break; } return 1;}void win_locSet(HWND hwndmain ,int flag){ MSG msg; flagLocSet = flag;//flag=1返回单次,2返回连续,3返回紧急,4返回win_locate LoadSkinBmps( &skin_locSet, TRUE ,bmp_name_locSet ,(sizeof (bmp_name_locSet))/sizeof(char *) ); if (skin_locSet.bmps == NULL) { printf ("Could not load skin bitmaps!\n"); } if ( !skin_init (&skin_locSet, main_event_cb_locSet, msg_event_cb_locSet) ){ /* 初始化皮肤 */ printf ("skin init fail!\n\n"); } else{ hWndMainlocSet= create_skin_control (&skin_locSet, hwndmain,143, DEF_X_, DEF_Y_, DEF_WIDTH, DEF_HEIGHT); currShowWindowHwnd = hWndMainlocSet; }}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -