// 窗口事件处理 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 TPagesGetListForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { int iRet = eFailed; tResponsePagesGetList* Response = NULL; //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_Refresh,TITLE_BUTTON_LEFT); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); SetAppTilte(this, APP_RE_ID_STRING_Pages); //从对应Json中获取数据,用于更新UI iRet = RenRenAPI_JsonParse(RR_PagesGetList, (void **)&Response); //:TODO: //Panel -> CoolBarList->pRowList->pBarRow->pListItem TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if (pCoolBarList) { TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); pRowList = pCoolBarList->Rows(); if (pRowList) { pRowList->BeginUpdate(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); //数量统计 { TBarListItem* lpItem = NULL; TUChar pszTitle[64] = {0}; lpItem = pBarRow->AppendItem(); if (lpItem) { Int32 StringWidth = 0; TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_PagesCount), Response->nArraySize); StringWidth = GetShowAllStringWidth(pszTitle, FONT_MIDDLE) + 5; //多预留一些 CtrlAddItemToCoolBarList_Lable(this, lpItem, (COOLBARLIST_WIDTH-StringWidth)/2, 10, StringWidth, FONT_MIDDLE, pszTitle); lpItem->SetHeight(10*2+FONT_MIDDLE); lpItem->SetEnabled(FALSE); } } //以下为增加列表项 for (int i = 0; i < Response->nArraySize; i++) { TUChar pszString[4096] = {0}; Coord nHeight = 0; Int32 nItemHeight = 0; pListItem = pBarRow->AppendItem(); if (pListItem) { //属性设置 pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itNone); //头像,需要做缩放 //先读取磁盘cache, 无文件再下载 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(Response->Array[i].headurl); if( pDownLoadBitmap != NULL) { gItemData[i].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); gItemData[i].MaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmp,(TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } else { gItemData[i].MaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default),(TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); //因为第一项为数据统计, 所以参数需要+1 RenRenAPICommon_DownloadPhoto(Response->Array[i].headurl, this->GetWindowHwndId(), i ); } #if 1 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name); CtrlAddItemToCoolBarList_Lable(this , pListItem , NAME_X, NAME_Y, 0, FONT_NORMAL,pszString, RGB_COLOR_LIGHTBLUE); TUString::StrPrintF(pszString , TResource::LoadConstString(APP_RE_ID_STRING_FriendNumFormat), Response->Array[i].fans_count); CtrlAddItemToCoolBarList_Lable(this, pListItem, COUNT_INFO_X, COUNT_INFO_Y, 0, FONT_SMALL, pszString, RGB_COLOR_GRAY); pListItem->SetHeight(COOLBARLIST_HEIGHT); #else //带描述的布局 //姓名 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name); CtrlAddItemToCoolBarList_RichView(this , pListItem , 65, 5, 240, &nHeight, FONT_NORMAL,pszString, RGB_COLOR_LIGHTBLUE); nItemHeight = 5 + nHeight; //描述 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].desc); CtrlAddItemToCoolBarList_RichView(this , pListItem , 65, nHeight + 5, 240, &nHeight, FONT_NORMAL,pszString, RGB_COLOR_BLACK); //成员个数 TUString::StrPrintF(pszString , TResource::LoadConstString(APP_RE_ID_STRING_FriendNumFormat), Response->Array[i].fans_count); CtrlAddItemToCoolBarList_Lable(this, pListItem, 65, (nItemHeight + nHeight + 10), 0, FONT_SMALL, pszString, RGB_COLOR_GRAY); nItemHeight = nItemHeight + nHeight + 25 + FONT_SMALL; pListItem->SetHeight(nItemHeight); #endif pListItem->SetTagValue(i); gItemData[i].id = Response->Array[i].page_id; } } pRowList->EndUpdate(); } } if( Response ) { delete Response; } return TRUE; }
/** * 设置专辑列表显示 * * \param pApp * * \return */ Int32 TPhotosGetAlbumsForm::_SetAlbumCoolBarList(TApplication* pApp) { //获取CoolBarList 控件指针 TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if (Response) { //动态添加控件处理 if (pCoolBarList) { //大行类,它管理 N个TBarRow对象 TBarRowList* pRowList = NULL; //小行类,管理N个TBarListItem 对象 TBarRow* pBarRow = NULL; //TCoolBarList中的项,为行所包含,一行可以包含多个项 TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); //获取行列表指针,通过行列表指针插入一行 pRowList = pCoolBarList->Rows(); if (pRowList) { //开始更新数据 pRowList->BeginUpdate(); //清除所有行 pRowList->Clear(); //在行列表尾追加一行 pBarRow = pRowList->AppendRow(); //数量统计 { TBarListItem* lpItem = NULL; TUChar pszTitle[64] = {0}; TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_AlbumCount), Response->nArraySize); lpItem = pBarRow->AppendItem(); lpItem->SetCaption(pszTitle); lpItem->SetEnabled(FALSE); } for(int i=0; i<Response->nArraySize; i++) { TUChar pnString[128] = {0};//相册名称 TUChar pctString[64] = {0};//相册创建时间 TUChar psString[64] = {0}; //相册大小 //添加列表项 pListItem = pBarRow->AppendItem(); if (pListItem) { //设定item属性 pListItem->SetHeight(COOLBAR_ITEM_HEIGHT); pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itDefault); //磁盘cache无文件,再下载 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(Response->Array[i].url); // 1、获取相册封面,图片头像,需要做缩放 if( pDownLoadBitmap != NULL) { gItemData[i].pBmp= pDownLoadBitmap->Create(IMAGE_W, IMAGE_H, 32); gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); gItemData[i].nImageID = CtrlAddItemToCoolBarList_Image(this, pListItem, IMAGE_X, IMAGE_Y, IMAGE_W, IMAGE_H, gItemData[i].pBmp); //pListItem->SetIcon( gItemData[i].pBmpZoom ); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } else { //因为第一项为数据统计, 所以参数需要+1 RenRenAPICommon_DownloadPhoto(Response->Array[i].url, this->GetWindowHwndId(), i ); gItemData[i].nImageID = CtrlAddItemToCoolBarList_Image(this, pListItem, IMAGE_X, IMAGE_Y, IMAGE_W, IMAGE_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default)); //pListItem->SetIcon(TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default)); } // 2、获取相册名称 TUString::StrUtf8ToStrUnicode(pnString , (const Char *)Response->Array[i].name); //是否加密 if(Response->Array[i].visable == 4) { CtrlAddItemToCoolBarList_Image(this, pListItem, NAME_X, NAME_Y + (NAME_H - LOCK_H)/2, LOCK_W, LOCK_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_locked)); CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X+LOCK_W, NAME_Y, NAME_W-LOCK_W, NAME_FONT, pnString, RGB_COLOR_BLACK); } else { CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X, NAME_Y, NAME_W, NAME_FONT, pnString, RGB_COLOR_BLACK); } // 3、获取相册大小 //按照格式串填写目的串 TUString::StrPrintF(psString, TResource::LoadConstString(APP_RE_ID_STRING_PhotosCountFormat), Response->Array[i].size); CtrlAddItemToCoolBarList_Lable(this, pListItem, SIZE_X, SIZE_Y, 0, SIZE_FONT, psString, RGB_COLOR_BLACK); // 4、获取创建相册日期 TUString::StrUtf8ToStrUnicode(pctString , (const Char *)Response->Array[i].create_time); CtrlAddItemToCoolBarList_Lable(this, pListItem, DATE_X, DATE_Y, 0, DATE_FONT, pctString, RGB_COLOR_GRAY); pListItem->SetTagValue(i); } gItemData[i].uid = Response->Array[i].uid; gItemData[i].aid = Response->Array[i].aid; gItemData[i].visable = Response->Array[i].visable; } pRowList->EndUpdate(); } } } return TRUE; }
// 窗口初始化 Boolean TMessageGetsForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { int iRet = eFailed; tResponseMessageGets* Response = NULL; if(nMessageBoxType == MESSAGE_TYPE_INBOX ) { SetAppTilte(this, APP_RE_ID_STRING_MessagesInBox); //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_OutBox,TITLE_BUTTON_LEFT); m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over); } else { SetAppTilte(this, APP_RE_ID_STRING_MessagesOutBox); //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_InBox,TITLE_BUTTON_LEFT); m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over); } m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); //从对应Json中获取数据,用于更新UI iRet = RenRenAPI_JsonParse(RR_MessageGets, (void **)&Response); //:TODO: //Panel -> CoolBarList->pRowList->pBarRow->pListItem TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if(pCoolBarList) { TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); pRowList = pCoolBarList->Rows(); if (pRowList) { pRowList->BeginUpdate(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); if(pBarRow) { //数量统计 { TBarListItem* lpItem = NULL; TUChar pszTitle[64] = {0}; lpItem = pBarRow->AppendItem(); if (lpItem) { Int32 StringWidth = 0; TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_MessageCount), Response->count); StringWidth = GetShowAllStringWidth(pszTitle, FONT_MIDDLE) + 8; //多预留一些 CtrlAddItemToCoolBarList_Lable(this, lpItem, (COOLBARLIST_WIDTH-StringWidth)/2, NAME_Y, 0, FONT_MIDDLE, pszTitle); lpItem->SetHeight(NAME_Y*2+FONT_MIDDLE); lpItem->SetEnabled(FALSE); } } //以下为增加列表项自定义项 for (int i = 0; i < Response->nSize_messages; i++) { TUChar pszString[4096] = {0}; pListItem = pBarRow->AppendItem(); if (pListItem) { //属性设置 pListItem->SetHeight(COOLBARLIST_HEIGHT); pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itNone); //头像,先读取磁盘cache, 无文件再下载 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(Response->messages[i].head_url); if( pDownLoadBitmap != NULL) { gItemData[i].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmp, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } else { gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default), (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); RenRenAPICommon_DownloadPhoto(Response->messages[i].head_url, this->GetWindowHwndId(), i ); } //姓名 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].name); CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X, NAME_Y, 0, FONT_MIDDLE, pszString); //时间 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].time); CtrlAddItemToCoolBarList_Lable(this, pListItem, TIME_X, TIME_Y, 0, FONT_SMALL, pszString, RGB_COLOR_LIGHTBLUE); //标题,新消息显示为红色 //一个小技巧,一个消息显示为两种(已读和未读), 然后根据情况隐藏一个 TUChar pszStringTemp[4096] = {0}; TUString::StrUtf8ToStrUnicode(pszStringTemp , (const Char *)Response->messages[i].title); gItemData[i].TitleIDRead = CtrlAddItemToCoolBarList_Lable(this, pListItem, TITLE_X, TITLE_Y, TITLE_W, FONT_NORMAL, pszStringTemp); TUString::StrCopy(pszString, TResource::LoadConstString(APP_RE_ID_STRING_NewMessageFlag)); TUString::StrCat(pszString, pszStringTemp); gItemData[i].TitleIDUnread = CtrlAddItemToCoolBarList_Lable(this, pListItem, TITLE_X, TITLE_Y, TITLE_W, FONT_NORMAL, pszString, RGB_COLOR_RED); if(Response->messages[i].is_read == 0) { this->HideControl(gItemData[i].TitleIDRead); } else { this->HideControl(gItemData[i].TitleIDUnread); } //内容 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].content); CtrlAddItemToCoolBarList_Lable(this, pListItem, CONTENT_X, CONTENT_Y, CONTENT_W, FONT_MIDDLE, pszString, RGB_COLOR_GRAY); pListItem->SetTagValue(i); gItemData[i].id = Response->messages[i].id; } } } pRowList->EndUpdate(); } } if( Response ) { delete Response; } return TRUE; }
// 窗口事件处理 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; }