MApp_ZUI_CTL_MarqueeTextWinProc字串滚动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | /////////////////////////////////////////////////////////////////////////////// /// global MApp_ZUI_CTL_MarqueeTextWinProc /// Window Proc for "marquee text" control, /// which display a static text by clipped string with dynamic color /// if the string content is more than boundary, it will set a timer for text rotation (once) /// /// rule: if window data == 0, no marquee animation /// if window is not focus state, no marquee animation /// if dynamic string content is shorter than boundary, no marquee animation /// if pData->u8ShowStartPosition==0xFF, animation disabled /// if pData->u8ShowStartPosition>=strlen, animation disabled /// /// /// @param [in] hWnd HWND window handle /// @param [in] pMsg PMSG message type /// /// @return S32 message execute result /// /// @author MStarSemi @date 2007/1/25 /////////////////////////////////////////////////////////////////////////////// S32 MApp_ZUI_CTL_MarqueeTextWinProc( HWND hWnd, PMSG pMsg) { GUI_DATA_MARQUEE_VARDATA * pData = (GUI_DATA_MARQUEE_VARDATA*)MApp_ZUI_API_GetWindowData(hWnd); switch (pMsg->message) { case MSG_TIMER: if (pData) { if (pData->u8ShowStartPosition == 0) MApp_ZUI_API_SetTimer(hWnd, pMsg->wParam, ZUI_MARQUEE_ANIMATION_INTERVAL_MS); pData->u8ShowStartPosition++; MApp_ZUI_API_InvalidateWindow(hWnd); } return 0; case MSG_PAINT: { //get buffer GC for offline drawing... PAINT_PARAM * param = (PAINT_PARAM*)pMsg->wParam; DRAWSTYLE_TYPE ds_type = DS_NORMAL; if (param->bIsDisable) { param->dc.u8ConstantAlpha = MApp_ZUI_API_GetDisableAlpha(hWnd); ds_type = DS_DISABLE; } else if (param->bIsFocus) //the same focus group { param->dc.u8ConstantAlpha = MApp_ZUI_API_GetFocusAlpha(hWnd); ds_type = DS_FOCUS; } else { param->dc.u8ConstantAlpha = MApp_ZUI_API_GetNormalAlpha(hWnd); } _MApp_ZUI_API_DefaultOnPaint(hWnd, param, FALSE); { U16 u16TxtComponentIndex = _MApp_ZUI_API_FindFirstComponentIndex(hWnd, ds_type, CP_TEXT_OUT); LPTSTR pStr = MApp_ZUI_ACT_GetDynamicText(hWnd); if (u16TxtComponentIndex != 0xFFFF && pStr) { DRAW_TEXT_OUT_DYNAMIC dyna; _MApp_ZUI_API_ConvertTextComponentToDynamic(u16TxtComponentIndex, &dyna); dyna.pString = pStr; dyna.TextColor = MApp_ZUI_ACT_GetDynamicColor(hWnd, ds_type, dyna.TextColor); //marquee animation: if (ds_type == DS_FOCUS && pData != NULL && pData->u8ShowStartPosition != 0xFF) { if (pData->u8ShowStartPosition >= MApp_ZUI_API_Strlen(pStr)) { pData->u8ShowStartPosition = 0xFF; MApp_ZUI_API_KillTimer(hWnd, 0); } else if (pData->u8ShowStartPosition == 0) { U16 width; clrBtn1.Fontfmt.flag = dyna.flag; clrBtn1.Fontfmt.ifont_gap = dyna.u8dis; clrBtn1.bStringIndexWidth = CHAR_IDX_2BYTE; width = msAPI_OSD_GetStrWidth(Font[dyna.eSystemFont].fHandle, (U8*)pStr, &clrBtn1); //note: add border for a little truncate case.. if (width+BTN_TEXT_GAP*2 <= param->rect->width) { pData->u8ShowStartPosition = 0xFF; MApp_ZUI_API_KillTimer(hWnd, 0); } } else { dyna.pString += pData->u8ShowStartPosition; dyna.u8dots = 0; //note: don't show dots for animation.. } } else { //note: pData may be shared with others, so don't clear them // but we need to stop the timer if animation still going MApp_ZUI_API_KillTimer(hWnd, 0); } _MApp_ZUI_API_DrawDynamicComponent(CP_TEXT_OUT_DYNAMIC, &dyna, ¶m->dc, param->rect); } } } return 0; default : break ; } return DEFAULTWINPROC(hWnd, pMsg); } /////////////////////////////////////////////////////////////// // methods void MApp_ZUI_CTL_MarqueeTextEnableAnimation( HWND hwnd, BOOLEAN bEnable) { //note: if enable, try to check string length is long enough, and then start animation // if disable, stop and clear to normal status if (hwnd != HWND_INVALID) { GUI_DATA_MARQUEE_VARDATA * pData = (GUI_DATA_MARQUEE_VARDATA*)MApp_ZUI_API_GetWindowData(hwnd); if (pData == NULL) return ; if (bEnable) { pData->u8ShowStartPosition = 0; MApp_ZUI_API_SetTimer(hwnd, 0, ZUI_MARQUEE_INITIAL_INTERVAL_MS); } else { pData->u8ShowStartPosition = 0xFF; MApp_ZUI_API_KillTimer(hwnd, 0); } MApp_ZUI_API_InvalidateWindow(hwnd); } } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)