|

楼主 |
发表于 2021-2-19 11:05:27
|
显示全部楼层
- void copy_part_of_bitmap(int x, int y, const GUI_BITMAP *bmp, int x0, int y0, int width, int height)
- {
- GUI_RECT rect;
- rect.x0 = x;
- rect.y0 = y;
- rect.x1 = x + width - 1;
- rect.y1 = y + height - 1;
- GUI_SetClipRect(&rect);
- GUI_DrawBitmap(bmp, x0, y0);
- GUI_SetClipRect(NULL);
- }
- static void _CbHome(WM_MESSAGE * pMsg)
- {
- WM_HWIN hWin;
- hWin = pMsg->hWin;
- switch (pMsg->MsgId)
- {
- case WM_PAINT:
- {
- printf("WM_PAINT:_CbHome\n");
- copy_part_of_bitmap(g_tBmpPara.iX,g_tBmpPara.iY,g_tBmpPara.pBmp,g_tBmpPara.iX0,g_tBmpPara.iY0,g_tBmpPara.iWidth,g_tBmpPara.iHeight);
- //GUI_DrawBitmap(g_tBmpPara.pBmp, 160, 93);
- break;
- }
- default:
- BUTTON_Callback(pMsg);
- }
- }
- static void _CbRvDmHome(WM_MESSAGE * pMsg)
- {
- WM_HWIN hItem;
- switch (pMsg->MsgId)
- {
- case WM_PAINT:
- {
- // GUI_DrawBitmap(&(g_tRwDm.hPic[16]), 0, 0);
- //copy_part_of_bitmap(g_tBmpPara.iX,g_tBmpPara.iY,g_tBmpPara.pBmp,g_tBmpPara.iX0,g_tBmpPara.iY0,g_tBmpPara.iWidth,g_tBmpPara.iHeight);
- break;
- }
- case WM_INIT_DIALOG:
- g_tBmpPara.pBmp = &(g_tRwDm.hPic[16]);
- g_tBmpPara.iX = 44;
- g_tBmpPara.iY = 144;
- g_tBmpPara.iX0 = 0;
- g_tBmpPara.iY0 = 0;
- g_tBmpPara.iWidth = 389;
- g_tBmpPara.iHeight = 186;
- hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
- WM_SetCallback(hItem, _CbHome);
-
- #if 0
- hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
- WM_SetCallback(hItem, _CbHome);
- #endif
- break;
- case WM_NOTIFY_PARENT:
- switch(WM_GetId(pMsg->hWinSrc))
- {
- case ID_BUTTON_2:
- switch(pMsg->Data.v)
- {
- case WM_NOTIFICATION_CLICKED:
- g_tBmpPara.pBmp = &(g_tRwDm.hPic[16]);
- g_tBmpPara.iX = 0;
- g_tBmpPara.iY = 86;
- g_tBmpPara.iX0 = 0;
- g_tBmpPara.iY0 = 0;
- g_tBmpPara.iWidth = 389;
- g_tBmpPara.iHeight = 186;
- printf("WM_NOTIFY_PARENT:ID_BUTTON_2:WM_NOTIFICATION_CLICKED\n");
- break;
- case WM_NOTIFICATION_RELEASED:
- g_tBmpPara.pBmp = &(g_tRwDm.hPic[17]);
- g_tBmpPara.iX = 0;
- g_tBmpPara.iY = 0;
- g_tBmpPara.iX0 = 0;
- g_tBmpPara.iY0 = 0;
- g_tBmpPara.iWidth = 389;
- g_tBmpPara.iHeight = 186;
- printf("WM_NOTIFY_PARENT:ID_BUTTON_2:WM_NOTIFICATION_RELEASED\n");
- break;
- }
- break;
- }
- break;
-
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
复制代码
我用代码实现图片切割,将图片显示在按钮上。按下时g_tBmpPara.iY = 86;我想把图片往上挪动一下,但是效果与我想法不一样,图片不仅没有挪动,而且按钮上半部分变成白屏,其他地方不变(同样的方法在win 上可以正常实现)。百思不得其解,请指教?
|
|