Delphi Project with custom Style - delphi

I want to create a Delphi project with a custom Style, like the below image.
As you can see, the MainForm is transparent, and there are some components inside of it.
How can I create this transparent MainForm?
P.S:I want to create VCL project and i drawn this image by Photoshop.

Assuming you're using Firemonkey since you dont specify VCL or FMX.
You don't really need to create a style for this. Rather a simpler way would be to:
Set the form transparent property to True
Place a TRectangle on the form and make it align to Most left and adjust the color etc to your liking.
Place another TRectangle on your form and set the alignment to Client. You can then adjust the Opacity property for transparency, the fill property for color and then the stroke for the border.
I see a small space between the left and right in the photo. This can be done by setting a margin left value on the second TRectangle you placed.
Now this should look like you what want it to be provided you disabled the border of the form. There is 1 more thing we need to do to avoid having the controls show as transparent. We need to place a layout on the form. Not the rectangle. If you place the controls on the rectangle with opacity the controls will also be transparent. If you want the controls to have the same transparency value place it on the rectangle. Otherwise do the following:
Place a TLayout on the form. Not the rectangle.
Set the align property to Contents. This will make it overlap everything.
Set the margin left property of the layout to the width of the left rectangle you placed + the margin value of the client rectangle you placed to compensate for the little space.
Place your controls on the layout and they should show with default opacity.
One last thing to do is implement window drag. Assuming you disabled the border, your users will not be able to move the window at all since there is no border to drag. On the MouseDown event of the component you want the drag to start add the following code:
procedure TForm1.rctngl1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
StartWindowDrag;
end;
You should be all done now.
EDIT: I made an example after posting this answer: FMX Semi Transparent Form

Related

What is the difference between TScrollBar and TControlScrollBar to scroll TForm client area

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.

How resize a cxgrid with the mouse?

I have 4 cxgrid into a cxTabSheet, 3 aligned albottom and 1 aligned alClient...
When the mouse is over the edge of any cxgrid, the cursor mouse doesn´t change to the crSize(NS, WE, NESW, NWSE) and cannot select the border of grid for drag the mouse and resize it.
How can I do this?
The easiest way to do this, without writing any code, is to use one or more splitters on your form: see TSplitter and the Devex custom version, TcxSplitter, in the online help.
To use, place one or more splitters on the form orientated to allow resizing of the grid(s) as you wish, then place the grids on the appropriate areas of the splitters, or on panels on the splitters. One splitter can be placed inside another, so that you can have one resizable area inside another.

Centered, Full Screen Application

I am currently developing a fullscreen application that I want to be centered on the screen. I have set the following settings on the form:
WindowState:= wsMaximized
FormStyle:= fsStayOnTop
However due to the form height and width being much lower than the screens actual resolution, the form is aligned into the top-left corner. I have also attempted using the Position setting on the form, however none of these settings seem to have the desired outcome. They either have no effect or shift the entire maximized for towards the Bottom-Right corner, resulting in being able to see the forms behind (I hope I have described this well enough).
Thankyou
The way I understand your question is that the form, as such, maximises correctly, but the components are in top-left corner of the maximized form, according to their Left and Top properties as set in the form designer.
For example, a form as designed in the designer:
Form as it appears when maximized (and this is the problem):
If my understanding of the problem is correct, the solution is to place all components on a TPanel and then center that TPanel on the form.
There are two ways to center the TPanel
1) Clear (set to false) all anchors of the panel as in the link provided by TLama in his comment.
2) Center the panel in the forms OnResize event
procedure TForm4.FormResize(Sender: TObject);
begin
Panel1.Left := (ClientWidth - Panel1.Width) div 2;
Panel1.Top := (ClientHeight - Panel1.Height) div 2;
end;
Either way the result looks like:

TBrush bitmap alignment

I have a TPaintBox control and have assigned the TPaintBox->Canvas->Brush->Bitmap to a prepared TBitmap with a grid pattern. The TPaintBox is client aligned inside it's parent (Form).
When I manually call TPaintBox->Invalidate() to redraw the control the brush is aligned perfectly at top,left (0,0 - left picture), but as soon I resize the window, the brush offset change to (20,7 - right picture) until I manually call TPaintBox->Invalidate() again.
I have tried to use one of the standard brush patterns such as bsBDiagonal and bsCross, but they all behave the same (different alignment between an Invalidate() call and form resize).
I tried to use the Win32 API SetBrushOrgEx() to manually set the brush alignment, but it has no effect on a window resize update. It does work perfectly well if I manually call Invalidate().
If I set a breakpoint in my onPaint handler and check what the brush origo is, it always answer (0,0) even when it is misaligned.
I use Canvas->RectFill() to fill the background.
Canvas->Brush->Style = bsBDiagonal;
Canvas->FillRect(Client);
Any ideas?

How can I change window border size?

I removed caption bar of my window so now it only has a border around it. I don't want to set BorderStyle to bsNone but I want to remove border. How can I do it?
let me explain more. I want to make sth like Photoshop GUI. If I set border style to bsNone, I'll lose lots of features on win7. I tried to use GraphicControls instead of Form Caption bar to move the window (by handling WMNCHitTest message). It works but double click doesn't maximize and restore the window when border style is bsNone but everything works well when it is bsResizable. I want to set BorderStyle to bsResizable but I want to remove the border like when it is bsNone
You can set the form's border to bsNone and then add a panel to the form. Set the panel's align property to alClient and adjust its border however you like. You have control over the inner and outer bevels and their widths to a 1 pixel granularity. Since Panel1 is a container, it should be easy to just drag everything onto it as though it were the form itself. In the designer, it would be nearly invisible.
If you are not familiar with it, you can drag all the controls from one container to another using the structure view (it's called the object treeview in older versions). This makes it so you don't have to redesign your form to do this. If the panel itself is a problem, you can always just send it to the back and leave all the other controls on the form. It will look exactly the same, but then the controls maintain a TForm parent instead of a TPanel parent. It's just a little extra thing to maintain in the designer.
Having said that, I also recommend considering Mason's comment about nonstandard UIs.
Setting the borderstyle to "bsSizeToolWin" isn't an option? It would be a thinner border, but it would be resizeable and it's still conform the Windows standard...
I haven't seen latest Photoshop, but I guess you need something like that: http://delphihaven.wordpress.com/2010/04/22/setting-up-a-custom-title-bar-reprise/

Resources