Impactnetworking


Borland C ++ Builder FAQ
The content The last update: 12/12/2008

How to draw on a desktop and other windows?

The author: OlegGG

Example:
TCanvas * DeskTop = new TCanvas; 
if (DeskTop) 
        { 
        DeskTop-> Handle = GetDC (HWND_DESKTOP); 
        DeskTop-> Brush-> Style = bsClear; 
        DeskTop-> Font-> Size = 36; 
        DeskTop-> Font-> Style = TFontStyles () <<fsBold; 
        DeskTop-> Font-> Name = "Lucida Console"; 

        int count = DeskTop-> Font-> Size*3; 
        int Xit_st =-1; 
        int Yit_st =-1; 
        int X = 50; 
        int Y = 50; 
        for (int y=count; y> 0; y-) 
                { 
                int cv = 255-255/y; 
                DeskTop-> Font-> Color = (TColor) RGB (cv, cv, cv); 
                DeskTop-> TextOut (X+Xit_st*y, Y+Yit_st*y, "www.sources.ru"); 
                }
        ReleaseDC (0, DeskTop-> Handle); 
        }
delete DeskTop; 

How to make, that the form could not be moved?

The author: KAV

We catch WM_NCHITTEST and in a handler function of this message we write:
if (Message. Result == HTCAPTION) Message. Result = HTNOWHERE; 

How to drag the form not for title?

The author: OlegGG

In event OnMouseDown of the form and components with which we are going to drag, we place the code:
if (Button == mbLeft) 
        { 
        long SC_DRAGMOVE = 0xF012; 
        ReleaseCapture (); 
        SendMessage (Form1-> Handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0); 
        }

How in program runtime to drag a component as in design?

The author: KAV

In OnMouseDown that component:
ReleaseCapture (); //it is a form method 
Panel1-> Perform (WM_SYSCOMMAND, 0xF012,0); //for example, we drag Panel1 

How to restrict cursor movement by any area?

The author: OlegGG

To restrict cursor movement it is possible by means of function ClipCursor.
For example, we "clamp" the cursor in a rectangle:
RECT r; 
r.left = 10; 
r.top = 10; 
r.right = 20; 
r.bottom = 20; 
ClipCursor (&r); 
To remove restrictions on cursor movement it is possible, transferring functions NULL:
ClipCursor (NULL); 

Where to download pictures for buttons?

The author: kenai

For example, here: bitmaps.zip (8,8 Mb)