2015-02-04 1 views
2

에 사용자 정의 버튼 상대적 나는 그 어떤 페이지는 다음 코드를 사용하여 절대 값을 사용하여 위치에 사용자 정의 버튼을 만들 수 있습니다 알고 :이노 설치 위치 기존의 버튼

//Create the About button 
    AboutButton := TButton.Create(WizardForm); 
    AboutButton.Caption := '&About'; 
    AboutButton.Width := ScaleX(75); 
    AboutButton.Height := ScaleY(23); 
    AboutButton.Left := WizardForm.InfoAfterPage.Left + 10; 
    AboutButton.Top := WizardForm.InfoAfterPage.Height + 90; 
    AboutButton.OnClick := @AboutButtonClick; 
    AboutButton.Parent := WizardForm.NextButton.Parent; 

이 유일한 문제를 사용자가 위치 조정을 위해 절대 값을 사용하기 때문에 화면 해상도> 텍스트 및 기타 항목 만들기를 선택하고 크기 조정을 보통 125 %로 설정하면 사용자가 Windows 배율을 켰을 때 버튼이 다른 내장 버튼을 사용하면 혼란 스럽습니다. 따라서 새로 만든 사용자 지정 단추를 기본 제공 단추와 관련하여 배치하여 항상 인라인으로 표시하고 의도 한대로 표시 할 수 있습니까? 아니면 내가 바라 보는이 스케일링 딜레마에 대한 다른 해결책이 있습니까? 모든 위치/크기에

+0

? NEXT와 CANCEL이 같은 지역에 있습니까? – RobeN

+0

예, 다음 및 취소 버튼과 일치합니다. 창의 왼쪽에서 취소 버튼과 같은 공백은 창의 오른쪽에서옵니다. –

답변

3

이 내가 그것을 쓰는 것이 방법입니다

AboutButton := TButton.Create(WizardForm); 
    AboutButton.Caption := '&About'; 
    AboutButton.Left := WizardForm.InfoAfterPage.Left + (WizardForm.ClientWidth - 
    (WizardForm.CancelButton.Left + WizardForm.CancelButton.Width)); 
    // sets Left position from the Page Left 
    // + already scaled gap calculated on the basis of TLama's recommendations 
    AboutButton.Width := WizardForm.NextButton.Width; 
    // sets same Width as NextButton 
    AboutButton.Top := WizardForm.NextButton.Top;  
    // sets same Top position as NextButton 
    AboutButton.Height := WizardForm.NextButton.Height; 
    // sets same Height as NextButton 
    AboutButton.OnClick := @AboutButtonClick; 
    AboutButton.Parent := WizardForm.NextButton.Parent; 

예 :

96 (Default) 버튼을 배치 할 않는

120 (125%)

144 (150%)

+0

똑똑! 그건 완벽하게 작동합니다. 매우 감사합니다. –

+2

크기 조정을 방지하려면 오른쪽 취소 단추 가장자리와 양식의 오른쪽 클라이언트 가장자리 사이의 너비를 가져옵니다. 그것은 이미 마 법적 가치 10보다 규모가 크고 정밀합니다. ['여기 있습니다.] (http://i.imgur.com/Rfw6CM8.png). – TLama

+1

감사합니다. @TLama. 그래서 Back과 Cancel 버튼 사이와 Back과 Next 버튼 사이의 거리를 계산할 수있게되었습니다. –

0

사용 scaleX가()scaleY를() :

AboutButton.Width := ScaleX(75); 
    AboutButton.Height := ScaleY(23); 
    AboutButton.Left := ScaleX(WizardForm.InfoAfterPage.Left + 10); 
    AboutButton.Top := ScaleY(WizardForm.InfoAfterPage.Height + 90); 

이 모든 DPIs에서 제대로 작동합니다.

+0

불행히도 그것은 작동하지 않고 마법사 페이지에서 버튼이 완전히 사라집니다. 그것이 범위를 벗어나거나 무언가 때문이라고 생각합니다. –