Mega Code Archive

 
Categories / Delphi / Forms
 

Custom Caption Bar

Title: Custom Caption Bar Question: How can I create a form with my own caption bar and replace the 'normal' caption bar with a custom one? (Bitmap)? ======= Answer: Here you will find a really easy way to personalize your application and let it look 'different' from the normal windows applications. First let your form hide the 'common' captionbar. procedure TForm1.FormCreate(Sender: TObject); begin SetWindowLong(Form1.Handle, GWL_STYLE, GetWindowLong(form1.handle,GWL_STYLE) and not WS_CAPTION); form1.height := clientheight; end; =========================== Put an image (created with Paint Shop Pro or an other picture design program) on your form and set the alignment to altop. //Then on imagemousedown do this = after this you can move your form if you click on the image: procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin releasecapture; perform(WM_SYSCOMMAND, SC_MOVE + 1, 0); end; =========================== To create the same options on your customized captionbar as on a 'common one' you can place some custom buttons (images on the right side of your image1 (create them in a picture design program). In order to keep them aligned with your form on resizing do this: procedure TForm1.FormResize(Sender: TObject); begin image2.Left := form1.Width - 25; // keeps the original distance end; ============================ Like the example above you can create more buttons with the systemcommands like 1) maximize 2) minimize 3) close and more. Check these screenshots to see some examples: Custom captionbar Or don't use a captionbar :) Panel aligned to alltop to set a custom caption bar here. Another example: