2

I want to put components at the top of the form in the border like in this screenshot.

enter image description here

I got in my project a TPageControl and i want to move it to the top in the border. How can i do this?

enter image description here

Hidden
  • 3,598
  • 4
  • 34
  • 57
  • 2
    That's actually very difficult to achieve. You don't actually put controls in that area. You would implement custom painting and event handling. And expect to have different code for different versions of Windows. Which versions would you like to support. To be quite frank, this is a topic that is probably too broad for a single question. – David Heffernan Jul 29 '13 at 08:54
  • I want to use it under windows 7 – Hidden Jul 29 '13 at 08:54
  • 1
    This has actually been asked for quite a lot of times. Usually people want to achieve something like "Chrome Tabs" or something like that. As a user, I hate this stuff. – Günther the Beautiful Jul 29 '13 at 08:58
  • I'm really interested how to do this. I would be happy for a tutorial or advanced answer. – Hidden Jul 29 '13 at 08:58
  • 1
    Is all you want to be able to put tabs in the caption bar like a modern browser? If so then this question is a dupe of [Google Chrome style tabs on glass in Delphi](http://stackoverflow.com/questions/3924720/google-chrome-style-tabs-on-glass-in-delphi) If you want something as advanced as your screenshots, and you want a detailed tutorial, then the question is probably too broad. – David Heffernan Jul 29 '13 at 09:06
  • 1
    I don't need glass effects and i dont want do create a new browser. My question is how i can place / paint componenets (in my example the tabs) in the caption bar. Like here: http://delphihaven.files.wordpress.com/2010/04/runtime.png?w=450 – Hidden Jul 29 '13 at 09:18
  • 2
    I think the best way to do this is customize the Title bar:[http://delphihaven.wordpress.com/2010/04/19/setting-up-a-custom-titlebar/](http://delphihaven.wordpress.com/2010/04/19/setting-up-a-custom-titlebar/) – AndreaBoc Jul 29 '13 at 09:41
  • 2
    @Polymorphin The PNG that you linked to comes from an article that supplies complete source code. So, just use that code. – David Heffernan Jul 29 '13 at 11:06

1 Answers1

1

It should be noted that Microsoft highly suggests against doing such a thing. That said, keep in mind that the design of a window literally counter-indicates putting any kind of "control" in the non-client area. That said, you can see pretty readily by looking at the code posted here in terms of the events. You literally have to account for your new "control" by painting it yourself and then intercepting the "special" controls via all the non-client area messages.

TTitleBtnForm = class(TForm)
   procedure FormResize(Sender: TObject);
private
   TitleButton : TRect;
   procedure DrawTitleButton;
   {Paint-related messages}
   procedure WMSetText(var Msg : TWMSetText); message WM_SETTEXT;
   procedure WMNCPaint(var Msg : TWMNCPaint); message WM_NCPAINT;
   procedure WMNCActivate(var Msg : TWMNCActivate); message WM_NCACTIVATE;
   {Mouse down-related messages}
   procedure WMNCHitTest(var Msg : TWMNCHitTest); message WM_NCHITTEST;
   procedure WMNCLButtonDown(var Msg : TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
   function GetVerInfo : DWORD;
 end;

I won't do a disservice to the person who owns the content of the site by posting the whole thing, but you'll get the idea pretty quickly that it's not wise to mess with the non-client area.

On the other hand, keep in mind that all the examples you posted are skinned windows, which means the standard window was reframed with new controls indicating what you want. In that case, you can do whatever you want, as long as you provide all the expected functionality. You start by setting the BorderStyle to bsNone and then shimming your controls out to the dimensions of your form so you don't see awkward gaps. Here's a very quick example I did. Of course, you change colors and add close/minimize/maximize buttons and whatever you like.

enter image description here

Hope that all helps.

Glenn1234
  • 2,542
  • 1
  • 16
  • 21