/* 按钮消息回调函数 */ static int BtnProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { int temp; switch(message){ case MSG_SETFOCUS:{ SetWindowBkColor(hWnd, SETFOCUS_COLOR); SendMessage(editHelp, MSG_PAINT, 0, (LPARAM)GetDlgCtrlID(hWnd)); }break; case MSG_KILLFOCUS:{ SetWindowBkColor(hWnd, KILLFOCUS_COLOR); }break; } temp = (*OldBtnProc)(hWnd, message, wParam, lParam); return(temp); }
/* 帮助控件回调函数 */ static int EditProcHelp(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { int temp; int id; char strHelp[200] = {0}; //设置帮助栏背景框颜色和字体颜色 SetWindowBkColor(hWnd,COLOR_black); #ifdef FONTCOLOR SetWindowElementColorEx( hWnd, FGC_CONTROL_NORMAL,COLOR_yellow); #endif switch(message){ case MSG_PAINT:{ id = lParam; switch(id){ case DID_CO2SET_SET_ALMCLASS:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_alarm_class", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_CO2SET_SET_ALMPRINT:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_alarm_print", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_CO2SET_SET_HIGH_ETCO2:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_co2_high_etco2", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_CO2SET_SET_LOW_ETCO2:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_co2_low_etco2", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_CO2SET_SET_HIGH_FICO2:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_co2_high_fico2", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_CO2SET_OK:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_exit", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; default:{ SetWindowText(hWnd, ""); }break; }break; }break; } temp = (*OldEditProcHelp)(hWnd, message, wParam, lParam); return(temp); }
/* 帮助控件回调函数 */ static int EditProcHelp(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { int temp; int id; char strHelp[200] = {0}; //设置帮助栏背景框颜色和字体颜色 SetWindowBkColor(hWnd,COLOR_black); #ifdef FONTCOLOR SetWindowElementColorEx( hWnd, FGC_CONTROL_NORMAL,COLOR_yellow); #endif switch(message){ case MSG_PAINT:{ id = lParam; switch(id){ case DID_RECORDER_WAVE1:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, STR_SETTING_DLG_PRINTER, "help_printer_wave1", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_RECORDER_WAVE2:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, STR_SETTING_DLG_PRINTER, "help_printer_wave2", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_RECORDER_WAVE3:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, STR_SETTING_DLG_PRINTER, "help_printer_wave3", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_RECORDER_DURATION:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, STR_SETTING_DLG_PRINTER, "help_printer_length", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_RECORDER_SPEED:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes,STR_SETTING_DLG_PRINTER, "help_printer_speed", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_RECORDER_OK:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, STR_SETTING_GENERAL, "help_previous", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; default:{ SetWindowText(hWnd, ""); }break; }break; }break; } temp = (*OldEditProcHelp)(hWnd, message, wParam, lParam); return(temp); }
static void draw_hilighted_item(HWND hDlg, HDC hdc) { LicensePlate_CtrlInfo_t* ctrlInfo; HWND hwndWidget; int prevSel; RECT rect; int x, y, w, h; gal_pixel hilightColor, normalColor; hilightColor = RGBA2Pixel(HDC_SCREEN, 0xDC, 0xDC, 0xDC, 0xFF); // hilightColor = RGBA2Pixel(HDC_SCREEN, 0x00, 0xFF, 0x99, 0xFF); normalColor = RGBA2Pixel(HDC_SCREEN, 0x99, 0x99, 0x99, 0xFF); ctrlInfo = (LicensePlate_CtrlInfo_t*)GetWindowAdditionalData(hDlg); if(ctrlInfo != NULL) { if(ctrlInfo->curSel >= 0) { hwndWidget = GetDlgItem(hDlg, ID_NUMBER_START + ctrlInfo->curSel); GetWindowRect(hwndWidget, &rect); w = ctrlInfo->pBmpArrow->bmWidth; h = ctrlInfo->pBmpArrow->bmHeight; x = rect.left; y = rect.top - h - 4; if(w < RECTW(rect)) { x = rect.left + ( (RECTW(rect) - w) >> 1 ); } FillBoxWithBitmap(hdc, x, y, w, h, ctrlInfo->pBmpArrow); if(hwndWidget && hwndWidget != HWND_INVALID) { SetWindowBkColor(hwndWidget, hilightColor ); } prevSel = ctrlInfo->curSel - 1; if(prevSel >= 0) { hwndWidget = GetDlgItem(hDlg, ID_NUMBER_START + prevSel ); if(hwndWidget && hwndWidget != HWND_INVALID) { SetWindowBkColor(hwndWidget, normalColor ); } } } else {
static int create_cont_toolbar (HWND hwnd) { HWND ntb; NTBINFO ntb_info; NTBITEMINFO ntbii; gal_pixel pixel; int i; ntb_info.nr_cells = 3; ntb_info.w_cell = 0; ntb_info.h_cell = 0; ntb_info.nr_cols = 0; if (LoadBitmapFromMem (HDC_SCREEN, &cont_ntb_bmp, cont_bmp, sizeof(cont_bmp), "gif") < 0) return -1; ntb_info.image = &cont_ntb_bmp; ntb = CreateWindow (CTRL_NEWTOOLBAR, "", WS_CHILD | WS_VISIBLE, IDC_CONT_NTB, 1, 0, CONT_WIN_WIDTH - 2, 20, hwnd, (DWORD) &ntb_info); pixel = GetPixelInBitmap (ntb_info.image, 0, 0); SetWindowBkColor (ntb, pixel); InvalidateRect (ntb, NULL, TRUE); for (i = 0; i < 3; i++) { memset (&ntbii, 0, sizeof (ntbii)); ntbii.flags = NTBIF_PUSHBUTTON; ntbii.id = IDC_NTB_LOGO + i; ntbii.bmp_cell = i; ntbii.text = ""; SendMessage (ntb, NTBM_ADDITEM, 0, (LPARAM)&ntbii); } SetNotificationCallback (ntb, ntb_proc); return 0; }
/* 帮助控件回调函数 */ static int EditProcHelp(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { int temp; int id; char strHelp[200] = {0}; SetWindowBkColor(hWnd,COLOR_black); #ifdef FONTCOLOR SetWindowElementColorEx( hWnd, FGC_CONTROL_NORMAL,COLOR_yellow); #endif switch(message){ case MSG_PAINT:{ id = lParam; switch(id){ case DID_IBP2_SET_LABEL:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_label", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_SET_UNIT:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_unit", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_SET_VIEW:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_view", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_SET_SPEED:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_speed", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_SET_TOP:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_scale_top", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_SET_MIDDLE:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_scale_middle", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_SET_BOTTOM:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_scale_bottom", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_SET_ALARM:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_set_alarm", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_ZERO:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_zero", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_OK:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_exit", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; case DID_IBP2_FILTER:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFile(gsLanguageRes, "HELP", "help_ibp_filter", strHelp, sizeof strHelp); SetWindowText(hWnd, strHelp); }break; default:{ SetWindowText(hWnd, ""); }break; }break; }break; } temp = (*OldEditProcHelp)(hWnd, message, wParam, lParam); return(temp); }
static int HelloWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { HDC hdc; static HWND hwnd; static int i = 0; switch (message) { case MSG_PAINT: hdc = BeginPaint (hWnd); TextOut (hdc, 60, 60, "Hello world!"); EndPaint (hWnd, hdc); return 0; case 888888888888888888: { HDC hdc2 = (HDC)wParam; const RECT* clip = (const RECT*) lParam; BOOL fGetDC = FALSE; RECT rcTemp; if (hdc2 == 0) { hdc2 = GetClientDC (hWnd); fGetDC = TRUE; } if (clip) { rcTemp = *clip; ScreenToClient (hWnd, &rcTemp.left, &rcTemp.top); ScreenToClient (hWnd, &rcTemp.right, &rcTemp.bottom); IncludeClipRect (hdc2, &rcTemp); } FillBoxWithBitmap (HDC_SCREEN, 0, 0, 0, 0, &bmp_bkgnd); if (fGetDC) ReleaseDC (hdc2); return 0; } break; case MSG_CREATE: hwnd = CreateWindowEx("static", "", WS_CHILD | WS_VISIBLE, WS_EX_NONE, 123, 0, 0, 50, 50, hWnd, NULL); SetWindowBkColor(hwnd, RGBA2Pixel(HDC_SCREEN, 0x00, 0x00, 0xff, 0x10)); break; case MSG_KEYDOWN: if (i) { SetWindowBkColor(hwnd, RGBA2Pixel(HDC_SCREEN, 0x00, 0x00, 0xff, 0x10)); } else { SetWindowBkColor(hwnd, RGB2Pixel(HDC_SCREEN, 0x00, 0xff, 0xff)); } i = 1-i; break; case MSG_CLOSE: DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc (hWnd, message, wParam, lParam); }
static int BookProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam) { switch (message) { case MSG_INITDIALOG: { SVITEMINFO svii; static int i = 0; hScrollView = GetDlgItem (hDlg, IDC_SCROLLVIEW); SetWindowBkColor (hScrollView, PIXEL_lightwhite); SendMessage (hScrollView, SVM_SETITEMCMP, 0, (LPARAM)myCmpItem); SendMessage (hScrollView, SVM_SETITEMDRAW, 0, (LPARAM)myDrawItem); for (i = 0; i < TABLESIZE(people); i++) { svii.nItemHeight = 32; svii.addData = (DWORD)people[i]; svii.nItem = i; SendMessage (hScrollView, SVM_ADDITEM, 0, (LPARAM)&svii); SendMessage (hScrollView, SVM_SETITEMADDDATA, i, (DWORD)people[i]); } break; } case MSG_COMMAND: { int id = LOWORD (wParam); int code = HIWORD (wParam); switch (id) { case IDC_SCROLLVIEW: if (code == SVN_CLICKED) { int sel; const char *info; sel = SendMessage (hScrollView, SVM_GETCURSEL, 0, 0); info = (const char *)SendMessage (hScrollView, SVM_GETITEMADDDATA, sel, 0); } break; } break; } case MSG_KEYDOWN: if (wParam == SCANCODE_REMOVE) { int idx = SendMessage (hScrollView, SVM_GETCURSEL, 0, 0); SendMessage (hScrollView, SVM_DELITEM, idx, 0); SendMessage (hScrollView, SVM_SETCURSEL, idx, 0); return 0; } break; case MSG_CLOSE: { EndDialog (hDlg, 0); return 0; } } return DefaultDialogProc (hDlg, message, wParam, lParam); }
/* window procedure of the property sheet. */ static int PropSheetCtrlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam) { PCONTROL ctrl; PPROPSHEETDATA propsheet; ctrl = gui_Control (hwnd); propsheet = (PROPSHEETDATA *) ctrl->dwAddData2; switch (message) { case MSG_CREATE: { #ifdef __TARGET_MSTUDIO__ SetWindowBkColor(hwnd, GetWindowElementPixel (hwnd, WE_MAINC_THREED_BODY)); #endif if (!(propsheet = calloc (1, sizeof (PROPSHEETDATA)))) { return -1; } ctrl->dwAddData2 = (DWORD)propsheet; break; } /* make the client size same as window size */ case MSG_SIZECHANGED: { const RECT* rcWin = (RECT *)wParam; RECT* rcClient = (RECT *)lParam; /* cale the width of content page */ *rcClient = *rcWin; propsheet->head_rc.right = RECTWP (rcClient); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { propsheet->head_rc.top = RECTHP (rcClient) - get_metrics (MWM_ICONY) - 2 - _ICON_OFFSET * 2; propsheet->head_rc.bottom = RECTHP (rcClient); } else { propsheet->head_rc.bottom = get_metrics (MWM_ICONY) + 2 + _ICON_OFFSET * 2; } if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { HDC hdc; propsheet->head_width = propsheet->head_rc.right; if (propsheet->head) { PPROPPAGE page; hdc = GetClientDC(hwnd); page = propsheet->head; while(page) { page->width = tab_required_width (hdc, propsheet, page); page = page->next; } ReleaseDC (hdc); update_propsheet (propsheet); } } resize_children (propsheet, rcClient, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 1; } case MSG_DESTROY: { PPROPPAGE page, temp; page = propsheet->head; while (page) { temp = page->next; destroy_page (page); free (page); page = temp; } free (propsheet); break; } case MSG_GETDLGCODE: { return DLGC_WANTTAB | DLGC_WANTARROWS; } case PSM_SHEETCMD: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (SendMessage (page->hwnd, MSG_SHEETCMD, wParam, lParam)) /* when encounter an error, return page index plus 1. */ return index + 1; index++; page = page->next; } return 0; /* success */ } case PSM_SETACTIVEINDEX: { PPROPPAGE page; if ((page = get_page (propsheet, wParam)) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; update_propsheet (propsheet); NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } return PS_ERR; } case PSM_GETACTIVEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page == propsheet->active) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETACTIVEPAGE: { return (propsheet->active) ? propsheet->active->hwnd : HWND_INVALID; } case PSM_GETPAGE: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (index == wParam) { return page->hwnd; } index ++; page = page->next; } return HWND_INVALID; } case PSM_GETPAGEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page->hwnd == wParam) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETPAGECOUNT: { return propsheet->page_count; } case PSM_GETTITLELENGTH: { int len = PS_ERR; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { len = strlen (page->title); } return len; } case PSM_GETTITLE: { char* buffer = (char*)lParam; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { strcpy (buffer, page->title); return PS_OKAY; } return PS_ERR; } case PSM_SETTITLE: { BOOL rc = PS_ERR; char* buffer = (char*)lParam; PPROPPAGE page; HDC hdc; if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { if ((page = get_page (propsheet, wParam))) { rc = set_page_title (page, buffer); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } else { if ((page = get_page (propsheet, wParam))) { hdc = GetClientDC (hwnd); rc = set_page_title_normal_style (hdc, propsheet, page, buffer); ReleaseDC (hdc); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } return rc; } case PSM_ADDPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { int index; PPROPPAGE page; if ((propsheet->head_rc.right / (propsheet->page_count + 1)) < _MIN_TAB_WIDTH) { return PS_ERR; } if (!(page = calloc (1, sizeof (PROPPAGE)))) { return PS_ERR; } if (!create_page (hwnd, ctrl->dwStyle, propsheet, page, (DLGTEMPLATE *)wParam, (WNDPROC)lParam)) { free (page); return PS_ERR; } index = append_page (propsheet, page); if (propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); } propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return index; } else { return add_new_page_normal_style (hwnd, ctrl, propsheet, (DLGTEMPLATE *)wParam, (WNDPROC)lParam); } } case PSM_REMOVEPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { remove_page (propsheet, page); destroy_page (page); free (page); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { return PS_ERR; } if (propsheet->active == page) { propsheet->active = propsheet->head; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); if (propsheet->active) { show_hide_page (propsheet->active, SW_SHOW); } } InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } else { return delete_page (hwnd, ctrl, propsheet, wParam); } } case MSG_LBUTTONDOWN: { click_tab_bar (hwnd, ctrl, propsheet, lParam); /* dump_propsheetdata (propsheet); */ break; } case MSG_KEYDOWN: { PPROPPAGE page, new_active = NULL; if (!(lParam & KS_CTRL) || (propsheet->head == NULL)) { break; } /* Key borad message for PSS_COMPACTTAB and PSS_SIMPLE */ switch (LOWORD (wParam)) { case SCANCODE_CURSORBLOCKDOWN: case SCANCODE_CURSORBLOCKRIGHT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { new_active = propsheet->active->next; if (new_active == NULL) new_active = propsheet->head; break; } else { scroll_tab_right (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case SCANCODE_CURSORBLOCKUP: case SCANCODE_CURSORBLOCKLEFT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { page = propsheet->head; if (propsheet->head == propsheet->active) { while (page && page->next) { page = page->next; } } else { while (page) { if (page->next == propsheet->active) break; page = page->next; } } new_active = page; break; } else { scroll_tab_left (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } } /* switch */ if (new_active == NULL) { break; } show_hide_page (propsheet->active, SW_HIDE); propsheet->active = new_active; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (new_active, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case MSG_NCPAINT: case MSG_PAINT: { HDC hdc = BeginPaint (hwnd); PPROPPAGE page = ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) ? propsheet->first_display_page : propsheet->head; draw_propsheet (hwnd, hdc, ctrl, propsheet, page); EndPaint (hwnd, hdc); return 0; } default: break; } return DefaultControlProc (hwnd, message, wParam, lParam); }
static int DialogProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam) { switch(message) { case MSG_INITDIALOG: { tipLabelData_t* tipLabelData; tipLabelData = (tipLabelData_t*)lParam; if(!tipLabelData) { db_error("invalid tipLabelData\n"); return -1; } SetWindowAdditionalData(hDlg, (DWORD)tipLabelData); if(tipLabelData->pLogFont) { SetWindowFont(hDlg, tipLabelData->pLogFont); } if(tipLabelData->full_screen == 1){ SetWindowBkColor(hDlg,FULL_BLACK); }else{ SetWindowBkColor(hDlg, tipLabelData->bgc_widget); } if(tipLabelData->full_screen == 1){ SetWindowElementAttr(GetDlgItem(hDlg, IDC_TITLE), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, FULL_BLACK) ); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TEXT), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, FULL_BLACK) ); }else{ SetWindowElementAttr(GetDlgItem(hDlg, IDC_TITLE), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, tipLabelData->fgc_widget) ); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TEXT), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, tipLabelData->fgc_widget) ); } SetTimerEx(hDlg, TIMEOUT_TIMER, tipLabelData->timeoutMs / 10, timerCallback); } break; case MSG_PAINT: { RECT rect; HDC hdc; tipLabelData_t* tipLabelData; hdc = BeginPaint(hDlg); tipLabelData = (tipLabelData_t*)GetWindowAdditionalData(hDlg); GetClientRect(GetDlgItem(hDlg, IDC_TITLE), &rect); if(tipLabelData->full_screen == 1){ SetPenColor(hdc, FULL_BLACK); }else{ SetPenColor(hdc, tipLabelData->linec_title ); } Line2(hdc, 0, RECTH(rect) + 2, RECTW(rect), RECTH(rect) + 2); #if 0 char *filepath=(char *)"/etc/res/others/wifi.png"; LoadBitmapFromFile(HDC_SCREEN, &tipLabelData->bitImage, filepath); FillBoxWithBitmap(hdc,0,0,320,240,&tipLabelData->bitImage); #endif //ShowWindow(hDlg,SW_SHOWNORMAL); EndPaint(hDlg, hdc); } break; case MSG_FONTCHANGED: { PLOGFONT pLogFont; pLogFont = GetWindowFont(hDlg); if(pLogFont) { SetWindowFont(GetDlgItem(hDlg, IDC_TITLE), pLogFont); SetWindowFont(GetDlgItem(hDlg, IDC_TEXT), pLogFont); } } break; case MSG_KEYUP: { switch(wParam) { case CDR_KEY_RIGHT: EndDialog(hDlg, 0); break; case CDR_KEY_LEFT: case CDR_KEY_OK: case CDR_KEY_MODE: break; } } break; case MSG_KEYDOWN: { //EndDialog(hDlg, 0); } break; case MSG_CLOSE_TIP_LABEL: tipLabelData_t* tipLabelData; tipLabelData = (tipLabelData_t*)GetWindowAdditionalData(hDlg); db_info("MSG_CLOSE_LOWPOWER_DIALOG\n"); if(IsTimerInstalled(hDlg, ONE_SHOT_TIMER) == TRUE) { KillTimer(hDlg, ONE_SHOT_TIMER); } if(IsTimerInstalled(hDlg, TIMEOUT_TIMER) == TRUE) { KillTimer(hDlg, TIMEOUT_TIMER); } if (tipLabelData->bitImage.bmBits != NULL){ UnloadBitmap(&tipLabelData->bitImage); } EndDialog(hDlg, 0); break; } return DefaultDialogProc(hDlg, message, wParam, lParam); }
static int msgBoxProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam ) { MBPrivData* privData; switch(message) { case MSG_FONTCHANGED: { HWND hChild; hChild = GetNextChild(hDlg, 0); while( hChild && (hChild != HWND_INVALID) ) { SetWindowFont(hChild, GetWindowFont(hDlg)); hChild = GetNextChild(hDlg, hChild); } } break; case MSG_INITDIALOG: { unsigned int dwStyle; MessageBox_t* info = (MessageBox_t *)lParam; if(info == NULL) { db_error("invalid info\n"); return -1; } dwStyle = info->dwStyle & MB_TYPEMASK; privData = (MBPrivData*)malloc(sizeof(MBPrivData)); privData->dwStyle = dwStyle; if(privData->dwStyle & MB_OKCANCEL){ privData->IDCSelected = IDC_BUTTON_START + 1; privData->buttonNRs = 2; } else { privData->IDCSelected = IDC_BUTTON_START; privData->buttonNRs = 1; } db_msg("buttonNRs is %d\n", privData->buttonNRs); privData->flag_end_key = info->flag_end_key; privData->linecTitle = info->linecTitle; privData->linecItem = info->linecItem; privData->confirmCallback = info->confirmCallback; privData->confirmData = info->confirmData; privData->msg4ConfirmCallback = info->msg4ConfirmCallback; SetWindowAdditionalData(hDlg, (DWORD)privData); SetWindowFont(hDlg, info->pLogFont); /******* the hilight is the global attibute *******/ gp_hilite_bgc = GetWindowElementPixel(hDlg, WE_BGC_HIGHLIGHT_ITEM); gp_hilite_fgc = GetWindowElementPixel(hDlg, WE_FGC_HIGHLIGHT_ITEM); gp_normal_bgc = info->bgcWidget; gp_normal_fgc = info->fgcWidget; SetWindowBkColor(hDlg, gp_normal_bgc); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TITLE), WE_FGC_WINDOW, Pixel2DWORD(HDC_SCREEN, gp_normal_fgc)); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TEXT), WE_FGC_WINDOW, Pixel2DWORD(HDC_SCREEN, gp_normal_fgc)); SetWindowText(GetDlgItem(hDlg, IDC_TITLE), info->title); SetWindowText(GetDlgItem(hDlg, IDC_TEXT), info->text); for(unsigned int i = 0; i < privData->buttonNRs; i++) { SetWindowElementAttr( GetDlgItem(hDlg, IDC_BUTTON_START + i), WE_FGC_WINDOW, Pixel2DWORD(HDC_SCREEN, gp_normal_fgc)); SetWindowAdditionalData2( GetDlgItem(hDlg, IDC_BUTTON_START + i), (DWORD)info->buttonStr[i]); } } break; case MSG_KEYUP: { privData = (MBPrivData *)GetWindowAdditionalData(hDlg); switch(wParam) { case CDR_KEY_OK: if(privData->flag_end_key == 1) { db_msg("hDlg is %x\n", hDlg); if( (privData->IDCSelected == IDC_BUTTON_START) && privData->confirmCallback) { if(privData->msg4ConfirmCallback) { SetWindowText(GetDlgItem(hDlg, IDC_TEXT), privData->msg4ConfirmCallback); SetTimerEx(hDlg, TIMER_CONFIRM_CALLBACK, 5, timerCallback); SetNullFocus(hDlg); } else { db_msg("confirmCallback\n"); (*privData->confirmCallback)(hDlg , privData->confirmData); db_msg("confirmCallback\n"); } } else { EndDialog(hDlg, privData->IDCSelected); } } break; case CDR_KEY_MENU: case CDR_KEY_MODE: if(privData->flag_end_key == 1) EndDialog(hDlg, IDC_BUTTON_CANCEL); break; case CDR_KEY_LEFT: privData->IDCSelected--; if(privData->IDCSelected < IDC_BUTTON_START) { privData->IDCSelected = IDC_BUTTON_START + privData->buttonNRs - 1; } InvalidateRect(hDlg, NULL, TRUE); break; case CDR_KEY_RIGHT: privData->IDCSelected++; if(privData->IDCSelected > (IDC_BUTTON_START + privData->buttonNRs - 1) ) { privData->IDCSelected = IDC_BUTTON_START; } InvalidateRect(hDlg, NULL, TRUE); break; default: break; } } break; case MSG_KEYDOWN: { RECT rect; GetClientRect(hDlg, &rect); privData = (MBPrivData *)GetWindowAdditionalData(hDlg); switch(wParam) { case CDR_KEY_OK: if(privData->flag_end_key == 0) { db_msg("hDlg is %x\n", hDlg); if( (privData->IDCSelected == IDC_BUTTON_START) && privData->confirmCallback ) { if(privData->msg4ConfirmCallback) { SetWindowText(GetDlgItem(hDlg, IDC_TEXT), privData->msg4ConfirmCallback); SetTimerEx(hDlg, TIMER_CONFIRM_CALLBACK, 5, timerCallback); SetNullFocus(hDlg); } else { db_msg("confirmCallback\n"); (*privData->confirmCallback)(hDlg , privData->confirmData); db_msg("confirmCallback\n"); } } else { EndDialog(hDlg, privData->IDCSelected); } } break; case CDR_KEY_MENU: case CDR_KEY_MODE: if(privData->flag_end_key == 0) { EndDialog(hDlg, 0); } break; default: break; } } break; case MSG_PAINT: { RECT rect, rect1; HDC hdc = BeginPaint(hDlg); privData = (MBPrivData *)GetWindowAdditionalData(hDlg); GetClientRect(GetDlgItem(hDlg, IDC_TITLE), &rect); GetClientRect(hDlg, &rect1); /**** draw the line below the title *******/ SetPenColor(hdc, privData->linecTitle ); Line2(hdc, 1, RECTH(rect) + 1, RECTW(rect) - 2, RECTH(rect) + 1); /**** draw the line above the button *******/ SetPenColor(hdc, privData->linecItem ); Line2(hdc, 1, RECTH(rect1) * 3 / 4 - 2, RECTW(rect1) - 2, RECTH(rect1) * 3 / 4 - 2); unsigned int i; for(i = 0; i < privData->buttonNRs; i++) { if(IDC_BUTTON_START + i == privData->IDCSelected) { drawButton(hDlg, IDC_BUTTON_START + i, BUTTON_SELECTED); } else { drawButton(hDlg, IDC_BUTTON_START + i, BUTTON_UNSELECTED); } } EndPaint(hDlg, hdc); } break; case MSG_DESTROY: { db_msg("msg destroy"); privData = (MBPrivData *)GetWindowAdditionalData(hDlg); if(privData) free(privData); } break; case MSG_CLOSE_TIP_LABEL: EndDialog(hDlg, 0); break; default: break; } return DefaultDialogProc (hDlg, message, wParam, lParam); }
/* 帮助控件回调函数 */ static int EditProcHelp(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { int temp; int id; char strHelp[200] = {0}; //设置帮助栏背景框颜色和字体颜色 SetWindowBkColor(hWnd,COLOR_black); #ifdef FONTCOLOR SetWindowElementColorEx( hWnd, FGC_CONTROL_NORMAL,COLOR_yellow); #endif switch(message){ case MSG_PAINT:{ id = lParam; switch(id){ case DID_MENU_SCREEN:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_MAINMENU, "help_screen", strHelp, sizeof strHelp,"Select different screen."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_MONITOR:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes,STR_SETTING_DLG_MAINMENU, "help_monitor", strHelp, sizeof strHelp,"Set monitor param."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_TRENDREVIEW:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_MAINMENU, "help_trendreview", strHelp, sizeof strHelp,"View trend."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_ALARMREVIEW:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_MAINMENU, "help_alarmreview", strHelp, sizeof strHelp,"View alarm event."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_ARRREVIEW:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_MAINMENU, "help_arrrview", strHelp, sizeof strHelp,"View arrhythmia event."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_ALARMSETUP:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_MAINMENU, "help_alarmsetup", strHelp, sizeof strHelp,"Set alarm param."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_PATIENTINFO:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_MAINMENU, "help_patientinfo", strHelp, sizeof strHelp,"Patient info set."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_CALCULATOR:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_MAINMENU, "help_calculator", strHelp, sizeof strHelp,"Calculator select."); SetWindowText(hWnd, strHelp); }break; /*TODO 屏蔽standby功能 转换成趋势 case DID_MENU_STANDBY:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes,STR_SETTING_DLG_MAINMENU, "help_standby", strHelp, sizeof strHelp,"Standby mode."); SetWindowText(hWnd, strHelp); }break; */ case DID_MENU_STANDBY:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes,STR_SETTING_DLG_MAINMENU, "help_trendreview", strHelp, sizeof strHelp,"View trend."); SetWindowText(hWnd, strHelp); }break; case DID_MENU_OK:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_GENERAL, "help_backtomain", strHelp, sizeof strHelp,"Return to main screen."); SetWindowText(hWnd, strHelp); }break; default:{ SetWindowText(hWnd, ""); }break; }break; }break; } temp = (*OldEditProcHelp)(hWnd, message, wParam, lParam); return(temp); }
/* 帮助控件回调函数 */ static int EditProcHelp(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { int temp; int id; char strHelp[200] = {0}; //设置帮助栏背景框颜色和字体颜色 SetWindowBkColor(hWnd,COLOR_black); #ifdef FONTCOLOR SetWindowElementColorEx( hWnd, FGC_CONTROL_NORMAL,COLOR_yellow); #endif switch(message){ case MSG_PAINT:{ id = lParam; switch(id){ case DID_COMMONALM_HR:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_hr", strHelp, sizeof strHelp,"Set alarm for HR."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_SPO2:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_spo2", strHelp, sizeof strHelp,"Set alarm for SPO2."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_NIBPSYS:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes,STR_SETTING_DLG_ALMSETUP, "help_nibpsys", strHelp, sizeof strHelp,"Set alarm for NIBP Sys."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_NIBPDIA:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_nibpdia", strHelp, sizeof strHelp,"Set alarm for NIBP Dia."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_NIBPMEAN:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_nibpmean", strHelp, sizeof strHelp,"Set alarm for NIBP Mean."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_RESP:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_resp", strHelp, sizeof strHelp,"Set alarm for Resp."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_T1:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_temp1", strHelp, sizeof strHelp,"Set alarm for TEMP1."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_T2:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_temp2", strHelp, sizeof strHelp,"Set alarm for TEMP2."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_DEFAULT:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_default", strHelp, sizeof strHelp,"Default alarm limit."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_OK:{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_GENERAL, "help_previous", strHelp, sizeof strHelp,"Return to the previous menu."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_HR_HIGH : case DID_COMMONALM_SPO2_HIGH: case DID_COMMONALM_NIBPSYS_HIGH: case DID_COMMONALM_NIBPDIA_HIGH : case DID_COMMONALM_NIBPMEAN_HIGH: case DID_COMMONALM_RESP_HIGH: case DID_COMMONALM_T1_HIGH : case DID_COMMONALM_T2_HIGH :{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_high", strHelp, sizeof strHelp,"Set alarm upper limit."); SetWindowText(hWnd, strHelp); }break; case DID_COMMONALM_HR_LOW : case DID_COMMONALM_SPO2_LOW: case DID_COMMONALM_NIBPSYS_LOW: case DID_COMMONALM_NIBPDIA_LOW : case DID_COMMONALM_NIBPMEAN_LOW: case DID_COMMONALM_RESP_LOW: case DID_COMMONALM_T1_LOW : case DID_COMMONALM_T2_LOW :{ memset(strHelp, 0, sizeof strHelp); GetStringFromResFiles(gsLanguageRes, STR_SETTING_DLG_ALMSETUP, "help_low", strHelp, sizeof strHelp,"Set alarm lower limit."); SetWindowText(hWnd, strHelp); }break; default:{ SetWindowText(hWnd, ""); }break; }break; }break; } temp = (*OldEditProcHelp)(hWnd, message, wParam, lParam); return(temp); }