初级会员
- 积分
- 79
- 金钱
- 79
- 注册时间
- 2015-10-23
- 在线时间
- 15 小时
|
问题就是:我在主窗口下建立了子窗口,为什么我在实验过程中一点击子窗口就会自动返回到父窗口,我目前以为是因为子窗口的句柄问题导致的,我就把原先guibuilder生成的代码,把Hitem改为hitem1,把下面生成的封装函数中的Hwin改为hwin1,可是还是解决不了这个问题,有没有哪位朋友给予解答方法?子窗口程序如下:
#include "DIALOG.h"#include "led.h"@正点原子
#include "beep.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_IMAGE_0 (GUI_ID_USER + 0x01)
#define ID_SCROLLBAR_0 (GUI_ID_USER + 0x02)
#define ID_BUTTON_0 (GUI_ID_USER + 0x03)
#define ID_BUTTON_1 (GUI_ID_USER + 0x04)
#define ID_BUTTON_2 (GUI_ID_USER + 0x05)
#define ID_BUTTON_3 (GUI_ID_USER + 0x06)
#define ID_BUTTON_4 (GUI_ID_USER + 0x07)
#define ID_BUTTON_5 (GUI_ID_USER + 0x08)
#define ID_BUTTON_6 (GUI_ID_USER + 0x09)
#define ID_BUTTON_7 (GUI_ID_USER + 0x0A)
#define ID_BUTTON_8 (GUI_ID_USER + 0x0B)
#define ID_IMAGE_0_IMAGE_0 0x00
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _acImage_0, "C:\Users\Administrator\Desktop\±¸óÃí¼±ê\true_00001.bmp", ID_IMAGE_0_IMAGE_0
*/
static const U8 _acImage_0[230454] = {
图片数组
};
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Mp3", ID_WINDOW_0, 0, 0, 240, 320, 0, 0x0, 0 },
{ IMAGE_CreateIndirect, "Mp3", ID_IMAGE_0, 1, 0, 240, 320, 0, 0, 0 },
{ SCROLLBAR_CreateIndirect, "Scrollbar", ID_SCROLLBAR_0, -11, 191, 258, 10, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "1", ID_BUTTON_0, 67, 203, 30, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "2", ID_BUTTON_1, 112, 203, 30, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "3", ID_BUTTON_2, 156, 203, 30, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "4", ID_BUTTON_3, 31, 257, 30, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "5", ID_BUTTON_4, 66, 255, 35, 35, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "6", ID_BUTTON_5, 105, 252, 40, 40, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "7", ID_BUTTON_6, 150, 255, 35, 35, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "8", ID_BUTTON_7, 189, 258, 30, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "9", ID_BUTTON_8, 205, 2, 30, 30, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetImageById
*/
static const void * _GetImageById(U32 Id, U32 * pSize) {
switch (Id) {
case ID_IMAGE_0_IMAGE_0:
*pSize = sizeof(_acImage_0);
return (const void *)_acImage_0;
}
return NULL;
}
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
const void * pData;
WM_HWIN hItem1;
U32 FileSize;
int NCode;
int Id;
// USER START (Optionally insert additional variables)
// USER END
static u8 ledflag=0;
static u8 beepflag=0;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Mp3'
//
hItem1 = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
IMAGE_SetBMP(hItem1, pData, FileSize);
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_SCROLLBAR_0: // Notifications sent by 'Scrollbar'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_VALUE_CHANGED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_0: // Notifications sent by '1'
switch(NCode) {
hItem1 = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0 );
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
LED1=~LED1; //LED1·′×a
ledflag=~ledflag;
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_1: // Notifications sent by '2'
switch(NCode) {
hItem1 = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1 );
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
BEEP=~BEEP; //·äÃùÆ÷·′×a
beepflag=~beepflag;
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_2: // Notifications sent by '3'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_3: // Notifications sent by '4'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_4: // Notifications sent by '5'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_5: // Notifications sent by '6'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_6: // Notifications sent by '7'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_7: // Notifications sent by '8'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
case ID_BUTTON_8: // Notifications sent by '9'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER START (Optionally insert additional code for further Ids)
// USER END
}
break;
// USER START (Optionally insert additional message handling)
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateMp3
*/
WM_HWIN CreateMp3(void);
WM_HWIN CreateMp3(void) {
WM_HWIN hWin1;
hWin1 = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin1;//Ö÷′°¿ú·μ»ØÖμ
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/
|
|