// 窗口事件处理 Boolean TMainMenuForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { //窗口创建 case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口关闭 case EVENT_WinClose: { _OnWinClose(pApp, pEvent); } break; //点击控件 case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); } break; //控件获取焦点 case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; //控件丢失焦点 case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; //输入框内容变化 case EVENT_FieldChanged: { _OnFldChangedEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口的背景 case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND); dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg_with_logo), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); //dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_QuickBar), 0, 44, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); pEraseEvent->result = 1; bHandled = TRUE; } break; // 右软键事件 case EVENT_KeyCommand: { if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) { // 模拟标题栏右按钮选中消息 HitControl(m_TitleBtnRight); bHandled = TRUE; } } break; //下载完成事件 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case RR_BlogAddBlog: case RR_StatusSet: { TUChar errorinfo[32] = {0}; if(RenRenAPI_JsonParse_bSuccess((RR_AccessType)notifyData.nAccessType,errorinfo)==0) { if(notifyData.nAccessType == RR_StatusSet) { //更新状态显示 //Set_Url_Params(RR_ProfileGetInfo, "uid", RenRenUserInfo.szuid); //RenRenAPICommon_Download(RR_ProfileGetInfo, this->GetWindowHwndId(), 0, 0); //Set_Url_Params(RR_StatusGet, "uid", RenRenUserInfo.szuid); //RenRenAPICommon_Download(RR_StatusGet, this->GetWindowHwndId(), 0, 0); } pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_Success),TResource::LoadConstString(APP_RE_ID_STRING_Publish),WMB_OK); } else { pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_Fail),TResource::LoadConstString(APP_RE_ID_STRING_Publish),WMB_OK); } break; } case RR_PhotosUpload: { if(pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadContinue),TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadSuccess),WMB_YESNO) ==0 ) { HitControl(m_QuickBarTakePhotoID); } break; } default: break; } break; } break; case MSG_POST_THREAD_NOTIFY: { PostNotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(PostNotifyMsgDataType)); if(notifyData.nParam == RR_StatusSet) { Set_Url_Params(RR_StatusSet, "status", (char*)notifyData.pszEditContent); Set_Url_Params(RR_StatusSet, "forward_id", ""); Set_Url_Params(RR_StatusSet, "forward_owner", ""); RenRenAPICommon_Download(RR_StatusSet, this->GetWindowHwndId(), 0, 0); } else if(notifyData.nParam == RR_PhotosUpload) { Set_Url_Params(RR_PhotosUpload, "caption", (char*)notifyData.pszEditContent); RenRenAPICommon_Download(RR_PhotosUpload, this->GetWindowHwndId(), 0, 0); } bHandled = TRUE; break; } default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
Boolean TAppListViewForm::EventHandler( TApplication * pApp, EventType *pEvent ) { Boolean bHandled = FALSE; switch( pEvent->eType ) { case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; case EVENT_CtrlSelect: { // 处理控件点击事件或响应事件 bHandled = _OnCtlSelectEvent( pApp, pEvent ); } break; case EVENT_ListPreDraw: { //bHandled = _OnLstPreDrawEvent(pEvent); } break; case EVENT_WinPaint: { //DrawWindow(); //bHandled = TRUE; } break; case EVENT_CoolListViewCustomDraw: { //bHandled = _OnCoolListViewCustomDrawEvent(pApp, pEvent); } break; case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; case EVENT_WinClose: { // Do uninitialization here } break; case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); TRectangle rcBack(5, 142, 310, 314); this->GetBounds(&rcBack); // 擦除 dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_title_bg), 0, 0, SCR_W, GUI_API_STYLE_ALIGNMENT_LEFT); //dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_bottom_bg), 0, rcBack.Bottom()-68, //320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); pEraseEvent->result = 1; bHandled = TRUE; } break; case MSG_DL_THREAD_PROCESS: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; } break; case MSG_DL_THREAD_NOTIFY: { //下载完成消息 NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case KX_PostDiary: { if(KaiXinAPI_JsonParse_bSuccess(KX_PostDiary)) { pApp->MessageBox(TResource::LoadConstString(APP_KA_ID_STRING_Success),TResource::LoadConstString(APP_KA_ID_STRING_Publish),WMB_OK); Set_Url_Params(KX_DiaryList, "fuid", KaiXinUserInfo.uid); KaiXinAPICommon_Download(KX_DiaryList, this->GetWindowHwndId()); } else { pApp->MessageBox(TResource::LoadConstString(APP_KA_ID_STRING_Fail),TResource::LoadConstString(APP_KA_ID_STRING_Publish),WMB_OK); } break; } case KX_WriteRecord: { if(KaiXinAPI_JsonParse_bSuccess(KX_WriteRecord)) { pApp->MessageBox(TResource::LoadConstString(APP_KA_ID_STRING_Success),TResource::LoadConstString(APP_KA_ID_STRING_Publish),WMB_OK); Set_Url_Params(KX_RecordList, "fuid", KaiXinUserInfo.uid); KaiXinAPICommon_Download(KX_RecordList, this->GetWindowHwndId()); } else { pApp->MessageBox(TResource::LoadConstString(APP_KA_ID_STRING_Fail),TResource::LoadConstString(APP_KA_ID_STRING_Publish),WMB_OK); } break; } } break; } case MSG_POST_THREAD_NOTIFY: { PostNotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(PostNotifyMsgDataType)); if(notifyData.nEditType == NewDiaryEdit) { Set_Url_Params(KX_PostDiary, "title", (char*)notifyData.PostMsgData.diarydata.pszEditTitle); Set_Url_Params(KX_PostDiary, "content", (char*)notifyData.PostMsgData.diarydata.pszEditContent); KaiXinAPICommon_Download(KX_PostDiary, this->GetWindowHwndId()); } else if(notifyData.nEditType == NewRecordEdit) { Set_Url_Params(KX_WriteRecord, "privacy", "0"); Set_Url_Params(KX_WriteRecord, "reccont", (char*)notifyData.PostMsgData.recorddata.pszRecordContent); KaiXinAPICommon_Download(KX_WriteRecord, this->GetWindowHwndId()); } bHandled = TRUE; break; } case EVENT_KeyCommand: { // 抓取右软键事件 if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) { // 模拟退出按钮选中消息 HitControl(m_BackBtn); bHandled = TRUE; } } break; default: break; } return bHandled; }
Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch(pEvent->eType) { case EVENT_WinInit: CfgRegisterScreenSwitchNotify(GetWindowHwndId(), 0); bHandled = TRUE; break; case EVENT_WinPaint: if (CfgGetScreenStatus()) { // draw CCDirector::sharedDirector()->mainLoop(); } bHandled = TRUE; break; case EVENT_PenDown: bHandled = OnPenDown(pEvent, 0); break; case EVENT_PenMove: bHandled = OnPenMove(pEvent); break; case EVENT_PenUp: bHandled = OnPenUp(pEvent, 0); break; case EVENT_MultiTouchDown: bHandled = OnPenDown(pEvent, pEvent->lParam3); break; case EVENT_MultiTouchUp: bHandled = OnPenUp(pEvent, pEvent->lParam3); break; case EVENT_KeyCommand: { if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) { bHandled = CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked); } else if (pEvent->sParam1 == SYS_KEY_SOFTKEY_LEFT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_LEFT_LONG) { bHandled = CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeMenuClicked); } } break; case MESSAGE_SENSORS_DATA: { TG3SensorsDataType data; if (Sys_GetMessageBody((MESSAGE_t *)pEvent, &data, sizeof(TG3SensorsDataType)) == sizeof(TG3SensorsDataType) && TG3_SENSOR_TYPE_ACCELEROMETER == data.sensorMask) { // convert the data to iphone format UIAcceleration AccValue; AccValue.x = -(data.acceleration.x / TG3_GRAVITY_EARTH); AccValue.y = -(data.acceleration.y / TG3_GRAVITY_EARTH); AccValue.z = -(data.acceleration.z / TG3_GRAVITY_EARTH); AccValue.timestamp = (double) TimGetTicks() / 100; // call delegates' didAccelerate function UIAccelerometer::sharedAccelerometer()->didAccelerate(&AccValue); bHandled = TRUE; } } break; case EVENT_WinClose: CfgUnRegisterScreenSwitchNotify(GetWindowHwndId(), 0); // Stop the application since the main form has been closed pApp->SendStopEvent(); break; case EVENT_ScreenSwitchNotify: { bool bInBack = CCXApplication::sharedApplication()->isInBackground(); // if the app have be in background,don't handle this message CCX_BREAK_IF(bInBack); if (! pEvent->sParam1) // turn off screen { // CCDirector::sharedDirector()->pause(); CCXApplication::sharedApplication()->applicationDidEnterBackground(); CCXApplication::sharedApplication()->StopMainLoop(); } else { // CCDirector::sharedDirector()->resume(); CCXApplication::sharedApplication()->applicationWillEnterForeground(); CCXApplication::sharedApplication()->StartMainLoop(); } break; } } // { // char szType[32]; // sprintf(szType, "%d", pEvent->eType); // const char * pszType = szType; // switch (pEvent->eType) // { // case EVENT_ScreenSwitchNotify: // pszType = "EVENT_ScreenSwitchNotify"; // break; // // case EVENT_GlesUpdateNotify: // pszType = "EVENT_GlesUpdateNotify"; // break; // // case EVENT_WinPaint: // pszType = "EVENT_GlesUpdateNotify"; // break; // } // if (pszType) // { // char szMsg[256]; // sprintf(szMsg, "%d: %s: %d \r\n", TimGetTicks(), pszType, pEvent->sParam1); // #if defined (_TRANZDA_VM_) // #define LOG_FILE_NAME "d:/Work7/NEWPLUS/TDA_DATA/UserData/mesagelog.txt" // #else // #define LOG_FILE_NAME "/NEWPLUS/TDA_DATA/UserData/mesagelog.txt" // #endif // FILE * pf = fopen(LOG_FILE_NAME, "a+"); // fwrite(szMsg, 1, strlen(szMsg), pf); // fclose(pf); // } // } if (! bHandled) { return TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口事件处理 Boolean TPagesGetListForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { //窗口创建 case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口关闭 case EVENT_WinClose: { _OnWinClose(pApp, pEvent); } break; //点击控件 case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); } break; //控件获取焦点 case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; //控件丢失焦点 case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; //输入框内容变化 case EVENT_FieldChanged: { _OnFldChangedEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口的背景 case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND); dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); pEraseEvent->result = 1; bHandled = TRUE; } break; // 右软键事件 case EVENT_KeyCommand: { if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) { // 模拟标题栏右按钮选中消息 HitControl(m_TitleBtnRight); bHandled = TRUE; } } break; //下载完成事件 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case RR_PhotoDownload: { TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap != NULL) { TMaskButton* pMyHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(gItemData[notifyData.nParam].MaskButtonID)); if(pMyHeadMBtn != NULL) { if( gItemData[notifyData.nParam].pBmp != NULL) { gItemData[notifyData.nParam].pBmp->Destroy(); gItemData[notifyData.nParam].pBmp = NULL; } gItemData[notifyData.nParam].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[notifyData.nParam].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); pMyHeadMBtn->SetImage(gItemData[notifyData.nParam].pBmp, (HEADMASKBUTTON_W - gItemData[notifyData.nParam].pBmp->GetWidth())/2, (HEADMASKBUTTON_H - gItemData[notifyData.nParam].pBmp->GetHeight())/2 ); pMyHeadMBtn->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } } break; default: break; } } break; default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口事件处理 Boolean TCommentDetailForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; break; } case EVENT_WinClose: { _OnWinClose(pApp, pEvent); break; } case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); TRectangle rcBack(5, 142, 310, 314); this->GetBounds(&rcBack); // 擦除 dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_title_bg), 0, 0, SCR_W, GUI_API_STYLE_ALIGNMENT_LEFT); //dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_bottom_bg), 0, rcBack.Bottom()-68, //320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); pEraseEvent->result = 1; bHandled = TRUE; } break; case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); break; } case MSG_POST_THREAD_NOTIFY: { PostNotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(PostNotifyMsgDataType)); switch(notifyData.nEditType) { case ReplyUserCommentEdit: case ReplyCommentEdit: { Set_Url_Params(KX_ReplyComment, "replycont", (char*)notifyData.PostMsgData.commentdata.pszCommentContent); Set_Url_Params(KX_ReplyComment, "fuid", (char*)notifyData.PostMsgData.commentdata.nOuid); Set_Url_Params(KX_ReplyComment, "thread_cid", (char*)notifyData.PostMsgData.commentdata.nId); KaiXinAPICommon_Download(KX_ReplyComment, this->GetWindowHwndId()); break; } default: break; } bHandled = TRUE; } break; //下载完成消息在给各自form中处理模板 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case KX_PhotoDownload: { if( pBmp[notifyData.nParam] != NULL) { pBmp[notifyData.nParam]->Destroy(); pBmp[notifyData.nParam] = NULL; } pBmp[notifyData.nParam] = LoadImgByPath(notifyData.pszFilePath); if(pBmp[notifyData.nParam]) { TImage* pTImage; pTImage = static_cast< TImage* >(this->GetControlPtr(m_iaTImageID[notifyData.nParam])); if(pTImage) { pTImage->SetBitmap(pBmp[notifyData.nParam]); pTImage->Draw(); } } break; } case KX_ReplyComment: { //Shoud do update data here break; } case KX_DeleteComment: { //Shoud do update data here this->CloseWindow(); break; } } } case EVENT_KeyCommand: { // 抓取右软键事件 if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) { // 模拟退出按钮选中消息 HitControl(m_BackBtn); bHandled = TRUE; } } break; default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口事件处理 Boolean TPhotosGetAlbumsForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { //窗口创建 case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口关闭 case EVENT_WinClose: { _OnWinClose(pApp, pEvent); } break; //点击控件 case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); } break; //控件获取焦点 case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; //控件丢失焦点 case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; //输入框内容变化 case EVENT_FieldChanged: { _OnFldChangedEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口的背景 case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND); dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); if(m_FormMode == FORM_MODE_MYHOME) dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_Bottom_btn_bg), 0, BOTTOM_TAB_Y, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); pEraseEvent->result = 1; bHandled = TRUE; } break; // 右软键事件 case EVENT_KeyCommand: { if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) { // 模拟标题栏右按钮选中消息 HitControl(m_TitleBtnRight); bHandled = TRUE; } } break; //下载完成事件 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case RR_PhotoDownload: { if(notifyData.nParam == FEED_PROFILE_IMAGE_INDEX) { //下载完后更新对应的图片 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap) { TMaskButton* pLogo = NULL; pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID)); if(pLogo) { TRectangle rc; pLogo->GetBounds(&rc); if( pProfileImage != NULL) { pProfileImage->Destroy(); pProfileImage = NULL; } pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pLogo->SetCaption(TUSTR_Re_NULL,0,0); pLogo->SetImage(pProfileImage, (rc.Width()-pProfileImage->GetWidth())/2, (rc.Height()-pProfileImage->GetHeight())/2); pLogo->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } break; } TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap= LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap != NULL) { TImage* pImage = static_cast<TImage*>(GetControlPtr(gItemData[notifyData.nParam].nImageID)); if(pImage != NULL) { if( gItemData[notifyData.nParam].pBmp != NULL) { gItemData[notifyData.nParam].pBmp->Destroy(); gItemData[notifyData.nParam].pBmp = NULL; } gItemData[notifyData.nParam].pBmp = pDownLoadBitmap->Create(IMAGE_W, IMAGE_H, 32); gItemData[notifyData.nParam].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); //pImage->SetImage(gItemData[notifyData.nParam].pBmp, (HEADMASKBUTTON_W - gItemData[notifyData.nParam].pBmp->GetWidth())/2, (HEADMASKBUTTON_H - gItemData[notifyData.nParam].pBmp->GetHeight())/2 ); pImage->SetBitmap(gItemData[notifyData.nParam].pBmp); pImage->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } } break; case RR_PhotosUpload: { if(pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadContinue),TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadSuccess),WMB_YESNO) ==0 ) { HitControl(m_TitleBtnLeft); } else { RenRenAPICommon_Download(RR_PhotosGetAlbums, this->GetWindowHwndId(), 0, m_FormMode); } break; } case RR_UsersGetInfoPhoto: { tResponseUsersGetInfo* Response = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&Response); if(Response) { _UpdateProfilePhoto(pApp, Response); delete Response; Response = NULL; } } break; default: break; } } break; case MSG_POST_THREAD_NOTIFY: { PostNotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(PostNotifyMsgDataType)); if(notifyData.nParam == EDIT_PARAM_PASSWORD) { Set_Url_Params(RR_PhotosGet, "password", (char*)notifyData.pszEditContent); RenRenAPICommon_Download(RR_PhotosGet, this->GetWindowHwndId(), 0, 0); } else if(notifyData.nParam == RR_PhotosUpload) { Set_Url_Params(RR_PhotosUpload, "caption", (char*)notifyData.pszEditContent); RenRenAPICommon_Download(RR_PhotosUpload, this->GetWindowHwndId(), 0, 0); } bHandled = TRUE; break; } default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口事件处理 Boolean TGuestbookGetForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { //窗口创建 case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口关闭 case EVENT_WinClose: { _OnWinClose(pApp, pEvent); } break; //点击控件 case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); } break; //控件获取焦点 case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; //控件丢失焦点 case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; //输入框内容变化 case EVENT_FieldChanged: { _OnFldChangedEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口的背景 case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND); dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); if(m_FormMode == FORM_MODE_MYHOME) dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_Bottom_btn_bg), 0, BOTTOM_TAB_Y, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); pEraseEvent->result = 1; bHandled = TRUE; } break; // 右软键事件 case EVENT_KeyCommand: { if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) { // 模拟标题栏右按钮选中消息 HitControl(m_TitleBtnRight); bHandled = TRUE; } } break; //下载完成事件 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case RR_PhotoDownload: { if(notifyData.nParam == FEED_PROFILE_IMAGE_INDEX) { //下载完后更新对应的图片 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap) { TMaskButton* pLogo = NULL; pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID)); if(pLogo) { TRectangle rc; pLogo->GetBounds(&rc); if( pProfileImage != NULL) { pProfileImage->Destroy(); pProfileImage = NULL; } pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pLogo->SetCaption(TUSTR_Re_NULL,0,0); pLogo->SetImage(pProfileImage, (rc.Width()-pProfileImage->GetWidth())/2, (rc.Height()-pProfileImage->GetHeight())/2); pLogo->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } break; } if( gItemData[notifyData.nParam].pBmp != NULL) { gItemData[notifyData.nParam].pBmp->Destroy(); gItemData[notifyData.nParam].pBmp = NULL; } if( gItemData[notifyData.nParam].pBmpZoom!= NULL) { gItemData[notifyData.nParam].pBmpZoom->Destroy(); gItemData[notifyData.nParam].pBmpZoom = NULL; } gItemData[notifyData.nParam].pBmp= LoadImgByPath(notifyData.pszFilePath); if(gItemData[notifyData.nParam].pBmp != NULL) { TMaskButton* pMyHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(gItemData[notifyData.nParam].HeadMaskButtonID)); if(pMyHeadMBtn != NULL) { gItemData[notifyData.nParam].pBmpZoom = gItemData[notifyData.nParam].pBmp->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[notifyData.nParam].pBmpZoom->QuickSpecialZoom(gItemData[notifyData.nParam].pBmp, 0, 0); pMyHeadMBtn->SetImage(gItemData[notifyData.nParam].pBmpZoom, (HEADMASKBUTTON_W - gItemData[notifyData.nParam].pBmpZoom->GetWidth())/2, (HEADMASKBUTTON_H - gItemData[notifyData.nParam].pBmpZoom->GetHeight())/2 ); pMyHeadMBtn->Draw(); } } break; } case RR_GuestbookPost: { pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_Success), TResource::LoadConstString(APP_RE_ID_STRING_SendComment), WMB_OK); RenRenAPICommon_Download(RR_GuestbookGet, this->GetWindowHwndId(), 0, m_FormMode); break; } case RR_UsersGetInfoPhoto: { tResponseUsersGetInfo* Response = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&Response); if(Response) { _UpdateProfilePhoto(pApp, Response); delete Response; Response = NULL; } } break; default: break; } } break; case MSG_POST_THREAD_NOTIFY: { PostNotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(PostNotifyMsgDataType)); //if(notifyData.nEditType == NewBlogEdit) { char* uid = Get_Url_Params(RR_GuestbookGet, "uid"); Set_Url_Params(RR_GuestbookPost, "uid", uid); Set_Url_Params(RR_GuestbookPost, "content", (char*)notifyData.pszEditContent); //留言是否为悄悄话,1表示是,0表示否,缺省值为0 if(notifyData.bPrivacy == TRUE) Set_Url_Params(RR_GuestbookPost, "type", "1"); else Set_Url_Params(RR_GuestbookPost, "type", "0"); //回复他人的留言需要传rid if(bReply) { char rid[64] = {0}; sprintf(rid, "%d", gItemData[m_SelectReplyItem].uid); Set_Url_Params(RR_GuestbookPost, "rid", rid); } else { Set_Url_Params(RR_GuestbookPost, "rid", ""); } //当回复公共主页的留言时需要传reply_gossip_id //TUChar sID[64]={0}; //Char id[64]={0}; //TUString::StrI64ToA(sID,(Int64)gItemData[m_SelectReplyItem].id); //TUString::StrUnicodeToStrUtf8(id,sID); char id[64] = {0}; DoubleToChar(gItemData[m_SelectReplyItem].id, id); Set_Url_Params(RR_GuestbookPost, "reply_gossip_id", (char*)id); RenRenAPICommon_Download(RR_GuestbookPost, this->GetWindowHwndId(), 0, 0); } bHandled = TRUE; break; } default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口事件处理 Boolean TUserInfoDetailForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; break; } case EVENT_WinClose: { _OnWinClose(pApp, pEvent); break; } case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); TRectangle rcBack(5, 142, 310, 314); GetBounds(&rcBack); // 擦除 dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_title_bg), 0, 0, SCR_W, GUI_API_STYLE_ALIGNMENT_LEFT); //dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_bottom_bg), 0, rcBack.Bottom()-44, //320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); pEraseEvent->result = 1; bHandled = TRUE; } break; case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); break; } //下载完成消息 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); switch(notifyData.nAccessType) { case KX_PhotoDownload: { if(pPhotoBmp != NULL) { pPhotoBmp->Destroy(); pPhotoBmp = NULL; } TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); TMaskButton* pHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_UserDetailHeadMaskButton)); if(pDownLoadBitmap) { TRectangle rc; pHeadMBtn->GetBounds(&rc); pPhotoBmp = TBitmap::Create(PHOTO_W, PHOTO_H, pDownLoadBitmap->GetDepth()); pPhotoBmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pHeadMBtn->SetImage(pPhotoBmp,(rc.Width()-pPhotoBmp->GetWidth())/2, (rc.Height()-pPhotoBmp->GetHeight())/2); pHeadMBtn->Draw(); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } break; } default: break; } bHandled = TRUE; break; } case EVENT_KeyCommand: { // 抓取右软键事件 if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) { // 模拟退出按钮选中消息 HitControl(m_BackBtn); bHandled = TRUE; } } break; default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }