试度把那按钮的区域用相同标题栏的颜色盖住
我没试过
只试过在标题栏画按钮(BCB的),看看吧 可能有用//---------------------------------------------------------------------------#include <vcl.h>
#pragma hdrstop#include "Unit2.h"
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Trayicon"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
        WindowCanvas = new TCanvas;
        // this code determines if we are running on NT3.X
        TOSVersionInfo ver;
        ver.dwOSVersionInfoSize = sizeof(TOSVersionInfo);
        GetVersionEx( &ver);
        if(ver.dwMajorVersion < 4)
        {
                /* if the OS is NT 3.5, the custom caption won't be drawn
                 use the Caption property as usual, since the custom
                 caption won't be able to draw the string.
                */
                IsNT35 = true;
        }
        else
        IsNT35 = false ;
        Caption="9x9=81 ?";
}
//---------------------------------------------------------------------------void __fastcall TForm1::WMNCActivate(TWMNCActivate &Msg)
{
    
        Msg.Result = true;              // always handle this message;
        if ((bool)Msg.Active == false)  // if non-active draw default
        {                               //  non-active title bar                // add code here to draw caption when window is inactive.
                // in this example, we leave the inactive caption alone.                DefWindowProc( Handle, Msg.Msg, Msg.Active, 0 );
                return;
        }
        
        TMessage PaintMsg;            // if active, do same thing as WMNCPaint
        PaintMsg.Msg    = Msg.Msg;    // create a MSG to pass to WMNCPaint and
        PaintMsg.WParam = Msg.Active; // call the function directly so painting        WMNCPaint(PaintMsg);          // happens now.}
//---------------------------------------------------------------------------void __fastcall TForm1::WMNCPaint(TMessage &Msg)
{
        CaptionRect1 = new TRect;
        CaptionRect2 = new TRect;
        
        // use default processing to draw min/max/close buttons, menu, and the
        // frame. the caption bar is drawn too, but we paint over that later.        DefWindowProc(Handle, Msg.Msg,Msg.WParam,Msg.LParam);
        
        // create a DC for the entire window, then assign
        // the handle to the window canvas
        
        HDC WindowDC = GetWindowDC(Handle);
        WindowCanvas->Handle  = WindowDC;        SetRect(CaptionRect1 , this->Width-29 , 6 , this->Width-19 , 16);
        SetRect(CaptionRect2 , this->Width-41 , 6 , this->Width-30 , 16);        DrawFrameControl( WindowDC , CaptionRect1 , DFC_CAPTION , 1 );
        DrawFrameControl( WindowDC , CaptionRect2 , 0 , 1 );        ReleaseDC(Handle, WindowDC); // free resources
        WindowCanvas->Handle = NULL ;
}//--------------------------------------------------------------------------__fastcall TForm1::~TForm1(void)
{
        delete WindowCanvas;
        WindowCanvas = NULL ;
}//--------------------------------------------------------------------------void __fastcall TForm1::FormResize(TObject *Sender)
{
        Perform(WM_NCPAINT,1,0); //not write this Event will happed question!         
}//---------------------------------------------------------------------------void __fastcall TForm1::WndProc(TMessage &Msg)
{        switch ( Msg.Msg )
        {
                case WM_NCLBUTTONDOWN :
                {
                        POINT *p = new POINT;
                        GetCursorPos( p );
                        Canvas->Handle = GetWindowDC( Handle );                        if ( PtInRect ( CaptionRect1 , Point ( p->x - Left, p->y - Top )))
                        {
                                Label1->Caption=Msg.Msg;//.HitTest ;
                                //WindowState = wsMinimized;
                        }                        if ( PtInRect ( CaptionRect2 , Point ( p->x - Left, p->y - Top )))
                        {
                                PopupMenu1->Popup(p->x,p->y);
                        }
                }
                break;                case WM_NCMOUSEMOVE :
                {
                        POINT *p = new POINT;
                        GetCursorPos( p );
                        Canvas->Handle = GetWindowDC( Handle );                        if ( PtInRect ( CaptionRect1 , Point ( p->x - Left, p->y - Top )))
                        {
                                Label2->Caption=Msg.Msg+2;//.HitTest ;                        }                        if ( PtInRect ( CaptionRect2 , Point ( p->x - Left, p->y - Top )))
                        {
                                Label2->Caption=Msg.WParam+5;//.HitTest ;
                        }                }
                break;                case WM_NCLBUTTONUP :
                {
                        POINT *p = new POINT;
                        GetCursorPos( p );
                        Canvas->Handle = GetWindowDC( Handle );                        if ( PtInRect ( CaptionRect1 , Point ( p->x - Left, p->y - Top )))
                        {
                               WindowState = wsMinimized;
                        }
                }
                break;                default :                        Msg.Result=false ;
        }
        TForm::WndProc(Msg);
}//----------------------------------------------------------------+++++++++++++++++++++++++++++++++++++++++++++++++.h//---------------------------------------------------------------------------#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include "Trayicon.h"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
        TLabel *Label1;
        TLabel *Label2;
        TPopupMenu *PopupMenu1;
        TMenuItem *A1;
        TMenuItem *B1;
        TTrayIcon *TrayIcon1;
        void __fastcall FormResize(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
private: // User declarations        TCanvas *WindowCanvas;
        bool  IsNT35;
        TRect *CaptionRect1 , *CaptionRect2;
        void __fastcall WMNCPaint( TMessage &Msg );
        void __fastcall WMNCActivate( TWMNCActivate &Msg );
        //void __fastcall On_ButtonDown( TWMNCLButtonDown &Msg ) ;
        //void __fastcall On_MouseMove( TWMNCMouseMove &Msg );
        //void __fastcall OnNcHitTest(TMessage  &Message);
        void __fastcall WndProc(TMessage &Msg);public: // User declarations        BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER( WM_NCPAINT , TMessage , WMNCPaint )
        MESSAGE_HANDLER( WM_NCACTIVATE , TWMNCActivate , WMNCActivate )
        //MESSAGE_HANDLER( WM_NCLBUTTONDOWN , TWMNCLButtonDown , On_ButtonDown )
        //MESSAGE_HANDLER( WM_NCMOUSEMOVE , TWMNCMouseMove , On_MouseMove )
        //MESSAGE_HANDLER( WM_NCHITTEST , TMessage , OnNcHitTest )
        END_MESSAGE_MAP( TForm )
        __fastcall ~TForm1( void );
        __fastcall TForm1( TComponent* Owner );
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

解决方案 »

  1.   

    如果你问的是Delphi的话,我刚看了一下,好象在Form的属性里设置BoderIcons中的选项就行了
    Delphi5以下的版本应该也可以吧。我现在这里只有Delphi6.
    如果在运行的时候改变,就好象要写些代码重载窗体。
      

  2.   

    同意楼上的。在Form的属性里设置BoderIcons中的选项就行了
    。在程序中动态设定按钮只会变灰,要重载一下窗体 
      

  3.   

    把BorderStyle的属性变成bsnone就可以了.
      

  4.   

    BorderIcons := BorderIcons - [biMaximize];