///////////////////////////////////////////////////////////////////////////////
/// 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, &param->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);
}
}

  

MApp_ZUI_CTL_MarqueeTextWinProc字串滚动的更多相关文章

  1. 【NOIP2015】 Day2 T2 字串 (多维动归)

    2018-09-12 原题传送门(洛谷)https://www.luogu.org/problemnew/show/P2679 模拟考试的时候完全没有想到 正确的DP方程呢 本来写了一个大致是对的转移 ...

  2. 最大公共字串LCS问题(阿里巴巴)

    给定两个串,均由最小字母组成.求这两个串的最大公共字串LCS(Longest Common Substring). 使用动态规划解决. #include <iostream> #inclu ...

  3. 编程:使用递归方式判断某个字串是否回文(Palindrome)

    Answer: import java.util.Scanner; public class Palindrome { private static int len;//全局变量整型数据 privat ...

  4. NOIP2002字串变换[BFS]

    题目描述 已知有两个字串 A$, B$ 及一组字串变换的规则(至多6个规则): A1$ -> B1$ A2$ -> B2$ 规则的含义为:在 A$中的子串 A1$ 可以变换为 B1$.A2 ...

  5. 字串符相关 split() 字串符分隔 substring() 提取字符串 substr()提取指定数目的字符 parseInt() 函数可解析一个字符串,并返回一个整数。

    split() 方法将字符串分割为字符串数组,并返回此数组. stringObject.split(separator,limit) 我们将按照不同的方式来分割字符串: 使用指定符号分割字符串,代码如 ...

  6. mormot 数据集转换为JSON字串

    mormot 数据集转换为JSON字串 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graph ...

  7. 字串变换(codevs 1099)

    题目描述 Description 已知有两个字串 A$, B$ 及一组字串变换的规则(至多6个规则): A1$ -> B1$ A2$ -> B2$ 规则的含义为:在 A$中的子串 A1$ ...

  8. @有两个含义:1,在参数里,以表明该变量为伪参数 ,在本例中下文里将用@name变量代入当前代码中2,在字串中,@的意思就是后面的字串以它原本的含义显示,如果不

    @有两个含义:1,在参数里,以表明该变量为伪参数 ,在本例中下文里将用@name变量代入当前代码中 2,在字串中,@的意思就是后面的字串以它原本的含义显示,如果不加@那么需要用一些转义符\来显示一些特 ...

  9. PHP 中替换若干字符串字串为数组中的值,不用循环,非常高效

    替换某个字符串中的一个或若干个字串为数组中某些值 php本身有自带的函数,可以不用循环非常高效的实现其效果: 实例代码:   $phrase  = "You should eat fruit ...

随机推荐

  1. C int类型的数组在内存中的地址示例

    #include <stdio.h> int main(void){ int age[5] = {5,6,7,20,99}; return 0; } //转换后 /*(gdb) p &am ...

  2. 2017.10.5 国庆清北 D5T2 整除

    80分暴力 /*找规律80分TLE俩点 忘了啥规律了. */ #include<iostream> #include<cstdio> #include<cmath> ...

  3. 如何在Processing中用鼠标获取RGB颜色数值

    要做一个抠图应用,所以随手做了个鼠标取色,代码如下: void mousePressed(){ int imgC = get(mouseX,mouseY); int R = (imgC >> ...

  4. 【概率论】5-10:二维正态分布(The Bivariate Normal Distributions)

    title: [概率论]5-10:二维正态分布(The Bivariate Normal Distributions) categories: - Mathematic - Probability k ...

  5. Comet OJ - Contest #9 & X Round 3题解

    传送门 \(A\) 咕咕 typedef long long ll; int a1,a2,n,d;ll res; int main(){ scanf("%d%d%d",&a ...

  6. Nginx 负载均衡演示之 upstream 参数 & location 参数

    upstream 参数nginx关于upstream参数官方文档:http://nginx.org/en/docs/http/ngx_http_upstream_module.html upstrea ...

  7. 小程序 跳转web-view 点击左上角返回需要点击2次才能返回

    小程序  跳转web-view  点击左上角返回需要点击2次才能返回 再html页面引入js即可解决 <script type="text/javascript" src=& ...

  8. vue-router 使用query传参跳转了两次(首次带参数,跳转到了不带参数)

    问题: 在做项目的过程中,使用query传参数,发现跳转过程中第一次有参数,但是路由马上又跳转了一次,然后 ?和它之后的参数都不见了 问题分析: 因为路由加载了两次 解决办法: ·1. 找到总的 la ...

  9. 页面的Tab选项卡 简单实例

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...

  10. Spring cloud微服务安全实战-4-3常见的微服务安全整体架构

    整体架构 这个图适合中小公司.麻雀虽小 五脏俱全.微服务架构所需要做的事在这个图里基本都有了. 绿色的不讲,主要讲的是这三块(橘黄色的).后面的和运维相关,会讲,不会讲的太深 订单服务 首先来写一个订 ...