線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2315
推到 Plurk!
推到 Facebook!

TScrollBox::VertScrollBar 的 Range 與 Position 問題

缺席
linly
一般會員


發表:42
回覆:37
積分:15
註冊:2007-10-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-03-13 14:30:27 IP:140.113.xxx.xxx 訂閱
不知道有沒有人也遇過這樣的問題,當我去看 BCB Help 得到的說明是:

Range
represents the virtual size (in pixels) of the associated control's
client area. For example, if the Range of a form's horizontal scroll
bar is set to 500, and the width of the form is 200, the scroll bar's
Position can vary from 0 to 300.

做了以下實驗,發現 Position 最大值會多出4,也就是用以上範例的話,範圍是 [0,304],請問這是正常現象嗎?還是我哪裡搞錯了,請指正,謝謝

Unit.h
[code cpp]
class TForm1 : public TForm
{
__published: // IDE-managed Components
TScrollBox *ScrollBox1;
TLabel *Label1;

private: // User declarations
TWndMethod OldScrollBoxWndProc;
void __fastcall ScrollBoxWndProc(TMessage& Message);

public: // User declarations
__fastcall TForm1(TComponent* Owner);
};

[/code]

Unit.cpp
__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)
{
OldScrollBoxWndProc = ScrollBox1->WindowProc;
ScrollBox1->WindowProc = ScrollBoxWndProc;
ScrollBox1->VertScrollBar->Range = 500;
}

void __fastcall TForm1::ScrollBoxWndProc(TMessage& Message)
{
switch (Message.Msg)
{
case WM_VSCROLL:
{
Label1->Caption = IntToStr(ScrollBox1->VertScrollBar->ScrollPos);
}
break;
}
OldScrollBoxWndProc(Message);
}
linly
一般會員


發表:42
回覆:37
積分:15
註冊:2007-10-07

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-03-16 20:36:14 IP:218.168.xxx.xxx 訂閱
後來發現多出來的 4 是 ScrollBox 的 Border,把 border style 改成 bs_None,就好了!!!!  應該是這樣。
系統時間:2024-05-02 22:10:16
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!