开发者

Why is my TSplitter in the wrong place?

开发者 https://www.devze.com 2023-02-16 02:44 出处:网络
I\'ve got a dialog that\'s laid out something like this: ---------------------------------------------

I've got a dialog that's laid out something like this:

---------------------------------------------
|                                           |
| CONFIG AREA                               |
| Align: alTop                              |
--------------------------------------------- <-static boundary
|                                           |
| DISPLAY AREA 1                            |
| Align: alTop                              |
============================================= <-TSplitter Align: alTop
|                                           |
| DISPLAY AREA 2                 开发者_JAVA百科           |
| align: alClient                           |
--------------------------------------------- <-bottom of dialog

However, at runtime, the splitter doesn't show up between Display Area 1 and Display Area 2, but between Config Area and Display Area 1, leading to some annoying interface problems. There's nothing in the form's setup-related event handlers that alters the Visible or Align properties of any of these components. Does anyone know why the splitter isn't loading in the place it's positioned at in the form designer?


(Can't reproduce.) Splitters are tricky things. I always write code to position them. In this case, I would do

procedure Form1Show(Sender: TObject);
begin
  Splitter1.Top := DisplayArea2.Top;
end;


I have had similar problems in the past. They were cause by:

  1. controls that where made invisible.
  2. control creation order.

I think the splitter is created after config area and before display area1. If you create it after display area 1 it should be fine.


I also had the same problem in the past. TSplitter should be placed between two TPanel, like such:

+---------------------------------------------+
|+-------------------------------------------+|
||                                           ||
|| CONFIG AREA                               ||
|| Align: alTop                              ||
|+-------------------------------------------+|
||                                           ||
|| DISPLAY AREA 1                            ||
|| Align: alClient                           ||
|+-------------------------------------------+|
+---------------------------------------------+
=============================================== <-TSplitter Align: alTop
|                                             |
| DISPLAY AREA 2                              |
| align: alClient                             |
----------------------------------------------- <-bottom of dialog

Config Area and Display Area 1 should now be contained inside a TPanel with Align := alTop and either the Config Area or the Display Area 1 should be aligned to alClient.

Hope this helps

0

精彩评论

暂无评论...
验证码 换一张
取 消