// 窗口初始化 Boolean TPhotosGetAlbumsForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { int nErrorCode = eFailed; Int32 Height_Panel = 0; //Panel高度 //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_Comment,TITLE_BUTTON_LEFT); //显示不同的title if(m_FormMode == FORM_MODE_NORMAL) { SetAppTilte(this, APP_RE_ID_STRING_Album); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); char* uid = NULL; uid = Get_Url_Params(RR_PhotosGetAlbums, "uid"); if( strcmp(uid, RenRenUserInfo.szuid) == 0) { m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_take_photo, APP_RE_ID_BITMAP_take_photo); } } else if(m_FormMode == FORM_MODE_MYHOME) { tResponseProfile* ResponseProfile; nErrorCode = RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile != NULL) { if(ResponseProfile->uid == RenRenUserInfo.uid) { SetAppTilte(this, APP_RE_ID_STRING_MyNews); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Home, TITLE_BUTTON_RIGHT); m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_take_photo, APP_RE_ID_BITMAP_take_photo); } else { //姓名 TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); SetAppTilte(this, 0, pszFName); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); } delete ResponseProfile; ResponseProfile = NULL; } } //设置panel高度 TPanel* pTPanel = static_cast<TPanel*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonPanel)); TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if(pTPanel) { TRectangle rect; Height_Panel = SCR_H - STATUSBAR_H - TITLEBAR_H; if(m_FormMode == FORM_MODE_MYHOME) Height_Panel -= BOTTOM_TAB_H; pTPanel->GetBounds(&rect); rect.SetHeight(Height_Panel); pTPanel->SetBounds(&rect); } if(m_FormMode == FORM_MODE_MYHOME) CreateProfileBottomTab(this, &BottomTabCtrID, 2); //显示个人信息 if(m_FormMode == FORM_MODE_MYHOME) { Int32 Height_Top = 0; //CoolBarList上面信息的高度 Int32 Height_CoolBarList = 0; //CoolBarList高度 tResponseProfile* ResponseProfile; nErrorCode = RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile != NULL) { //头像 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(ResponseProfile->headurl); //pProfileImage = LoadImgByUrl(ResponseProfile->headurl); const TBitmap * pImageDeault = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_DefaultLarge); const TBitmap * pBackImage = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_headmask_large); if(pDownLoadBitmap == NULL) { //RenRenAPICommon_DownloadPhoto(ResponseProfile->headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pImageDeault, (TBitmap*)pImageDeault, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); } else { //需要做放大 pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pProfileImage, (TBitmap*)pProfileImage, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } //下载大头像 tResponseUsersGetInfo* ResponseUserInfoPhoto = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&ResponseUserInfoPhoto); if(ResponseUserInfoPhoto) { if( (ResponseUserInfoPhoto->nArraySize > 0) && (ResponseUserInfoPhoto->Array[0].uid == ResponseProfile->uid) ) { _UpdateProfilePhoto(pApp, ResponseUserInfoPhoto); } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } delete ResponseUserInfoPhoto; ResponseUserInfoPhoto = NULL; } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } //姓名 TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); CtrlAddItemToPanel_Label(this, pTPanel, RR_NAME_X, RR_NAME_Y, 0, FONT_NORMAL, pszFName, RGB_COLOR_BLACK); Height_Top += (RR_NAME_Y+RR_NAME_H); //状态 TUChar pszStatus[1024] = {0}; Coord nHeight_RichView = 0; if(ResponseProfile->nSize_status>0) { TUString::StrUtf8ToStrUnicode(pszStatus, (const Char *)ResponseProfile->status[0].content); CtrlAddItemToPanel_RichView(this, pTPanel, RR_STATUS_X, RR_STATUS_Y, RR_STATUS_W, &nHeight_RichView, FONT_MIDDLE, pszStatus, RGB_COLOR_BLACK); } //位置容错调整 if(nHeight_RichView > (RR_HEAD_H-RR_NAME_H) ) Height_Top += nHeight_RichView; else Height_Top += (RR_HEAD_H- RR_NAME_H); //调整间隔 Height_Top += 4; //设置CoolBarList高度 if(pCoolBarList) { TRectangle rect; Int32 nY = Height_Top; pCoolBarList->GetBounds(&rect); rect.SetY(nY); pCoolBarList->SetBounds(&rect); } delete ResponseProfile; ResponseProfile = NULL; } } //从对应Json中获取数据,用于更新UI nErrorCode = RenRenAPI_JsonParse(RR_PhotosGetAlbums, (void **)&Response); if (Response ) { _SetAlbumCoolBarList(pApp); delete Response; Response = NULL; } else { //显示无权限操作的情况(用户设置了阅读权限) if(nErrorCode == 200) { TUChar ErrorInfo[ERROR_INFO_LEN] = {0}; if(RenRenAPI_JsonParse_bSuccess(RR_PhotosGetAlbums, ErrorInfo) != 0) { if(TUString::StrLen(ErrorInfo) > 0) { //动态添加列表数据 TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; pRowList = pCoolBarList->Rows(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); //显示错误提示 TBarListItem* lpItem = NULL; lpItem = pBarRow->AppendItem(); if (lpItem) { CtrlAddItemToCoolBarList_Lable(this, lpItem, RR_INFO_X, RR_INFO_Y, RR_INFO_W, FONT_NORMAL, (TUChar*)ErrorInfo); lpItem->SetHeight(RR_INFO_H); lpItem->SetEnabled(FALSE); } } } } } return TRUE; }
void ShowAbout(int iFontSize, Byte bLineBreak, Byte bVersionPos, String sDate, TPicture *pPicture, String sAddComp, String sVersion, String sAppName, String sCopyright, String sText, HICON hIcon) { TForm *Form; int I; String sCaption; TVSFixedFileInfo FileVersionInfo; String CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, OriginalFilename, ProductName, ProductVersion; TAboutObject *AboutObject; ShowWaitCursor(); // Randomize; if (IsShift() & IsCtrl()) { sAppName = "Дураев"; sAppName += sLineBreak; sAppName += "Константин Петрович"; sCopyright = ""; sCaption = "Автор"; sDate = "29.03.1981"; sVersion = ""; iFontSize = 16; sAddComp = NULL; pPicture = NULL; sText = ""; for (int i = 1; i < 280; i++) if (i % 40 == 0) sText = sText + sLineBreak; else // TODO: sText = sText + String(AnsiChar(Chr(Ord('А') + // Random(Ord('Я') - Ord('А'))))); sText = sText + L"Я"; } else { GetFileVerInfo(Application->ExeName, FileVersionInfo, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, OriginalFilename, ProductName, ProductVersion); sCaption = LoadStr(IDS_ABOUT_CAPTION); if (sDate == NULL) sDate = FormatDateTime("yyyy.mm.dd", UnixToDateTime(((PIMAGE_NT_HEADERS)((DWORD)((PIMAGE_DOS_HEADER) HInstance) + (((PIMAGE_DOS_HEADER) HInstance)->e_lfanew))) ->FileHeader.TimeDateStamp)); if (sVersion == NULL) { sVersion = FileVersion; if (IsValueInWord(FileVersionInfo.dwFileFlags, VS_FF_DEBUG)) sVersion = sVersion + LoadStr(IDS_ABOUT_DEBUG); else if (IsValueInWord(FileVersionInfo.dwFileFlags, VS_FF_PRERELEASE)) sVersion = sVersion + LoadStr(IDS_ABOUT_RC); } if (sAppName == NULL) sAppName = ProductName; if (sCopyright == NULL) sCopyright = LegalCopyright + "|@[email protected]"; if (sText == NULL) { sText = LoadStr(IDS_ABOUT_EULA1) + sLineBreak + LoadStr(IDS_ABOUT_EULA2) + sLineBreak + LoadStr(IDS_ABOUT_EULA3) + sLineBreak + LoadStr(IDS_ABOUT_EULA4); } if (bLineBreak != MAXBYTE) { I = PosPlace(SPACE, sAppName, bLineBreak); sAppName = sAppName.SubString(1, I - 1) + sLineBreak + sAppName.SubString(I + 1, MAXINT); } } // IsShift and IsCtrl if (hIcon == NULL) hIcon = LoadIcon(HInstance, L"MAINICON"); AboutObject = new TAboutObject(); Form = new TForm(Application); // Owner; Form->ShowHint = true; Form->Font->Name = "Arial"; Form->Font->Size = 10; Form->BorderStyle = bsDialog; Form->Caption = sCaption; Form->ClientHeight = 165; Form->ClientWidth = 420; TBevel *bvlIconFrame = new TBevel(Form); bvlIconFrame->Parent = Form; bvlIconFrame->SetBounds(8, 14, 52, 52); bvlIconFrame->Shape = bsFrame; TPanel *pnlIcon = new TPanel(Form); pnlIcon->Parent = Form; pnlIcon->SetBounds(16, 22, 36, 36); pnlIcon->Caption = ""; pnlIcon->BevelOuter = bvNone; pnlIcon->BorderStyle = bsSingle; pnlIcon->ParentBackground = false; pnlIcon->Color = (TColor) Random(0xFFFFFF); TImage *imgIcon = new TImage(Form); // Icon imgIcon->Parent = pnlIcon; imgIcon->Align = alClient; imgIcon->Transparent = true; imgIcon->Picture->Icon->Handle = hIcon; TLabel *lblCopyright = new TLabel(Form); // Copyright lblCopyright->Tag = 1; lblCopyright->Parent = Form; lblCopyright->Font->Style = TFontStyles() << fsBold; lblCopyright->SetBounds(8, 80, 0, 0); int PosHint = Pos('|', sCopyright); if (PosHint == 0) lblCopyright->Caption = sCopyright; else { lblCopyright->Caption = sCopyright.SubString(1, PosHint - 1); lblCopyright->Hint = sCopyright.SubString(PosHint + 1, MAXINT); lblCopyright->Cursor = crHandPoint; lblCopyright->OnMouseEnter = AboutObject->MouseEnter; lblCopyright->OnMouseLeave = AboutObject->MouseLeave; if (lblCopyright->Hint[1] == '@') { lblCopyright->Hint = lblCopyright->Hint.SubString(2, MAXINT); AboutObject->MailAddress = lblCopyright->Hint; AboutObject->MailSubject = OriginalFilename + " " + FileVersion; } lblCopyright->OnClick = AboutObject->Click; } TLabel *lblText = new TLabel(Form); // Text lblText->Parent = Form; lblText->WordWrap = true; lblText->SetBounds(8, 100, Form->ClientWidth - 16, 0); lblText->Caption = sText; // I = lblText->Top + lblText->Height; Form->ClientHeight = Form->ClientHeight + lblText->Height; if (sAddComp != NULL) { /* with TBevel.Create(Form) do { Parent = Form; SetBounds(7, I + 5, Form.ClientWidth - 15, 5); Shape = bsTopLine; I = Top + Height; }; with TLabel.Create(Form) do // Add Components { Parent = Form; SetBounds(8, I, 0, 0); Caption = 'Программное обеспечение использует следующие компоненты:'; I = Top + Height; }; with TLabel.Create(Form) do // Components { Tag = 2; Parent = Form; Font.Style = [fsBold]; SetBounds(8, I, 0, 0); Caption = sAddComp; Form.ClientHeight = Form.ClientHeight + Height + 12; if FileExists(FileInAppDir(rsLicenses)) then { Cursor = crHandPoint; OnClick = ClickObject.Click; OnMouseEnter = ClickObject.MouseEnter; OnMouseLeave = ClickObject.MouseLeave; }; } */ } else // sAddComp != NULL Form->ClientHeight = Form->ClientHeight - 12; TBevel *bvlBottom = new TBevel(Form); bvlBottom->Parent = Form; bvlBottom->SetBounds(7, Form->ClientHeight - 43, Form->ClientWidth - 15, 5); bvlBottom->Shape = bsTopLine; lblMemory = new TLabel(Form); // Физическая ... lblMemory->Parent = Form; lblMemory->SetBounds(8, Form->ClientHeight - 38, 0, 0); lblMemory->Caption = LoadStr(IDS_ABOUT_MEMORY); lblMemoryValue = new TLabel(Form); // TotalPhys lblMemoryValue->Parent = Form; lblMemoryValue->Font->Style = TFontStyles() << fsBold; lblMemoryValue->SetBounds(lblMemory->Width + 13, Form->ClientHeight - 38, 0, 0); lblProc = new TLabel(Form); // Процессор: lblProc->Parent = Form; lblProc->SetBounds(8, Form->ClientHeight - 22, 0, 0); lblProc->Caption = LoadStr(IDS_ABOUT_PROCESSOR); lblProcValue = new TLabel(Form); // CPUSpeed lblProcValue->Parent = Form; lblProcValue->Font->Style = TFontStyles() << fsBold; lblProcValue->SetBounds(lblMemory->Width + 13, Form->ClientHeight - 22, 0, 0); TGradientPanel *pnlName = new TGradientPanel(Form); pnlName->Parent = Form; pnlName->StartUpdate(); pnlName->SetBounds(68, 8, Form->ClientWidth - 76, 64); pnlName->BorderStyle = bsSingle; pnlName->BevelOuter = bvNone; pnlName->ParentBackground = false; if (pPicture == NULL) pnlName->ColorStart = pnlIcon->Color; else pnlName->ColorStart = clBlack; pnlName->ColorEnd = clBlack; pnlName->EndUpdate(); if (pPicture == NULL) { TLabel *lblAppName = new TLabel(Form); // Application Name (1) lblAppName->Parent = pnlName; lblAppName->SetBounds(2, 2, Form->ClientWidth - 83, 58); lblAppName->Alignment = taCenter; lblAppName->AutoSize = false; lblAppName->Caption = sAppName; lblAppName->ParentColor = false; lblAppName->Color = clBlack; lblAppName->ParentFont = false; lblAppName->Font->Charset = DEFAULT_CHARSET; lblAppName->Font->Color = clBlack; lblAppName->Font->Height = -51; lblAppName->Font->Name = "Courier New"; lblAppName->Font->Style = TFontStyles() << fsBold << fsItalic; lblAppName->Font->Size = iFontSize; lblAppName->Transparent = true; lblAppName->Layout = tlCenter; lblAppName->WordWrap = true; TLabel *lblAppName2 = new TLabel(Form); // Application Name (2) lblAppName2->Parent = pnlName; lblAppName2->SetBounds(0, 0, Form->ClientWidth - 83, 58); lblAppName2->Alignment = taCenter; lblAppName2->AutoSize = false; lblAppName2->Caption = sAppName; lblAppName2->ParentColor = false; lblAppName2->Color = clBlack; lblAppName2->ParentFont = false; lblAppName2->Font->Charset = DEFAULT_CHARSET; lblAppName2->Font->Color = clWhite; lblAppName2->Font->Height = -51; lblAppName2->Font->Name = "Courier New"; lblAppName2->Font->Style = TFontStyles() << fsBold << fsItalic; lblAppName2->Font->Size = iFontSize; lblAppName2->Transparent = true; lblAppName2->Layout = tlCenter; lblAppName2->WordWrap = true; } // pPicture == NULL else { TImage *imgPicture = new TImage(Form); imgPicture->Parent = pnlName; imgPicture->Align = alClient; imgPicture->Picture->Assign(pPicture); } TLabel *lblDate = new TLabel(Form); // Date lblDate->Parent = pnlName; lblDate->Caption = sDate; lblDate->Font->Assign(Form->Font); lblDate->Font->Style = TFontStyles() << fsBold; lblDate->Font->Color = clWhite; lblDate->Font->Size = 8; lblDate->Alignment = taRightJustify; switch (3) { case 0: lblDate->SetBounds(2, 2, lblDate->Width, lblDate->Height); break; case 1: lblDate->SetBounds(2, pnlName->ClientHeight - lblDate->Height - 2, lblDate->Width, lblDate->Height); break; case 2: lblDate->SetBounds(pnlName->ClientWidth - lblDate->Width - 2, 2, lblDate->Width, lblDate->Height); break; default: lblDate->SetBounds(pnlName->ClientWidth - lblDate->Width - 2, pnlName->ClientHeight - lblDate->Height - 2, lblDate->Width, lblDate->Height); } lblDate->Transparent = true; TLabel *lblVerion = new TLabel(Form); // Version lblVerion->Parent = pnlName; lblVerion->Caption = sVersion; lblVerion->Font->Assign(Form->Font); lblVerion->Font->Style = TFontStyles() << fsBold; lblVerion->Font->Color = clWhite; lblVerion->Font->Size = 8; switch (2) { case 0: lblVerion->SetBounds(2, 2, lblVerion->Width, lblVerion->Height); break; case 1: lblVerion->SetBounds(2, pnlName->ClientHeight - lblVerion->Height - 2, lblVerion->Width, lblVerion->Height); break; case 2: lblVerion->SetBounds(pnlName->ClientWidth - lblVerion->Width - 2, 2, lblVerion->Width, lblVerion->Height); break; default: lblVerion->SetBounds(pnlName->ClientWidth - lblVerion->Width - 2, pnlName->ClientHeight - lblVerion->Height - 2, lblVerion->Width, lblVerion->Height); } lblVerion->Transparent = true; TButton *btnClose = new TButton(Form); btnClose->Parent = Form; btnClose->Caption = "OK"; btnClose->ModalResult = mrCancel; btnClose->Cancel = true; btnClose->SetBounds(Form->ClientWidth - 83, Form->ClientHeight - 34, 75, 26); btnClose->TabOrder = 0; TTimer *timer = new TTimer(Form); timer->OnTimer = AboutObject->TimerTimer; timer->Interval = 1; timer->Enabled = true; RestoreCursor(); Form->Left = (Screen->Width - Form->Width) / 2; Form->Top = (Screen->Height - Form->Height) / 2; SetCurPosToCenter(btnClose); Form->ShowModal(); Form->Free(); AboutObject->Free(); lblMemory = NULL; lblProc = NULL; lblMemoryValue = NULL; lblProcValue = NULL; }
// 窗口初始化 Boolean TGuestbookGetForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { 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); //SetAppTilte(this, APP_RE_ID_STRING_Guestbook); //显示不同的title if(m_FormMode == FORM_MODE_NORMAL) { SetAppTilte(this, APP_RE_ID_STRING_Guestbook); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); } else if(m_FormMode == FORM_MODE_MYHOME) { tResponseProfile* ResponseProfile; RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile) { if(ResponseProfile->uid == RenRenUserInfo.uid) { SetAppTilte(this, APP_RE_ID_STRING_MyNews); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Home,TITLE_BUTTON_RIGHT); } else { TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); SetAppTilte(this, 0, pszFName); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); } delete ResponseProfile; ResponseProfile = NULL; } } //设置panel高度 TPanel* pTPanel = static_cast<TPanel*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonPanel)); TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if( (pTPanel == NULL) || (pCoolBarList == NULL) ) return FALSE; //调整Panel高度 { TRectangle rect; Int32 Height_Panel = 0; //Panel高度 Height_Panel = SCR_H - STATUSBAR_H - TITLEBAR_H; if(m_FormMode == FORM_MODE_MYHOME) Height_Panel -= BOTTOM_TAB_H; pTPanel->GetBounds(&rect); rect.SetHeight(Height_Panel); pTPanel->SetBounds(&rect); } if(m_FormMode == FORM_MODE_MYHOME) CreateProfileBottomTab(this, &BottomTabCtrID, 4); //:TODO: //显示个人信息 if(m_FormMode == FORM_MODE_MYHOME) { Int32 Height_Top = 0; //CoolBarList上面信息的高度 tResponseProfile* ResponseProfile; RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile != NULL) { //头像 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(ResponseProfile->headurl); //pProfileImage = LoadImgByUrl(ResponseProfile->headurl); const TBitmap * pImageDeault = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_DefaultLarge); const TBitmap * pBackImage = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_headmask_large); if(pDownLoadBitmap == NULL) { //RenRenAPICommon_DownloadPhoto(ResponseProfile->headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pImageDeault, (TBitmap*)pImageDeault, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); } else { //需要做放大 pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pProfileImage, (TBitmap*)pProfileImage, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } //下载大头像 tResponseUsersGetInfo* ResponseUserInfoPhoto = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&ResponseUserInfoPhoto); if(ResponseUserInfoPhoto) { if( (ResponseUserInfoPhoto->nArraySize > 0) && (ResponseUserInfoPhoto->Array[0].uid == ResponseProfile->uid) ) { _UpdateProfilePhoto(pApp, ResponseUserInfoPhoto); } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } delete ResponseUserInfoPhoto; ResponseUserInfoPhoto = NULL; } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } //姓名 TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); CtrlAddItemToPanel_Label(this, pTPanel, RR_NAME_X, RR_NAME_Y, 0, FONT_NORMAL, pszFName, RGB_COLOR_BLACK); Height_Top += (RR_NAME_Y+RR_NAME_H); //状态 TUChar pszStatus[1024] = {0}; Coord nHeight_RichView = 0; if(ResponseProfile->nSize_status>0) { TUString::StrUtf8ToStrUnicode(pszStatus, (const Char *)ResponseProfile->status[0].content); CtrlAddItemToPanel_RichView(this, pTPanel, RR_STATUS_X, RR_STATUS_Y, RR_STATUS_W, &nHeight_RichView, FONT_MIDDLE, pszStatus, RGB_COLOR_BLACK); } //位置容错调整 if(nHeight_RichView > (RR_HEAD_H-RR_NAME_H) ) Height_Top += nHeight_RichView; else Height_Top += (RR_HEAD_H- RR_NAME_H); //调整间隔 Height_Top += 4; //设置CoolBarList高度 if(pCoolBarList) { TRectangle rect; Int32 nY = Height_Top; pCoolBarList->GetBounds(&rect); rect.SetY(nY); pCoolBarList->SetBounds(&rect); } delete ResponseProfile; ResponseProfile = NULL; } } //从对应Json中获取数据,用于更新UI int nErrorCode = eFailed; tResponseGuestbookGet* Response = NULL; nErrorCode = RenRenAPI_JsonParse(RR_GuestbookGet, (void **)&Response); //动态添加列表数据 TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; pRowList = pCoolBarList->Rows(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); if(Response != NULL) { TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); pRowList->BeginUpdate(); if(Response->nArraySize == 0) { TUChar pszCount[64] = {0}; TUString::StrPrintF(pszCount, TResource::LoadConstString(APP_RE_ID_STRING_GuestbookCount), Response->nArraySize); TBarListItem* lpItem = NULL; lpItem = pBarRow->AppendItem(); lpItem->SetCaption(pszCount); lpItem->SetEnabled(FALSE); } //以下为增加列表项 for (int i = 0; i < Response->nArraySize; i++) { TUChar pszString[4096] = {0}; Coord nHeigh = 0; pListItem = pBarRow->AppendItem(); if (pListItem) { //属性设置 pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itNone); //先读取磁盘cache, 无文件再下载 gItemData[i].pBmp = LoadImgByUrl(Response->Array[i].headurl); if( gItemData[i].pBmp != NULL) { //头像,需要做缩放 gItemData[i].pBmpZoom = gItemData[i].pBmp->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[i].pBmpZoom->QuickSpecialZoom(gItemData[i].pBmp, 0, 0); gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmpZoom, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); } 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->Array[i].headurl, this->GetWindowHwndId(), i ); } //姓名 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name); CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X, NAME_Y, 0, NAME_FONT, pszString, RGB_COLOR_LIGHTBLUE); //悄悄话 if(Response->Array[i].is_whisper != 0) { gItemData[i].bWhisper = TRUE; CtrlAddItemToCoolBarList_Image(this, pListItem, WHISPER_X, WHISPER_Y , 49, 15, (TBitmap*)TResource::LoadConstBitmap(APP_RE_ID_BITMAP_whisper)); } //内容,去掉html格式化内容 StrRemoveAtoB(Response->Array[i].content, strlen(Response->Array[i].content), "<", ">"); TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].content); CtrlAddItemToCoolBarList_RichView(this, pListItem, CONTENT_X, CONTENT_Y, CONTENT_W, &nHeigh, CONTENT_FONT, pszString); //时间 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].time); CtrlAddItemToCoolBarList_Lable(this, pListItem, TIME_X, CONTENT_Y+nHeigh, 0, TIME_FONT, pszString, RGB_COLOR_GRAY); //回复 if(Response->Array[i].uid != RenRenUserInfo.uid) { TUString::StrCopy(pszString,TResource::LoadConstString(APP_RE_ID_STRING_Reply)); gItemData[i].TButtonReplyID = CtrlAddItemToCoolBarList_Button(this, pListItem, BUTTON_REPLY_X, BUTTON_REPLY_Y, BUTTON_REPLY_W, BUTTON_REPLY_H, pszString); } //设置CoolBarList Item的高度 pListItem->SetHeight(60 + nHeigh); //保存id gItemData[i].id = Response->Array[i].id; gItemData[i].uid = Response->Array[i].uid; } } pRowList->EndUpdate(); delete Response; Response = NULL; } else { //显示无权限操作的情况(用户设置了阅读权限) if(nErrorCode == 200) { TUChar ErrorInfo[ERROR_INFO_LEN] = {0}; int iResult = RenRenAPI_JsonParse_bSuccess(RR_GuestbookGet, ErrorInfo); if(iResult != 0) { if(TUString::StrLen(ErrorInfo) > 0) { //显示错误提示 TBarListItem* lpItem = NULL; lpItem = pBarRow->AppendItem(); if (lpItem) { CtrlAddItemToCoolBarList_Lable(this, lpItem, RR_INFO_X, RR_INFO_Y, RR_INFO_W, FONT_NORMAL, (TUChar*)ErrorInfo); lpItem->SetHeight(RR_INFO_H); lpItem->SetEnabled(FALSE); } } } } } return TRUE; }