//--------------------------------------------------------------------------- void __fastcall TSynchronizeDialog::UpdateControls() { EnableControl(StartButton, !LocalDirectoryEdit->Text.IsEmpty() && !RemoteDirectoryEdit->Text.IsEmpty()); TButton * OldButton = FSynchronizing ? StartButton : StopButton; TButton * NewButton = FSynchronizing ? StopButton : StartButton; if (!NewButton->Visible || OldButton->Visible) { NewButton->Visible = true; if (OldButton->Focused()) { NewButton->SetFocus(); } OldButton->Default = false; NewButton->Default = true; OldButton->Visible = false; // some of the above steps hides accelerators when start button is pressed with mouse ResetSystemSettings(this); } Caption = FormatFormCaption(this, LoadStr(FSynchronizing ? SYNCHRONIZE_SYCHRONIZING : SYNCHRONIZE_TITLE)); EnableControl(TransferSettingsButton, !FSynchronizing); CancelButton->Visible = !FSynchronizing || FLAGSET(FOptions, soNoMinimize); EnableControl(CancelButton, !FSynchronizing); EnableControl(DirectoriesGroup, !FSynchronizing); EnableControl(OptionsGroup, !FSynchronizing); EnableControl(CopyParamGroup, !FSynchronizing); MinimizeButton->Visible = FSynchronizing && FLAGCLEAR(FOptions, soNoMinimize); EnableControl(SynchronizeSelectedOnlyCheck, OptionsGroup->Enabled && FLAGSET(FOptions, soAllowSelectedOnly)); UnicodeString InfoStr = CopyParams.GetInfoStr(L"; ", ActualCopyParamAttrs()); CopyParamLabel->Caption = InfoStr; CopyParamLabel->Hint = InfoStr; CopyParamLabel->ShowHint = (CopyParamLabel->Canvas->TextWidth(InfoStr) > (CopyParamLabel->Width * 3 / 2)); TransferSettingsButton->Style = FLAGCLEAR(Options, soDoNotUsePresets) ? TCustomButton::bsSplitButton : TCustomButton::bsPushButton; if (LogPanel->Visible != FSynchronizing) { if (FSynchronizing) { LogPanel->Visible = true; ClientHeight = ClientHeight + LogPanel->Height; } else { ClientHeight = ClientHeight - LogPanel->Height; LogPanel->Visible = false; } } // When minimizing to tray globally, no point showing special "minimize to tray" command MinimizeButton->Style = !WinConfiguration->MinimizeToTray ? TCustomButton::bsSplitButton : TCustomButton::bsPushButton; }
//添加Button控件到CoolBarList, // pszString必须是动态的(非Static) // nWidth 为0 -- 自动长度 Int32 CtrlAddItemToCoolBarList_Button(TWindow*pWin, TBarListItem* pListItem, Coord nX, Coord nY, Coord nWidth, Int32 nHeight, TUChar* pszString) { TRectangle obBtnRec(0,0,0,0); Int32 nButtonId = pListItem->AddCtrl(CTL_CLASS_BUTTON, 20, 5); TButton* pButton = static_cast<TButton*>(pWin->GetControlPtr(nButtonId)); obBtnRec.SetRect(nX, nY, nWidth, nHeight); pButton->SetBounds(&obBtnRec); pButton->SetEnabled(TRUE); pButton->SetCaption(pszString,FALSE); return nButtonId; }
bool MainMenu::Update() { bool inWindow = false; bool leftButton = false; while(GetEvent(_event)) { if ( _event.Type == Event::MouseButtonPressed && _event.MouseButton.Button == Mouse::Left ) leftButton = true; } Vector2i Cell = Vector2i( _mouse.x/32, _mouse.y/32); TButton * b = 0x00; if ( _mouse.x >= _wintmp->GetPosition().x && _mouse.x <= _wintmp->GetPosition().x + _wintmp->GetSize().x && _mouse.y >= _wintmp->GetPosition().y && _mouse.y <= _wintmp->GetPosition().y + _wintmp->GetSize().y ) { inWindow = true; _wintmp->HighLight(); } else _wintmp->Reset(); if ( inWindow ) b = _wintmp->GetButton(_mouse); if ( leftButton ) { if ( b ) { switch(b->GetValue()) { case 1: { SetNext(MODE_GAME); return 0; } case 2: { SetNext(MODE_EDITOR); return 0; } } } } return 1; }
Int32 SetAppBitmapButton(TWindow * pWindow, Int32 NomalBtnID, Int32 OverBtnID) { Int32 m_BtnID = 0; TButton *pBtn; TRectangle BtnRC(TITLE_BUTTON_X, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H); const TBitmap * pNormalBmp = TResource::LoadConstBitmap(NomalBtnID);//APP_RE_ID_BITMAP_write_but const TBitmap * pOverBmp = TResource::LoadConstBitmap(OverBtnID);//APP_RE_ID_BITMAP_write_but_over pBtn = new TButton; if(pBtn->Create(pWindow)) { pBtn->SetBounds(&BtnRC); m_BtnID = pBtn->GetId(); pBtn->SetCaption(TUSTR_Kx_NULL,FALSE); pBtn->SetStyles(BTN_STYLES_GRAPGICS); pBtn->SetImage(pNormalBmp,0); pBtn->SetImage(pOverBmp,1); pBtn->Show(TRUE); } return m_BtnID; }
Int32 CtrlAddItemToPanel_Button(TWindow*pWin, TPanel* pPanel, Coord nX, Coord nY, Coord nWidth, Int32 nHeight, TUChar* pszString) { TRectangle obBtnRec(0,0,0,0); TButton* pButton = new TButton(); Int32 nButtonId = -1; if(pButton->Create(pPanel)) { nButtonId = pButton->GetId(); obBtnRec.SetRect(nX, nY, nWidth, nHeight); pButton->SetBounds(&obBtnRec); pButton->SetEnabled(TRUE); pButton->SetCaption(pszString,FALSE); } return nButtonId; }
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; }
//--------------------------------------------------------------------------- bool __fastcall InputDialog(const UnicodeString ACaption, const UnicodeString APrompt, UnicodeString & Value, UnicodeString HelpKeyword, TStrings * History, bool PathInput, TInputDialogInitialize OnInitialize) { bool Result = False; TInputDialogToken Token; TForm * Form = new TForm(GetFormOwner(), 0); // bypass the VCL streaming (for Salamander) try { // salam needs to override this in UseSystemSettings Form->Position = poOwnerFormCenter; SetCorrectFormParent(Form); UseSystemSettingsPre(Form); // this is what TCustomForm.Loaded does // Note that this is not needed as due to use of an alternative constructor above // we are already set to default font // See TMessageForm::Create for contrary Form->Font->Assign(Application->DefaultFont); Form->ParentFont = true; Token.OnInitialize = OnInitialize; Token.PathInput = PathInput; TNotifyEvent OnShow; ((TMethod *)&OnShow)->Data = &Token; ((TMethod *)&OnShow)->Code = InputDialogShow; Form->OnShow = OnShow; Form->Canvas->Font = Form->Font; Form->BorderStyle = bsDialog; Form->Caption = ACaption; Form->ClientWidth = ScaleByTextHeightRunTime(Form, 275); Form->ClientHeight = ScaleByTextHeightRunTime(Form, 102); if (!HelpKeyword.IsEmpty()) { Form->HelpKeyword = HelpKeyword; Form->BorderIcons = TBorderIcons(Form->BorderIcons) << biHelp; } TLabel * Prompt = new TLabel(Form); Prompt->Parent = Form; Prompt->AutoSize = True; Prompt->Left = ScaleByTextHeightRunTime(Form, 10); Prompt->Top = ScaleByTextHeightRunTime(Form, 13); Prompt->Caption = APrompt; TEdit * Edit; THistoryComboBox * HistoryCombo; if (History == NULL) { Edit = new TEdit(Form); Edit->Parent = Form; Edit->Text = Value; Edit->SelectAll(); Edit->MaxLength = 255; Token.Data.Edit = Edit; Token.EditControl = Edit; } else { HistoryCombo = new THistoryComboBox(Form); HistoryCombo->Parent = Form; HistoryCombo->Text = Value; HistoryCombo->SelectAll(); HistoryCombo->Items = History; HistoryCombo->MaxLength = 255; HistoryCombo->AutoComplete = false; Token.EditControl = HistoryCombo; } Token.EditControl->Left = Prompt->Left; Token.EditControl->Top = ScaleByTextHeightRunTime(Form, 30); Token.EditControl->Width = ScaleByTextHeightRunTime(Form, 255); Prompt->FocusControl = Token.EditControl; int ButtonTop = ScaleByTextHeightRunTime(Form, 66); int ButtonSpace = ScaleByTextHeightRunTime(Form, 6); TButton * Button; Button = new TButton(Form); Button->Parent = Form; Button->Caption = Vcl_Consts_SMsgDlgOK; Button->ModalResult = mrOk; Button->Default = True; int ButtonHeight = ScaleByTextHeightRunTime(Button, Button->Height); int ButtonWidth = ScaleByTextHeightRunTime(Button, Button->Width); int ButtonsStart; if (HelpKeyword.IsEmpty()) { ButtonsStart = (Form->ClientWidth / 2) - ButtonWidth - (ButtonSpace / 2); } else { ButtonsStart = (Form->ClientWidth / 2) - (3 * ButtonWidth / 2) - ButtonSpace; } Button->SetBounds(ButtonsStart, ButtonTop, ButtonWidth, ButtonHeight); Button = new TButton(Form); Button->Parent = Form; Button->Caption = Vcl_Consts_SMsgDlgCancel; Button->ModalResult = mrCancel; Button->Cancel = True; Button->SetBounds(ButtonsStart + ButtonWidth + ButtonSpace, ButtonTop, ButtonWidth, ButtonHeight); if (!HelpKeyword.IsEmpty()) { Button = new TButton(Form); Button->Parent = Form; Button->Caption = Vcl_Consts_SMsgDlgHelp; Button->ModalResult = mrNone; Button->SetBounds(ButtonsStart + 2 * (ButtonWidth + ButtonSpace), ButtonTop, ButtonWidth, ButtonHeight); TNotifyEvent OnClick; ((TMethod*)&OnClick)->Code = InputDialogHelp; Button->OnClick = OnClick; } UseSystemSettingsPost(Form); if (Form->ShowModal() == DefaultResult(Form)) { if (History != NULL) { HistoryCombo->SaveToHistory(); History->Assign(HistoryCombo->Items); Value = HistoryCombo->Text; } else { Value = Edit->Text; } Result = true; } } __finally { delete Form; } return Result; }
Int32 SetAppTitleButton(TWindow * pWindow, const TUChar* pszResTxt, int ButtonPosition) { Int32 m_BtnID = 0; TRectangle BtnRC_Left(TITLE_BUTTON_X, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H); TRectangle BtnRC_Right(SCR_W-TITLE_BUTTON_X-TITLE_BUTTON_W, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H); Coord nWidth = 0; Int32 nResIDNormal = 0; Int32 nResIDOver = 0; int nFontSize = 0; //根据显示文本的长短设置图标及文字大小 switch( TUString::StrLen(pszResTxt) ) { case 2: { nWidth = TITLE_BUTTON_W; nFontSize = FONT_NORMAL; nResIDNormal = APP_KA_ID_BITMAP_button53; nResIDOver = APP_KA_ID_BITMAP_button53_over; } break; case 3: { nWidth = TITLE_BUTTON_W; nFontSize = FONT_NORMAL; nResIDNormal = APP_KA_ID_BITMAP_button53; nResIDOver = APP_KA_ID_BITMAP_button53_over; } break; case 4: { nWidth = TITLE_BUTTON_W; nFontSize = FONT_NORMAL; nResIDNormal = APP_KA_ID_BITMAP_button53; nResIDOver = APP_KA_ID_BITMAP_button53_over; } break; case 5: { nWidth = TITLE_BUTTON_W; nFontSize = FONT_MIDDLE; nResIDNormal = APP_KA_ID_BITMAP_button53; nResIDOver = APP_KA_ID_BITMAP_button53_over; } break; case 6: default: { nWidth = TITLE_BUTTON_W; nFontSize = FONT_SMALL; nResIDNormal = APP_KA_ID_BITMAP_button53; nResIDOver = APP_KA_ID_BITMAP_button53_over; } break; } TFont tFont; const TBitmap* pNormalBmp = TResource::LoadConstBitmap(nResIDNormal); const TBitmap* pOverBmp = TResource::LoadConstBitmap(nResIDOver); tFont.Create(nFontSize, nFontSize, FONT_STYLE_BOLD); TButton* pBtn = new TButton; if(pBtn->Create(pWindow)) { BtnRC_Left.SetWidth(nWidth); BtnRC_Right.SetWidth(nWidth); BtnRC_Right.SetX(SCR_W-TITLE_BUTTON_X-nWidth); if(ButtonPosition == TITLE_BUTTON_LEFT) pBtn->SetBounds(&BtnRC_Left); else pBtn->SetBounds(&BtnRC_Right); m_BtnID = pBtn->GetId(); pBtn->SetFont(tFont); pBtn->SetColor(CTL_COLOR_TYPE_FORE,RGB_COLOR_WHITE); pBtn->SetColor(CTL_COLOR_TYPE_BACK,RGB_COLOR_WHITE); pBtn->SetColor(CTL_COLOR_TYPE_FOCUS_FORE,RGB_COLOR_WHITE); pBtn->SetColor(CTL_COLOR_TYPE_FOCUS_BACK,RGB_COLOR_WHITE); pBtn->SetCaption(pszResTxt,FALSE); pBtn->SetStyles(BTN_STYLES_GRAPGICS); pBtn->SetImage(pNormalBmp,0); pBtn->SetImage(pOverBmp,1); pBtn->Show(TRUE); } return m_BtnID; }
//设置应用标题栏按钮 Int32 SetAppTitleButton(TWindow * pWindow, Int32 nResId, int ButtonPosition) { Int32 m_BtnID = 0; TButton *pBtn; TRectangle BtnRC_Left(TITLE_BUTTON_X, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H); TRectangle BtnRC_Right(SCR_W-TITLE_BUTTON_X-TITLE_BUTTON_W, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H); TFont tFont; const TBitmap * pNormalBmp = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_button53); const TBitmap * pOverBmp = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_button53_over); if(TUString::StrLen(TResource::LoadConstString(nResId)) <= 2) tFont.Create(FONT_NORMAL, FONT_NORMAL, FONT_STYLE_BOLD); else tFont.Create(FONT_MIDDLE, FONT_MIDDLE, FONT_STYLE_BOLD); pBtn = new TButton; if(pBtn->Create(pWindow)) { if(ButtonPosition == TITLE_BUTTON_LEFT) pBtn->SetBounds(&BtnRC_Left); else pBtn->SetBounds(&BtnRC_Right); m_BtnID = pBtn->GetId(); pBtn->SetFont(tFont); pBtn->SetColor(CTL_COLOR_TYPE_FORE,RGB_COLOR_WHITE); pBtn->SetColor(CTL_COLOR_TYPE_BACK,RGB_COLOR_WHITE); pBtn->SetColor(CTL_COLOR_TYPE_FOCUS_FORE,RGB_COLOR_WHITE); pBtn->SetColor(CTL_COLOR_TYPE_FOCUS_BACK,RGB_COLOR_WHITE); pBtn->SetCaption(TResource::LoadConstString(nResId),FALSE); pBtn->SetStyles(BTN_STYLES_GRAPGICS); pBtn->SetImage(pNormalBmp,0); pBtn->SetImage(pOverBmp,1); pBtn->Show(TRUE); } return m_BtnID; }