大学生
最后登录1970-1-1
在线时间 小时
注册时间2016-7-21
|
楼主 |
发表于 2017-8-4 09:51:52
|
显示全部楼层
- #include "GUI.h"
- #include "BUTTON.h"
- void show()
- {
- GUI_SetFont(&GUI_Font8x16);
- //GUI_DispString("Mr.wu\nthe first");
- //设置画笔的粗细及颜色,以及矢量函数才能设置size
- GUI_SetPenSize(10);
- GUI_SetColor(GUI_RED);
- GUI_DrawLine(80, 10, 240, 90);
- GUI_DrawLine(80, 90, 240, 10);
- GUI_SetBkColor(GUI_BLACK);
- GUI_SetColor(GUI_WHITE);
- //设置正常模式
- GUI_SetTextMode(GUI_TM_NORMAL);
- GUI_DispStringHCenterAt("GUI_TM_NORMAL", 160, 10);
- //翻转文本
- GUI_SetTextMode(GUI_TM_REV);
- GUI_DispStringHCenterAt("GUI_TM_REV", 160, 26);
- //透明文本
- GUI_SetTextMode(GUI_TM_TRANS);
- GUI_DispStringHCenterAt("GUI_TM_TRANS", 160, 42);
- //异或文本
- GUI_SetTextMode(GUI_TM_XOR);
- GUI_DispStringHCenterAt("GUI_TM_XOR", 160, 58);
- GUI_SetTextMode(GUI_TM_TRANS | GUI_TM_REV);
- GUI_DispStringHCenterAt("GUI_TM_TRANS | GUI_TM_REV", 160, 74);
- }
- static void create_button0()
- {
- BUTTON_Handle hButton0;
- hButton0 = BUTTON_Create(260, 5, 50, 20, GUI_ID_BUTTON0, WM_CF_SHOW);
- BUTTON_SetText(hButton0, "Start");
- }
- static void create_button1()
- {
- BUTTON_Handle hButton1;
- hButton1 = BUTTON_Create(260, 35, 50, 20, GUI_ID_BUTTON1, WM_CF_SHOW);
- BUTTON_SetText(hButton1, "Start");
- }
- static void button_show()
- {
- create_button0();
- create_button1();
- }
- static void _cbBkWin(WM_MESSAGE * pMsg)
- {
- WM_HWIN hWin;
- int NCode, Id;
- hWin = pMsg->hWin;
- switch (pMsg->MsgId)
- {
- case WM_INIT_DIALOG:
-
- break;
- case WM_PAINT:
- show();
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- case GUI_ID_BUTTON0:
- switch (NCode)
- {
- case WM_NOTIFICATION_CLICKED:
- GUI_SetPenSize(10);
- GUI_SetColor(GUI_RED);
- GUI_DrawLine(80, 10, 240, 90);
- GUI_DrawLine(80, 90, 240, 10);
- break;
- }
- case GUI_ID_BUTTON1:
- switch (NCode)
- {
- case WM_NOTIFICATION_CLICKED:
- GUI_Clear();
- break;
- }
- /*
- case GUI_ID_BUTTON3:
- switch (NCode)
- {
- case WM_NOTIFICATION_RELEASED:
- GUI_SetPenSize(10);
- GUI_SetColor(GUI_RED);
- GUI_DrawLine(80, 10, 240, 90);
- GUI_DrawLine(80, 90, 240, 10);
- break;
- }
- case GUI_ID_BUTTON4:
- switch (NCode)
- {
- case WM_NOTIFICATION_RELEASED:
- GUI_SetPenSize(10);
- GUI_SetColor(GUI_RED);
- GUI_DrawLine(80, 10, 240, 90);
- GUI_DrawLine(80, 90, 240, 10);
- break;
- }
- case GUI_ID_BUTTON5:
- switch (NCode)
- {
- case WM_NOTIFICATION_RELEASED:
- GUI_SetPenSize(10);
- GUI_SetColor(GUI_RED);
- GUI_DrawLine(80, 10, 240, 90);
- GUI_DrawLine(80, 90, 240, 10);
- break;
- }
- case GUI_ID_BUTTON6:
- switch (NCode)
- {
- case WM_NOTIFICATION_RELEASED:
- GUI_SetPenSize(10);
- GUI_SetColor(GUI_RED);
- GUI_DrawLine(80, 10, 240, 90);
- GUI_DrawLine(80, 90, 240, 10);
- break;
- }
- case GUI_ID_BUTTON7:
- switch (NCode)
- {
- case WM_NOTIFICATION_RELEASED:
- GUI_SetPenSize(10);
- GUI_SetColor(GUI_RED);
- GUI_DrawLine(80, 10, 240, 90);
- GUI_DrawLine(80, 90, 240, 10);
- break;
- }
- */
- break;
- }
- }
- void MainTask()
- {
-
- GUI_Init();
- GUI_SetBkColor(GUI_BLACK);
- GUI_Clear();
- button_show();
- WM_SetCallback(WM_HBKWIN, _cbBkWin);
- while (1)
- {
- GUI_Delay(10);
- }
-
- }
复制代码
这代码我只是写来看看是怎么运行的,然后我发现刚开始运行的时候,原本想要按下键显示的也一并显示了,然后两个按键都有清屏的效果。。我也不知道怎么回事,你帮忙看下好嘛。。 |
|