I have created a component that has a paint override on the canvas and i would like to set a limit on minimum width and height. The scrollbar should appear at the side when the Width Or Height is less then the limit just like a scrollbox and can be scroll also.
i choose TCustomControl cause i paint and less flicker when double buffered.
any idea or better solution?
TScrollBox and TCustomControl both descend from TWinControl. TScrollBox and TScrollingWinControl add scroll bars, whereas TCustomControl adds a canvas. To get what you want, you can either add a canvas to a TScrollingWinControl, or you can add scroll bars to a TCustomControl.
Compare the definitions of the two classes (in Forms.pas and Controls.pas, respectively), and it should be clear which one's features will be easier to duplicate in your descendant. TCustomControl adds three simple methods, implemented in about 40 lines of code. Write a TScrollingWinControl descendant and copy the methods and properties from TCustomControl into it.
Related
I have an application made with frames.
I have a panel on the frame that I need to work out how to float and dock.
I'm not sure how to accomplish this.
I looked at devexpress docking controls, but they only work with forms.
So I think I need to work out 2 issues.
how to make the panel movable and resizable.
how to add docking logic to a frame?
any help will be appreciated.
1) TPanel movable and resizable
A Panel is always movable inside its container (Form, frame, another panel, scrollbox,...) and resizable. You just have to change its Top, Left, width and height properties. To make it dragable, you need to use MouseDown, MouseMove, MouseUp event, detect and handle the required mouse use to drag.
You can even move the TPanel from its container to another container by changing its Parent property. For example, you can move a panel from a TForm to another TForm. That's what you'll use for making your panel floating.
2) Floating TFrame
You cannot use a TFrame as a floating form. You need a TForm for that.
Note that you can use a TForm much like a TFrame. Use CreateParented to create the form and attach it to a container like a TFrame.
I am using Delphi 2009 and I have set (of variable length) of records with the data <image, label, file path> and I would like to present those records in gallery-like structurei with the horizontal scroll of the entire list and, possibly, with no vertical scroll.
TDBCtrlGrid seems to be exact solution (I can keep records in the TClientDataSet and there is lot of automation in place), but is vertical-only collection (at least for Delphi 2009), it has Orientation property but (at least in design time) it controls the scrollbar only (places it in the bottom). So - maybe it is still possible to adapt TDBCtrlGrid for horizontal use?
TScrollBox (with TFrame child elements) is another promising solution, but so far I can achieve that all the frames are stacked vertically and I don't see how can I ask them to be side-be-side horizontally. So - is there way to use TScrollBox for horizonatl, gallery like structure?
I have reserved the option to use TcxDBVerticalGrid, but I am doing everything to avoid it - I am not sure about the capabilities of the complex grid to present images with its own image internal component, I prefer to use TImage or TDBImage component (seems to be robust) inside some container of controles (e.g. on TFrame and put those frames in TScrollBox).
Assuming the question is something like "How can I make TDBCtrlGrid work in horizontal mode?"
In addition to setting the orientation, you should also set RowCount and ColCount to some decent values.
I want to draw small bitmaps hold in a list on a TForm with Canvas but beyond the limit of the size of the TForm and use Vertical and Horizontal Scrollers to navigate and allow the user to display the entire area.
I noticed that there are HorzScrollBar and VertScrollBar TControlScrollBar in the TForm, but impossible to get them visible or usable, even if they are checked as Visible.
I suppose that they are concerned only with components of the TForm, if we resize the TForm, they should appear.
Do I have to use external TScrollBar (Vertical and Horizontal ones) to achieve the scrolling (by program) of the client area of the TForm or is there a way of using the HorzScrollBar and VertScrollBar TControlScrollBar?
To automatically show the scrollbars when needed (controls outside of the visible area) set AutoScroll := true;.
But that requires that you use controls to draw your images. If you want to show the scrollbars even if you only draw (paint) directly on the form canvas, you can do so by setting the Range property to the actual extent of your drawn area.
E.g.
procedure TForm24.FormCreate(Sender: TObject);
begin
self.HorzScrollBar.Range := 1000;
end;
So, to answer your question, you can use the built-in scrollbars.
I have a problem with a TForm who contain a TMemo. If Autosize is set to True on the TForm, my TForm is halved and then I can size it ...
That's exactly this problem : https://www.youtube.com/watch?v=3eG3kwRgPTo
I'm with Delphi 10.1 Berlin, all is ok with my Delphi XE6.
Did you know how I can fix it ?
Thanks
You have a kind of circular reference in that the child windows are resizing themselves to the parent and the parent resizing itself to the children, and none of them specifying a width. I agree it is odd that adding a TMemo seems to screw things up but like any circular reference it needs to be broken, so either you need to resize the screen programmatically or, as would probably be better in your case, simply size the panels and don't use the align properties of those. I have tried that approach and it works.
Of course this only allows the top or bottom panel to be made invisible - not those in the middle.
I need a string grid which can scroll smoothly, as opposed to locking in the top row / left col positions. When you scroll a TStringGrid, the left visible column and top visible row snap into position along the top/left edges. I need the ability for the user to scroll smoothly, not locking these edges into place.
I wouldn't think this is possible to modify in the VCL TStringGrid (or TCustomGrid for that matter) because it relies on properties such as TopRow, LeftCol, VisibleRowCount, etc.. I'm pretty sure I'll need a third party control, but I'd love to use the TStringGrid if possible, because I already have a lot of code wrapped around it. If I do need a third-party grid, then I'm hoping it works closely enough like the TStringGrid.
The short answer is no, you canĀ“t pixel scroll a TStringGrid. You can simulate a grid using a TScrollBox. You can put a grid inside the TScrollBox, make the grid large enough to fit all rows and cols, and turn off its scroll bars, but some things like keyboard navigation will not work.
Other alternative is to use the TVirtualTree in grid mode or TListView. Both have this pixel scroll you want.
I was looking for something similar. Unfortunately, you can't do it with Borland's code but Lazarus can do it
Scrolling the TStringGrid pixel by pixel
You may want to take a look in their code.