Because this software is music software, need a lot of drawing, the existing DC-based API and BCB canvas can not complete the requirements (slow, draw a particular pattern difficult), in order to save time, derived from the existing T
Wincontrol Visual window control, the combination of specific drawing classes, Form a new class, the pattern is drawn in the visual area, the overloaded control of the mouse and keyboard event processing, the formation of standard control, which all implemented the
, but the result has failed, because after the drawing is completed, the system refreshes the control, the result is sad, change the size of the form to brush the next one, Visual window control This action is normal, the problem is that the system does not recognize my
self-drawing. Solve the problem is the system brush after painting, then intercepted wm_size message, the result is sad, in response to Wm_size message, since the drawing class crashes, because the control wm_size set up before the
drawing class, since the drawing class has not been established, the call members will inevitably crash. The workaround is to set a flag that, after the control is established, responds to the self-drawing of the wm_size message, and the result is changed and not refreshed because the system creates the
Visual window component only once wm_size. Since wm_size is not continuous, then a wm_paint "window redraw" message, the result again sad, is able to self-drawing, but other messages no longer respond. The
finds WM_PAINT quickly and violently refreshed by counting, causing other messages to be too late to reflect. According to the WM_PAINT definition, this is not the case, so the derivation is rolled up one level to Tcontrol, and the result is pulled normally. After a
wave 30 percent toss, the more complex full custom visual controls are avoided. The idea of a review of the problem is this: in order to save time, inherit from existing visual controls, customize the drawing above, customize the
drawing is self-made, memory-level drawing, middle-level less, so faster, and the pattern built-in. Controls are used to do primitives in response to various events. There was a problem inheriting the derived control, and the relationship between Twincontrol and
Tcontrol is that Tcontrol is the ancestor of all visual controls, Twincontrol derives from Tcontrol, joins the handle, and becomes the ancestor of the visual window control. Tcontrol is the most primitive visual control, with
the earliest incoming related messages, such as Wm_size,wm_paint, similar to the system definition. At this point, you have a fast and efficient control that can be drawn arbitrarily, although it does not have window capability, but the main purpose of plotting is not to ask the
question. For convenience, later called this control as "entity", is the most basic unit of each graphics operation. An interface has a lot of graphic composition, they have a reflection mechanism, mutual response to each other, the end of the
into human-computer interaction.
Tcontrol control: As the ancestor class of visual control, added Top,left,width,height and other related "dimension" concept and Reflect "visual" wm_size,wm_paint message ability, for descendants derive inheritance,
As long as they "draw themselves" out of the line. Some visual controls, "Draw your own" work can be handed out, called "self-painting", but must be the system's own drawing function. Many good-looking interfaces are "self-drawing" knots.
Fruit. Tcontrol There is no "appearance", in order to future generations have a variety of "appearance." Tcontrol has no "looks", but has the most basic ability to support "looks".
Twincontrol control: Derived from Tcontrol, with all the capabilities of the Tcontrol, mainly joined the relevant Windows "handle" concept, once the "handle" can be linked to the "window", that is, there is "
Window "Capabilities," windows "and" handles "are important concepts in Windows programming, and owning a window handle can do almost anything to manipulate a window. Twincontrol is the Windows window that contains
A handle to the visual control ancestor class.
Here is the control class, also called a rectangular entity (just solved the problem, just about)
Class Trectang:public Tcontrol
{
Public
The bool benable,//control allows
The bvisible,//control display allows
bvisibleframe,//Display Border Lines
bvisibletext,//display text
brightborderenable,//right Border move allow
bmousemoveinchangeenable;//Mouse Move in changes
DWORD dwfillcolor,//Control (fill) color
dwlinecolor,//color of the frame line
dwtextcolor,//text color
dwhotfillcolor,//hotspot Control (fill) color
dwhotlinecolor,//Hot Spot Frame line Color
dwhottextcolor;//Hot Text color
int ifontsize,//Font Size
ialignment;//Text Alignment Flags
String stext;//text inside Rectangle
__fastcall virtual Trectang (tcomponent* aowner);
void __fastcall Connect (Twincontrol *pparent);//Initial Association
void __fastcall adjresize (int ileft, int iTop, int iwidth, int iheight);//Rectangle control Resizing
Protected
DYNAMIC void __fastcall MouseDown (Tmousebutton Button, classes::tshiftstate Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp (Tmousebutton Button, classes::tshiftstate Shift, int X, int Y);
DYNAMIC void __fastcall MouseMove (classes::tshiftstate Shift, int X, int Y);
DYNAMIC void __fastcall Click (void);
DYNAMIC void __fastcall DblClick (void);
Private
Tdraw draw;//Drawing
int imousexpos,//mouse x position
imouseypos;//Mouse y position
void __fastcall selfdraw (void);//self-painting
void __fastcall OnMouseLeave (tmessage &msg);//mouse leave processing
void __fastcall OnPaint (tmessage &msg);
Begin_message_map
Message_handler (Cm_mouseleave, Tmessage, onmouseleave);//Mouse off hook
Message_handler (WM_PAINT, Tmessage, OnPaint);//Window Redraw hook
End_message_map (Tcontrol)
};
Customizing visual controls