WinSubClass.pas
上传用户:xjwsee
上传日期:2008-08-02
资源大小:796k
文件大小:278k
- r1:=rc;
- offsetrect(r1,-r1.left,-r1.top);
- try
- if (r1.Right>0) and (r1.Bottom>0) then begin
- btemp.width:=r1.right;
- btemp.height:=r1.bottom;
- end else begin
- fReentr := False;
- exit;
- end;
- except
- fReentr := False;
- exit;
- end;
- if font<>nil then btemp.canvas.font.assign(font);
- if trans then
- DrawParentImage(gcontrol,btemp.canvas.handle,true)
- else
- fillBG(btemp.canvas.handle,r1);
- { if not (xoTransparent in fsd.options) then begin
- fillBG(btemp.canvas.handle,r1);
- end
- else if gcontrol<>nil then
- DrawParentImage(gcontrol,btemp.canvas.handle,true);}
- // if flat , don't paint background image.
- if (i in [2,4]) or (not Flat) then
- DrawSkinMap( btemp.canvas.handle,r1,fsd.button,I,fsd.button.frame);
- ClientSize := Point(r1.right,r1.bottom);
- if (bGlyph <> nil) and (not bGlyph.empty) then
- GlyphSize := Point(bGlyph.Width div NumGlyphs, bglyph.Height)
- else begin
- GlyphSize := Point(0, 0);
- end;
- TextBounds := r1;
- inflaterect(TextBounds,-2,-2);
- case Layout of
- blGlyphLeft,blGlyphRight: Dec(TextBounds.Right,GlyphSize.X+2);
- blGlyphTop,blGlyphBottom: Dec(TextBounds.Bottom,GlyphSize.y+2)
- end;
- if Length(Caption) > 0 then begin
- //offsetrect(TextBounds,-TextBounds.Left,-TextBounds.Top);
- //TextBounds := Rect(0, 0, clientsize.x,clientsize.y);
- Tnt_DrawTextW(btemp.canvas.handle,Caption, TextBounds, DT_CALCRECT or dt_left or dt_WordBreak);
- TextSize := Point(TextBounds.Right - TextBounds.Left, TextBounds.Bottom -
- TextBounds.Top);
- end else begin
- TextBounds := Rect(0, 0, 0, 0);
- TextSize := Point(0,0);
- end;
- if GlyphSize.X*GlyphSize.y=0 then begin
- // if (i=1) and (fsd.button.newnormal) then
- if (fsd.button.newnormal) then
- btemp.canvas.Font.Color:= fsd.button.normalcolor2;
- if (i=4) and (fsd.button.newover) then
- btemp.canvas.Font.Color:= fsd.button.overcolor2;
- if (i=2) and (fsd.Button.newdown) then
- btemp.canvas.Font.Color:= fsd.button.downcolor2;
- if not enable then btemp.canvas.Font.Color := clBtnShadow;
- DrawBtnText(btemp.canvas,r1,caption);
- aCanvas.draw(rc.left,rc.top,btemp);
- fReentr := False;
- // acanvas.Unlock();
- exit;
- end;
- if Layout in [blGlyphLeft, blGlyphRight] then begin
- GlyphPos.Y := (ClientSize.y - GlyphSize.Y + 1) div 2;
- TextPos.Y := (ClientSize.y - TextSize.Y + 1) div 2;
- end else begin
- GlyphPos.X := (ClientSize.x - GlyphSize.X + 1) div 2;
- TextPos.X := (ClientSize.x - TextSize.X + 1) div 2;
- end;
- { if there is no text or no bitmap, then Spacing is irrelevant }
- if (GlyphSize.X = 0) or (TextSize.X = 0) then
- Spacing := 0;
- { adjust Margin and Spacing }
- if Margin = -1 then begin
- if Spacing = -1 then begin
- TotalSize := Point(GlyphSize.X + TextSize.X, GlyphSize.Y + TextSize.Y);
- if Layout in [blGlyphLeft, blGlyphRight] then
- Margin := (ClientSize.x - TotalSize.X) div 3
- else
- Margin := (ClientSize.y - TotalSize.Y) div 3;
- Spacing := Margin;
- end else begin
- TotalSize := Point(GlyphSize.X + Spacing + TextSize.X, GlyphSize.Y +
- Spacing + TextSize.Y);
- if Layout in [blGlyphLeft, blGlyphRight] then
- Margin := (r1.right - TotalSize.X ) div 2+1
- else
- Margin := (ClientSize.y - TotalSize.Y ) div 2+1;
- end;
- end else begin
- if Spacing = -1 then begin
- TotalSize := Point(ClientSize.x - (Margin + GlyphSize.X), ClientSize.y -
- (Margin + GlyphSize.Y));
- if Layout in [blGlyphLeft, blGlyphRight] then
- Spacing := (TotalSize.X - TextSize.X) div 2
- else
- Spacing := (TotalSize.Y - TextSize.Y) div 2;
- end;
- end;
- case Layout of
- blGlyphLeft:
- begin
- GlyphPos.X := Margin;
- TextPos.X := GlyphPos.X + GlyphSize.X + Spacing;
- DrawStyle:=DT_left or dt_WordBreak;
- end;
- blGlyphRight:
- begin
- GlyphPos.X := ClientSize.x - Margin - GlyphSize.X;
- TextPos.X := GlyphPos.X - Spacing - TextSize.X;
- DrawStyle:=DT_RIGHT or dt_WordBreak;
- end;
- blGlyphTop:
- begin
- GlyphPos.Y := Margin;
- TextPos.Y := GlyphPos.Y + GlyphSize.Y + Spacing;
- DrawStyle:=DT_center or dt_WordBreak;
- end;
- blGlyphBottom:
- begin
- GlyphPos.Y := ClientSize.y - Margin - GlyphSize.Y;
- TextPos.Y := GlyphPos.Y - Spacing - TextSize.Y;
- DrawStyle:=DT_center or dt_WordBreak;
- end;
- end;
- r1:=rect(glyphpos.x,glyphpos.y,0,0);
- DrawGlyph(btemp.canvas,r1,bglyph,j,NumGlyphs);
- TextBounds:= rect(textpos.x,textpos.y,textpos.x+TextSize.x,textpos.y+TextSize.y);
- SetBkMode(btemp.Canvas.Handle, TRANSPARENT);
- if (i=1) and (fsd.button.newnormal) then
- btemp.canvas.Font.Color:= fsd.button.normalcolor2;
- if (i=4) and (fsd.button.newover) then
- btemp.canvas.Font.Color:= fsd.button.overcolor2;
- if (i=2) and (fsd.Button.newdown) then
- btemp.canvas.Font.Color:= fsd.button.downcolor2;
- if not enable then
- btemp.canvas.Font.Color := clBtnShadow;
- // DrawText(bg.canvas.Handle, PChar(btn.caption),Length(btn.caption),TextBounds,DrawStyle);
- // acanvas.draw(rc.left,rc.top,BG);
- drawstyle := CheckBiDi(drawstyle);
- Tnt_DrawTextW(btemp.canvas.Handle,caption,TextBounds,DrawStyle);
- aCanvas.draw(rc.left,rc.top,btemp);
- finally
- fReentr := False;
- // acanvas.Unlock();
- end;
- end;
- procedure TSkinSpeedButton.DrawPicbtn( acanvas:Tcanvas; rc:TRect);
- var acolor:Tcolor;
- i,n,j:integer;
- r1,TextBounds:Trect;
- TextPos: TPoint;
- GlyphPos, ClientSize, GlyphSize, TextSize: TPoint;
- TotalSize: TPoint;
- DrawStyle: Longint;
- Layout: TButtonLayout;
- NumGlyphs,margin,spacing :integer;
- GlyphObj : TObject ;
- bGlyph : TGraphic;
- s:string;
- font:Tfont;
- flat:boolean;
- enable:boolean;
- begin
- if fsd.button=nil then exit;
- if fsd.Button.map.empty then exit;
- // RF: flag for reentrancy
- if fReentr then Exit;
- fReentr := True;
- // acanvas.Lock;
- try
- DrawStyle:=DT_LEFT or dt_WordBreak;
- i:=1;
- if (scDown in state) then i:=2
- else if (scMouseIn in state) then i:=4;
- s:=lowercase(GetEnumProperty(gcontrol,'Enabled'));
- if s='true' then enable:=true
- else enable:=false;
- if not enable then i:=3;
- s:=lowercase(GetEnumProperty(gcontrol,'Down'));
- if s='true' then i:=2 ;
- j:=1;
- case i of
- 1: j:=1;
- 2: j:=3;
- 3: j:=2;
- 4: j:=1;
- end;
- if s='true' then j:=4 ;
- GlyphObj := TObject(GetObjectProp(gcontrol,PicField,TObject));
- if (GlyphObj<>nil) then begin
- bGlyph := TGraphic(GetObjectProp(gcontrol,PicField,TGraphic));
- end else bGlyph:=nil;
- caption := GetStringProp(gcontrol,'Caption');
- font := Tfont(GetObjProp(gcontrol,'Font',Tfont));
- // bglyph := Tbitmap(GetObjProp(gcontrol,'Glyph',Tbitmap));
- NumGlyphs := GetIntProperty(gcontrol,'NumGlyphs') ;
- if NumGlyphs<0 then NumGlyphs:=1;
- // bglist := Timagelist(GetObjProp(gcontrol,'Images',Timagelist));
- // imageindex := GetIntProperty(gcontrol,'ImageIndex') ;
- // disabledindex := GetIntProperty(gcontrol,'DisabledIndex') ;
- s:=lowercase(GetEnumProperty(gcontrol,'Flat'));
- if s='true' then flat:=true
- else flat:=false;
- Margin := GetIntProperty(gcontrol,'Margin') ;
- Spacing := GetIntProperty(gcontrol,'Spacing') ;
- s := lowercase(GetEnumProperty(gcontrol,'Layout'));
- if s='blglyphleft' then layout:=blGlyphLeft
- else if s='blglyphright' then layout:=blGlyphRight
- else if s='blglyphtop' then layout:=blGlyphTop
- else if s='blglyphbottom' then layout:=blGlyphbottom;
- r1:=rc;
- offsetrect(r1,-r1.left,-r1.top);
- try
- if (r1.Right>0) and (r1.Bottom>0) then begin
- btemp.width:=r1.right;
- btemp.height:=r1.bottom;
- end else begin
- fReentr := False;
- exit;
- end;
- except
- fReentr := False;
- exit;
- end;
- if font<>nil then btemp.canvas.font.assign(font);
- if trans then
- DrawParentImage(gcontrol,btemp.canvas.handle,true)
- else
- fillBG(btemp.canvas.handle,r1);
- { if not (xoTransparent in fsd.options) then begin
- fillBG(btemp.canvas.handle,r1);
- end
- else if gcontrol<>nil then
- DrawParentImage(gcontrol,btemp.canvas.handle,true);}
- // if flat , don't paint background image.
- if (i in [2,4]) or (not Flat) then
- DrawSkinMap( btemp.canvas.handle,r1,fsd.button,I,fsd.button.frame);
- ClientSize := Point(r1.right,r1.bottom);
- if (bGlyph <> nil) and (not bGlyph.empty) then
- GlyphSize := Point(bGlyph.Width div NumGlyphs, bglyph.Height)
- else begin
- GlyphSize := Point(0, 0);
- end;
- TextBounds := r1;
- inflaterect(TextBounds,-2,-2);
- case Layout of
- blGlyphLeft,blGlyphRight: Dec(TextBounds.Right,GlyphSize.X+2);
- blGlyphTop,blGlyphBottom: Dec(TextBounds.Bottom,GlyphSize.y+2)
- end;
- if Length(Caption) > 0 then begin
- //offsetrect(TextBounds,-TextBounds.Left,-TextBounds.Top);
- //TextBounds := Rect(0, 0, clientsize.x,clientsize.y);
- Tnt_DrawTextW(btemp.canvas.handle,Caption, TextBounds, DT_CALCRECT or dt_left or dt_WordBreak);
- TextSize := Point(TextBounds.Right - TextBounds.Left, TextBounds.Bottom -
- TextBounds.Top);
- end else begin
- TextBounds := Rect(0, 0, 0, 0);
- TextSize := Point(0,0);
- end;
- if GlyphSize.X*GlyphSize.y=0 then begin
- if (i=1) and (fsd.button.newnormal) then
- btemp.canvas.Font.Color:= fsd.button.normalcolor2;
- if (i=4) and (fsd.button.newover) then
- btemp.canvas.Font.Color:= fsd.button.overcolor2;
- if (i=2) and (fsd.Button.newdown) then
- btemp.canvas.Font.Color:= fsd.button.downcolor2;
- if not enable then btemp.canvas.Font.Color := clBtnShadow;
- DrawBtnText(btemp.canvas,r1,caption);
- aCanvas.draw(rc.left,rc.top,btemp);
- fReentr := False;
- // acanvas.Unlock();
- exit;
- end;
- if Layout in [blGlyphLeft, blGlyphRight] then begin
- GlyphPos.Y := (ClientSize.y - GlyphSize.Y + 1) div 2;
- TextPos.Y := (ClientSize.y - TextSize.Y + 1) div 2;
- end else begin
- GlyphPos.X := (ClientSize.x - GlyphSize.X + 1) div 2;
- TextPos.X := (ClientSize.x - TextSize.X + 1) div 2;
- end;
- { if there is no text or no bitmap, then Spacing is irrelevant }
- if (GlyphSize.X = 0) or (TextSize.X = 0) then
- Spacing := 0;
- { adjust Margin and Spacing }
- if Margin = -1 then begin
- if Spacing = -1 then begin
- TotalSize := Point(GlyphSize.X + TextSize.X, GlyphSize.Y + TextSize.Y);
- if Layout in [blGlyphLeft, blGlyphRight] then
- Margin := (ClientSize.x - TotalSize.X) div 3
- else
- Margin := (ClientSize.y - TotalSize.Y) div 3;
- Spacing := Margin;
- end else begin
- TotalSize := Point(GlyphSize.X + Spacing + TextSize.X, GlyphSize.Y +
- Spacing + TextSize.Y);
- if Layout in [blGlyphLeft, blGlyphRight] then
- Margin := (r1.right - TotalSize.X ) div 2+1
- else
- Margin := (ClientSize.y - TotalSize.Y ) div 2+1;
- end;
- end else begin
- if Spacing = -1 then begin
- TotalSize := Point(ClientSize.x - (Margin + GlyphSize.X), ClientSize.y -
- (Margin + GlyphSize.Y));
- if Layout in [blGlyphLeft, blGlyphRight] then
- Spacing := (TotalSize.X - TextSize.X) div 2
- else
- Spacing := (TotalSize.Y - TextSize.Y) div 2;
- end;
- end;
- case Layout of
- blGlyphLeft:
- begin
- GlyphPos.X := Margin;
- TextPos.X := GlyphPos.X + GlyphSize.X + Spacing;
- DrawStyle:=DT_left or dt_WordBreak;
- end;
- blGlyphRight:
- begin
- GlyphPos.X := ClientSize.x - Margin - GlyphSize.X;
- TextPos.X := GlyphPos.X - Spacing - TextSize.X;
- DrawStyle:=DT_RIGHT or dt_WordBreak;
- end;
- blGlyphTop:
- begin
- GlyphPos.Y := Margin;
- TextPos.Y := GlyphPos.Y + GlyphSize.Y + Spacing;
- DrawStyle:=DT_center or dt_WordBreak;
- end;
- blGlyphBottom:
- begin
- GlyphPos.Y := ClientSize.y - Margin - GlyphSize.Y;
- TextPos.Y := GlyphPos.Y - Spacing - TextSize.Y;
- DrawStyle:=DT_center or dt_WordBreak;
- end;
- end;
- r1:=rect(glyphpos.x,glyphpos.y,0,0);
- // DrawGlyph(btemp.canvas,r1,bglyph,j,NumGlyphs);
- if (bglyph<>nil) {and Assigned(bglyph.Graphic)} then
- btemp.Canvas.Draw(r1.left ,r1.top,bglyph);
- TextBounds:= rect(textpos.x,textpos.y,textpos.x+TextSize.x,textpos.y+TextSize.y);
- SetBkMode(btemp.Canvas.Handle, TRANSPARENT);
- if (i=1) and (fsd.button.newnormal) then
- btemp.canvas.Font.Color:= fsd.button.normalcolor2;
- if (i=4) and (fsd.button.newover) then
- btemp.canvas.Font.Color:= fsd.button.overcolor2;
- if (i=2) and (fsd.Button.newdown) then
- btemp.canvas.Font.Color:= fsd.button.downcolor2;
- if not enable then
- btemp.canvas.Font.Color := clBtnShadow;
- // DrawText(bg.canvas.Handle, PChar(btn.caption),Length(btn.caption),TextBounds,DrawStyle);
- // acanvas.draw(rc.left,rc.top,BG);
- drawstyle := CheckBiDi(drawstyle);
- Tnt_DrawTextW(btemp.canvas.Handle,caption,TextBounds,DrawStyle);
- aCanvas.draw(rc.left,rc.top,btemp);
- finally
- fReentr := False;
- // acanvas.Unlock();
- end;
- end;
- procedure TSkinControl.DrawCaption(acanvas: TCanvas; rc:TRect;
- text:widestring; enabled,defaulted:boolean;Alignment:word=DT_CENTER);
- const
- Alignments: array[TAlignment] of Word = (DT_LEFT,DT_RIGHT,DT_CENTER );
- var
- r1: TRect;
- DrawStyle: Longint;
- begin
- DrawStyle := DT_EXPANDTABS or Alignment;
- r1 := rc;
- SetBkMode(aCanvas.Handle, TRANSPARENT);
- with ACanvas do begin
- Brush.Style := bsClear;
- font.style:=[];
- // Calculate vertical layout
- // DrawText(ACanvas.Handle,PChar(Text),Length(Text),r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
- tnt_DrawTextw(ACanvas.Handle,Text,r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
- if Alignment=dt_center then
- OffsetRect(r1, ((rc.right - rc.left) - (r1.right - r1.left)) div 2,
- ((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2-1)
- else begin
- OffsetRect(r1, 0,((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2-1);
- r1.Left:=rc.left;r1.right:=rc.Right;
- end;
- if not enabled then Font.Color := clBtnShadow;
- // DrawText(ACanvas.Handle, PChar(Text),-1,r1,DrawStyle);
- DrawStyle := CheckBiDi(DrawStyle);
- Tnt_DrawTextW(ACanvas.Handle, text,r1,DrawStyle);
- end;
- end;
- procedure TSkinControl.DrawImgCaption(acanvas: TCanvas; rc:TRect;
- ImgList:hImageList;imgIndex:integer;text:widestring;talign:integer=DT_CENTER);
- var
- imgrect,textrect,r1,r2: TRect;
- DrawStyle: Longint;
- h,w,margin:integer;
- begin
- ImageList_GetIconSize(ImgList,w,h);
- if (imgindex<>-1) and (ImgList<>0) and ((rc.Right-rc.left)>w) then begin
- imgrect:=rect(0,0,w,h);
- end else begin
- imgrect:=rect(0,0,0,0);
- w:=0;
- end;
- //DrawStyle:= DrawStyle or dt_WordBreak ;
- DrawStyle := DT_END_ELLIPSIS or DT_EXPANDTABS or dt_WordBreak ;//DT_SINGLELINE;// or DT_CENTER;
- textrect:=rc;
- if (ImgList<>0) and (imgindex<>-1) then dec(textrect.right,-(2+w));
- if Length(Text)>0 then
- TNT_DrawTextw(acanvas.Handle,Text,textrect,DrawStyle or DT_CALCRECT or DT_NOCLIP)
- // DrawText(acanvas.Handle,PChar(Text),Length(Text),textrect,DrawStyle or DT_CALCRECT or DT_NOCLIP)
- else textrect.right:=textrect.left;
- offsetrect(imgrect,rc.left,rc.top);
- case talign of
- DT_CENTER :
- margin:=(rc.right-rc.left-w-(textrect.right-textrect.left)) div 2;
- DT_Left :
- margin:=3;
- DT_right :
- margin:=(rc.right-rc.left-w-(textrect.right-textrect.left))-2;
- end;
- if margin<2 then margin:=1;
- offsetrect(imgrect,margin,(rc.bottom-rc.top-w) div 2);
- OffsetRect(textrect,margin+w,
- ((rc.Bottom - rc.Top)-(textrect.Bottom-textrect.Top)) div 2);
- if (ImgList<>0) and (ImgIndex<>-1) then
- ImageList_Draw(imglist,ImgIndex,ACanvas.handle,
- imgrect.Left, imgrect.Top,ILD_TRANSPARENT);
- if Length(Text)=0 then exit;
- SetBkMode(aCanvas.Handle, TRANSPARENT);
- ACanvas.Brush.Style := bsClear;
- ACanvas.font.style:=[];
- if not enabled then ACanvas.Font.Color := clBtnShadow;
- if textrect.Left<rc.Left then textrect.Left:=rc.Left;
- if textrect.right>rc.right then textrect.right:=rc.right;
- DrawStyle:=CheckBiDi(DrawStyle);
- // DrawText(ACanvas.Handle, PChar(Text),Length(Text),textrect,DrawStyle);
- Tnt_DrawTextW(ACanvas.Handle,Text,textrect,DrawStyle);
- end;
- {procedure TSkinControl.DrawImgCaption(acanvas: TCanvas; rc:TRect;
- ImgList:TCustomImageList;imgIndex:integer;
- text:string; enabled,default:boolean;Alignment: TAlignment=taCenter);
- const
- Alignments: array[TAlignment] of Word = (DT_LEFT,DT_RIGHT,DT_CENTER );
- var
- r1: TRect;
- DrawStyle: Longint;
- begin
- DrawStyle := DT_EXPANDTABS or DT_SINGLELINE or Alignments[Alignment];
- r1.Left := rc.Left + 6;
- r1.Top := rc.Top + 1;
- r1.Right := r1.Left + 16;
- r1.Bottom := r1.Top + 16;
- if (ImgIndex>-1) and (ImgIndex <ImgList.Count) then
- ImgList.Draw(ACanvas, r1.Left, r1.Top, ImgIndex,Enabled);
- rc.left:=r1.right;
- r1:=rc;
- SetBkMode(aCanvas.Handle, TRANSPARENT);
- with ACanvas do begin
- Brush.Style := bsClear;
- // if Default then
- // Font.Style := Font.Style + [fsBold];
- font.style:=[];
- DrawText(Handle,PChar(Text),Length(Text),r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
- OffsetRect(r1, ((rc.right - rc.left) - (r1.right - r1.left)) div 2,
- ((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2);
- Font.Color := fsd.colors[csButtonText];
- if not enabled then
- Font.Color := clBtnShadow;
- DrawText(Handle, PChar(Text),Length(Text),r1,DrawStyle);
- end;
- end;}
- procedure TSkinControl.DrawSkinMap( dc:HDC; rc:TRect;
- aObject:TdataSkinObject;I,N:integer);
- var temp:Tbitmap;
- adc:HDC;
- begin
- if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
- temp:=GetHMap(rc,aobject.map,aobject.r,i,n,aobject.tile);
- if aobject.trans=1 then begin
- DrawTranmap(DC,rc,temp);
- end else
- BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.Top,
- temp.Canvas.Handle ,0 ,0 ,Srccopy);
- temp.free;
- end;
- function TSkinControl.CheckBiDi(dw:dword):dword;
- begin
- if (control<>nil) and (control.BiDiMode=bdRightToLeft) then
- dw := dw or dt_RtlReading;
- if (gcontrol<>nil) and (gcontrol.BiDiMode=bdRightToLeft) then
- dw := dw or dt_RtlReading;
- result:=dw;
- end;
- procedure TSkinControl.DrawBuf( dc:HDC; rc:TRect);
- begin
- // fcanvas.handle:=dc;
- // fcanvas.draw(rc.left,rc.top,BG);
- BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.Top,
- bg.Canvas.Handle ,0 ,0 ,Srccopy);
- end;
- procedure TSkinControl.WMPaint(message:TMessage);
- var ps: TPaintStruct ;
- dc: HDC ;
- rc :Trect;
- begin
- if ( message.wParam=0 ) then begin
- DC := BeginPaint(hWnd, ps);
- end else begin
- DC := message.wParam;
- end;
- if GetWindowRect( hWnd, rc ) then begin
- // GetWindowRect( hWnd, rc );
- boundsrect:=rc;
- OffsetRect( rc, -rc.left, -rc.top );
- // try
- Drawcontrol(dc,rc);
- // except
- // end;
- end;
- if ( message.wParam=0 ) then
- EndPaint(hWnd, ps);
- end;
- procedure TSkinControl.WMERASEBKGND(var Msg: TMessage);
- var r:Trect;
- i:integer;
- begin
- i:=0;
- if (control<>nil) then i:= control.Tag;
- if (control<>nil) or (i=8888) then
- DrawParentImage(control,msg.wparam,true)
- else begin
- GetClientRect(hwnd,r);
- fillParentBG(msg.wparam,r);
- end;
- // FillRect( msg.wparam,r,fsd.BGbrush);
- Msg.Result := 1;
- end;
- procedure TSkinControl.DrawBMPSkin( abmp:Tbitmap;rc:TRect;aObject:TdataSkinObject;
- I,N:integer;trans:integer);
- var temp:Tbitmap;
- begin
- if ((rc.right-rc.left)<0) or ((rc.bottom-rc.top)<0) then exit;
- temp:=GetHMap(rc,aobject.map,aobject.r,i,n,aobject.tile);
- fillBG(abmp.canvas.handle,rc);
- if trans=1 then begin
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- // temp.Transparentcolor:= temp.Canvas.Pixels[0, 0];
- end;
- abmp.canvas.draw(0,0,temp);
- temp.free;
- end;
- procedure TSkinControl.DrawSkin( rc:TRect;aObject:TdataSkinObject;
- I,N:integer;trans:integer);
- var temp:Tbitmap;
- begin
- if ((rc.right-rc.left)<0) or ((rc.bottom-rc.top)<0) then exit;
- temp:=GetHMap(rc,aobject.map,aobject.r,i,n,aobject.tile);
- fillBG(bg.canvas.handle,rc);
- if trans=1 then begin
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- // temp.Transparentcolor:= temp.Canvas.Pixels[0, 0];
- end;
- bg.canvas.draw(0,0,temp);
- temp.free;
- end;
- procedure TSkinControl.DrawSkinMap1( dc:HDC; rc:TRect;
- bmp:Tbitmap;I,N:integer);
- var temp:Tbitmap;
- w,h,x:integer;
- adc:HDC;
- acanvas:Tcanvas;
- begin
- if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
- temp:=Tbitmap.create;
- w:=bmp.width div n;
- h:=bmp.height;
- temp.height:=rc.bottom-rc.top;
- temp.width:=rc.right-rc.left;
- x:=(i-1)*w;
- temp.canvas.copyrect( rect(0,0,rc.right-rc.left,rc.bottom-rc.top),
- bmp.canvas,rect(x,0,x+w,h));
- acanvas:=Tcanvas.create;
- acanvas.handle:=dc;
- try
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- // temp.Transparentcolor:=temp.Canvas.Pixels[0, 0];
- acanvas.draw(rc.left,rc.top,temp);
- finally
- temp.free;
- acanvas.free;
- end;
- end;
- procedure TSkinControl.DrawSkinMap3( acanvas:Tcanvas; rc:TRect;
- bmp:Tbitmap;I,N:integer);
- var temp1:Tbitmap;
- w,h,x:integer;
- begin
- if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
- temp1:=Tbitmap.create;
- w:=bmp.width div n;
- h:=bmp.height;
- temp1.height:=rc.bottom-rc.top;
- temp1.width:=rc.right-rc.left;
- x:=(i-1)*w;
- temp1.canvas.copyrect( rect(0,0,rc.right-rc.left,rc.bottom-rc.top),
- bmp.canvas,rect(x,0,x+w,h));
- temp1.Transparent:=true;
- temp1.Transparentcolor:=clFuchsia;
- acanvas.draw(rc.left,rc.top,temp1);
- temp1.free;
- end;
- procedure TSkinControl.DrawSkinMap2( dc:HDC; rc:TRect;
- bmp:Tbitmap;I,N:integer);
- var temp:Tbitmap;
- w,h,x:integer;
- begin
- if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
- temp:=Tbitmap.create;
- w:=bmp.width div n;
- h:=bmp.height;
- temp.height:=rc.bottom-rc.top;
- temp.width:=rc.right-rc.left;
- x:=(i-1)*w;
- temp.canvas.copyrect( rect(0,0,rc.right-rc.left,rc.bottom-rc.top),
- bmp.canvas,rect(x,0,x+w,h));
- { fcanvas.handle:=dc;
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- // temp.Transparentcolor:=temp.Canvas.Pixels[0, 0];
- fcanvas.draw(rc.left,rc.top,temp);}
- DrawTranmap(DC,rc,temp);
- temp.free;
- end;
- {procedure TSkinControl.DrawSkinMap2( dc:HDC; rc:TRect;
- bmp:Tbitmap;I,N:integer);
- var mask:Tbitmap;
- w,h,x:integer;
- begin
- if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
- mask:=Tbitmap.create;
- mask.assign(bmp);
- mask.mask(clFuchsia);
- w:=bmp.width div n;
- h:=bmp.height;
- x:=(i-1)*w;
- TransparentStretchBlt(dc,rc.left,rc.Top,rc.Right-rc.Left,rc.Bottom-rc.Top,
- bmp.Canvas.Handle,x,0,x+w,h,mask.Handle,x,0);
- mask.free;
- end;}
- function TSkinStatusBar.BeforeProc(var Message: TMessage):boolean;
- var r:Trect;
- begin
- // result:=inherited BeforeProc(message);
- // exit;
- //Draw child control
- result:=true;
- case message.msg of
- WM_ERASEBKGND: begin
- message.result:=1;
- result:=false;
- end;
- WM_Paint : begin
- wmpaint(message);
- result:=false;
- end;
- else result:=inherited BeforeProc(message);
- end;
- end;
- procedure TSkinStatusBar.DrawControl( dc:HDC; rc:TRect);
- const
- Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
- var i,n,j,m,w1,h1:integer;
- r,r1,r2:Trect;
- sb:Tstatusbar;
- dwstyle:dword;
- bfont,cfont:Hfont;
- Flags:TAlignment;
- text:widestring;
- b:boolean;
- begin
- sb:=Tstatusbar(control);
- n:= sb.Panels.count;
- r1:=rc;
- b:=false;
- offsetrect(r1,-r1.left,-r1.top);
- bg.width:=r1.right;
- bg.height:=r1.bottom;
- bg.canvas.brush.color:=fsd.colors[csButtonFace];
- bg.canvas.fillrect(r1);
- bg.canvas.Font := TAcControl(control).Font;
- bg.canvas.font.style:=[];
- if fsd.statusbar<>nil then
- bg.canvas.Font.Color:= fsd.statusbar.normalcolor2;
- // bfont:=sendmessage(hwnd,wm_getfont,0,0);
- // cfont := selectobject(bg.canvas.handle,bfont);
- if fsd.statusbar<>nil then
- SetTextColor(bg.canvas.handle,ColorToRGB(fsd.statusbar.normalcolor2));
- if (sb.simplepanel) or (sb.Panels.count=0) then begin
- j:=1;
- if (sb.bidimode = bdRightToLeft) then
- Flags:=taRightJustify
- else
- Flags:=taLeftJustify;
- text:= GetStringProp(sb,'simpletext');
- if (fsd.statusbar<>nil) and (not fsd.statusbar.map.empty) then
- drawitem(bg.canvas.handle,rc,j,text,Flags)
- else
- Defaultpaint(bg.canvas,rc,j,text,Flags);
- if text='' then text:=' ';
- r2:=rc;
- InflateRect( r2, -2, 0 );
- DrawCaption(bg.canvas,r2,text,true,false,Alignments[flags]);
- end else begin
- m:=0;
- for i:= 0 to n-1 do begin
- j:=0;
- flags:=sb.Panels[i].alignment;
- if (sb.Panels[i].bidimode=bdRightToLeft) then begin
- if Flags=taLeftJustify then
- Flags :=taRightJustify
- else if Flags=taRightJustify then
- Flags:=taLeftJustify;
- end;
- if sb.Panels[i].Bevel=pblowered then j:=1;
- if sb.Panels[i].Bevel=pbNone then j:=3;
- if sb.Panels[i].Bevel=pbRaised then j :=2;
- if sendmessage(hwnd,SB_GETRECT,i,integer(@r))<>0 then begin
- //InflateRect( r, 2, 0 );
- inc(r.Right,2);
- if i=n-1 then r.Right := rc.Right;
- text:= GetStringProp(sb.Panels[i],'Text');
- if (fsd.statusbar<>nil) and (not fsd.statusbar.map.empty) then
- drawitem(bg.canvas.handle,r,j,text,Flags)
- else
- Defaultpaint(bg.canvas,r,j,text,Flags);
- if sb.Panels[i].Style=psText then begin
- if text='' then text:=' ';
- InflateRect( r, -2, 0 );
- DrawCaption(bg.canvas,r,text,true,false,Alignments[flags]);
- end;
- end;
- end;
- end;
- dwstyle:= GetWindowLong(hWnd,GWL_STYLE);
- if (dwstyle and SBARS_SIZEGRIP)>0 then begin
- r1.Right := rc.Right - 1;
- r1.bottom := rc.bottom - 1;
- if (fsd.ExtraImages<>nil) and (not fsd.ExtraImages.map.empty) then begin
- w1:= fsd.ExtraImages.map.width div fsd.ExtraImages.frame;
- h1:= fsd.ExtraImages.map.height;
- r1.left:=r1.right - w1 ;
- r1.top:= r1.bottom - h1;
- DrawSkinMap1( bg.canvas.handle,r1,fsd.ExtraImages.map,5,fsd.ExtraImages.frame);
- end;
- end;
- DrawBuf( dc,rc);
- if control<>nil then
- TAcWincontrol(control).PaintControls(dc,nil);
- if assigned(sb.ondrawpanel) and (n>0) then begin
- for i:= 0 to n-1 do begin
- if sendmessage(hwnd,SB_GETRECT,i,integer(@r))<>0 then begin
- InflateRect( r, -2, -2 );
- sb.ondrawpanel(sb,sb.Panels[i],r);
- end;
- end;
- end;
- // selectobject(bg.canvas.handle,cfont);
- end;
- {procedure TSkinStatusBar.DrawControl( dc:HDC; rc:TRect);
- var i,n,j,m,l,w1,h1:integer;
- r,r1,r2:Trect;
- bfont,cfont:Hfont;
- dwstyle:dword;
- issimple:boolean;
- Buffer: array[0..128] of Char;
- s:string;
- begin
- // if fsd.statusbar=nil then exit;
- n:=sendmessage(hwnd,SB_GETPARTS,0,integer(@l));
- r1:=rc;
- offsetrect(r1,-r1.left,-r1.top);
- bg.width:=r1.right;
- bg.height:=r1.bottom;
- bg.canvas.brush.color:=fsd.colors[csButtonFace];
- bg.canvas.fillrect(r1);
- bg.canvas.Font.style := [];
- bfont:=sendmessage(hwnd,wm_getfont,0,0);
- cfont := selectobject(bg.canvas.handle,bfont);
- if fsd.statusbar<>nil then
- SetTextColor(bg.canvas.handle,fsd.statusbar.normalcolor2);
- issimple:= (sendmessage(hwnd,SB_ISSIMPLE,0,0)>0);
- if (issimple) or (n=0) then begin
- j:=1;
- sendmessage(hwnd,SB_GETTEXT,0,integer(@buffer));
- s:=buffer;
- if (fsd.statusbar<>nil) and (not fsd.statusbar.map.empty) then
- drawitem(bg.canvas.handle,rc,j,s,taLeftJustify)
- else
- Defaultpaint(bg.canvas.handle,rc,j,s,taLeftJustify);
- end else begin
- m:=0;
- for i:= 0 to n-1 do begin
- m:= sendmessage(hwnd,SB_GETTEXT,i,integer(@buffer));
- m := m div 16;
- s:=buffer;
- case m of
- 0 : j:=1;
- SBT_NOBORDERS : j:=0;
- SBT_POPOUT : j :=2;
- else j:=0;
- end;
- if sendmessage(hwnd,SB_GETRECT,i,integer(@r))<>0 then begin
- if i=n-1 then r.Right := rc.Right;
- if (fsd.statusbar<>nil) and (not fsd.statusbar.map.empty) then
- drawitem(bg.canvas.handle,r,j,s,taLeftJustify)
- else
- Defaultpaint(bg.canvas.handle,r,j,s,taLeftJustify);
- end;
- end;
- end;
- dwstyle:= GetWindowLong(hWnd,GWL_STYLE);
- if (dwstyle and SBARS_SIZEGRIP)>0 then begin
- r1.Right := rc.Right - 1;
- r1.bottom := rc.bottom - 1;
- if (fsd.ExtraImages<>nil) and (not fsd.ExtraImages.map.empty) then begin
- w1:= fsd.ExtraImages.map.width div fsd.ExtraImages.frame;
- h1:= fsd.ExtraImages.map.height;
- r1.left:=r1.right - w1 ;
- r1.top:= r1.bottom - h1;
- DrawSkinMap1( bg.canvas.handle,r1,fsd.ExtraImages.map,5,fsd.ExtraImages.frame);
- end;
- end;
- DrawBuf( dc,rc);
- selectobject(bg.canvas.handle,cfont);
- end;}
- procedure TSkinStatusBar.drawitem(dc:HDC; rc:TRect;I:integer;text:widestring='';Align:TAlignment=taLeftJustify);
- const
- Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
- var temp:TBitmap;
- FontHeight: Integer;
- Flags: Longint;
- acolor:Tcolor;
- begin
- if (rc.right<rc.left) or (rc.bottom<rc.top) then exit;
- temp:=GetHMap(rc,fsd.statusbar.map,fsd.statusbar.r,i,3,fsd.statusbar.tile);
- BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.top,
- temp.Canvas.Handle ,0 ,0 ,Srccopy);
- temp.free;
- { if text='' then text:=' ';
- InflateRect( rc, -2, 0 );
- DrawCaption(dc,rc,text,true,false,Alignments[Align]);}
- end;
- procedure TSkinStatusBar.Defaultpaint(acanvas:Tcanvas; rc:TRect;I:integer;
- text:widestring='';Align:TAlignment=taLeftJustify);
- var
- TopColor, BottomColor: TColor;
- FontHeight: Integer;
- Flags: Longint;
- procedure AdjustColors(Bevel: TStatusPanelBevel);
- begin
- TopColor := clBtnHighlight;
- if Bevel = pbLowered then TopColor := clBtnShadow;
- BottomColor := clBtnShadow;
- if Bevel = pbLowered then BottomColor := clBtnHighlight;
- end;
- begin
- if i=1 then begin
- AdjustColors(pbLowered);
- Frame3D(acanvas, Rc, TopColor, BottomColor, 1);
- end else if i=2 then begin
- AdjustColors(pbRaised);
- Frame3D(acanvas, Rc, TopColor, BottomColor, 1);
- end;
- // if text='' then text:=' ';
- // InflateRect( rc, -2, 0 );
- // DrawCaption(dc,rc,text,true,false,Alignments[Align]);
- { with bg.Canvas do begin
- Brush.Color := fsd.colors[csButtonFace];
- FillRect(rc);
- SetBkMode(Handle, TRANSPARENT);
- Font := TAcControl(control).Font;
- font.style:=[];
- FontHeight := TextHeight('W');
- with rc do begin
- Top := ((Bottom + Top) - FontHeight) div 2;
- Bottom := Top + FontHeight;
- end;
- Flags := DT_EXPANDTABS or DT_VCENTER or Alignments[Align];
- // Flags := DrawTextBiDiModeFlags(Flags);
- DrawText(Handle, PChar(text), -1, rc, Flags);
- end;}
- end;
- Procedure TSkinGroupBox.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- var s:string;
- begin
- inherited init(sf,sd,acanvas,acolor);
- if control=nil then exit;
- // s := lowercase(GetEnumProperty(control,'Transparent'));
- // if s='true' then kind:=1;
- kind:=1;
- end;
- function TSkinGroupBox.BeforeProc(var Message: TMessage):boolean;
- var r:Trect;
- begin
- result:=true;
- result:=inherited BeforeProc(message);
- if kind=0 then exit;
- case message.msg of
- //has problem in TScrollbox.
- { WM_ERASEBKGND:begin
- WMERASEBKGND(message);
- message.Result:=1;
- result:=false;
- end; }
- WM_Paint : begin
- wmpaint(message);
- result:=false;
- end;
- end;
- end;
- procedure TSkinGroupBox.DrawControl( dc:HDC; rc:TRect);
- var r,r1:Trect;
- oldcolor,i:integer;
- bfont,cfont:Hfont;
- OldMode:integer;
- font:Tfont;
- dw:dword;
- begin
- defaultdraw(dc,rc);
- exit;
- if (fsd.box=nil) or (fsd.box.map.empty) then exit;
- i:=1;
- DrawSkinMap( dc,rc,fsd.box,I,fsd.box.frame);
- caption:=getformcaption(hwnd);
- if (control<>nil) then
- caption := GetStringProp(control,'Caption')
- else
- caption:=getformcaption(hwnd);
- if control<>nil then begin
- font := Tfont(GetObjProp(control,'Font',Tfont));
- if font<>nil then begin
- bfont := font.Handle;
- SetTextColor(dc,ColorToRGB(font.Color));
- end;
- end else
- bfont:=sendmessage(hwnd,wm_getfont,0,0);
- // if (control<>nil) then
- // bfont := Taccontrol(control).font.Handle;
- cfont:=selectobject(dc,bfont);
- OldMode := SetBkMode(dc, TRANSPARENT);
- // oldcolor := setbkcolor(dc,fsd.colors[csButtonFace]);
- r1:=rect(rc.Left+10,rc.top+1,rc.right,rc.bottom);
- // DrawText(dc, PChar(caption),-1,r1,DT_EXPANDTABS or DT_Left);
- Tnt_DrawTextW(dc, caption,r1,DT_EXPANDTABS or DT_Left);
- // setbkcolor(dc,oldcolor);
- SetBkMode(dc, OldMode);
- selectobject(dc,cfont);
- if (control<>nil) and (kind=1) then
- TAcWincontrol(control).PaintControls(dc,nil);
- end;
- function TSkincontrol.TextHeight(dc:HDC;const s: string):integer;
- var asize : TSize;
- begin
- asize.cX := 0;
- asize.cY := 0;
- Windows.GetTextExtentPoint32(dc, PChar(s), Length(s), asize);
- result:=asize.cy;
- end;
- procedure TSkinGroupBox.DefaultDraw( dc:HDC; rc:TRect);
- var r,r1:Trect;
- oldcolor,i,h:integer;
- bfont,cfont:Hfont;
- oldbrush,nbrush: HBRUSH ;
- oldpen,npen:Hpen;
- oldmode:integer;
- font:Tfont;
- exstyle:dword;
- dw:dword;
- begin
- caption:=getformcaption(hwnd);
- if (caption='') and (control<>nil) then begin
- caption := GetStringProp(control,'Caption');
- end;
- if control<>nil then FillBG(dc,rc);
- { if control<>nil then
- DrawParentImage(control,dc,true)
- else FillBG(dc,rc);}
- { bfont:=sendmessage(hwnd,wm_getfont,0,0);
- if (control<>nil) then
- bfont := Taccontrol(control).font.Handle;}
- bfont:=sendmessage(hwnd,wm_getfont,0,0);
- if control<>nil then begin
- //font := Tfont(GetObjProp(control,'Font',Tfont));
- font := Taccontrol(control).font;
- if font<>nil then begin
- bfont := font.Handle;
- SetTextColor(dc,ColorToRGB(font.Color));
- end;
- end;
- cfont:=selectobject(dc,bfont);
- h:=TextHeight(dc,'0');
- npen := CreatePen(PS_SOLID,1,fsd.colors[csButtonShadow]);
- r1 := Rect(0, H div 2 - 1, rc.right, rc.bottom);
- r:=r1;
- if kind=0 then begin
- framerect(dc,r,fsd.BGBrush);
- InflateRect(R, -1, -1);
- framerect(dc,r,fsd.BGBrush);
- end;
- nbrush:=GetStockObject(NULL_BRUSH);
- oldbrush:=selectobject(dc,nbrush);
- oldpen := selectobject(dc,npen);
- r1 := Rect(1, H div 2 - 1, rc.right-1, rc.bottom-1);
- RoundRect(dc,r1.left,r1.top,r1.right,r1.bottom,5,5);
- selectobject(dc,oldBrush);
- selectobject(dc,oldpen);
- deleteobject(npen);
- // OldMode := SetBkMode(dc, TRANSPARENT);
- dw:= DT_EXPANDTABS;
- oldcolor := setbkcolor(dc,fsd.colors[csButtonFace]);
- ExStyle := GetWindowLong( hWnd, GWL_ExSTYLE );
- if (exstyle and WS_EX_Right)>0 then begin
- r1:=rect(rc.Left,rc.top,rc.right-8,rc.bottom);
- dw:=dw or DT_Right;
- dw:=checkBidi(dw);
- Tnt_DrawTextW(dc,caption,r1,dw);
- end else begin
- r1:=rect(rc.Left+8,rc.top,rc.right,rc.bottom);
- dw:=dw or DT_Left;
- Tnt_DrawTextW(dc,caption,r1,dw);
- end;
- setbkcolor(dc,oldcolor);
- selectobject(dc,cfont);
- // SetBkMode(dc, OldMode);
- if (control<>nil) and (kind=1) then
- TAcWincontrol(control).PaintControls(dc,nil);
- end;
- procedure TSkinBox.AfterProc(var Message: TMessage);
- begin
- end;
- Procedure TSkinBox.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- begin
- // inherited init(sf,sd,acanvas,acolor);
- newcolor:=acolor;
- fsd:=sd;
- fCanvas:=acanvas;
- control:=Twincontrol(owner);
- hwnd := control.handle;
- skinform :=sf;
- Twinskinform(sf).addcontrollist(self);
- // OldWndProc:= Control.WindowProc;
- // Control.WindowProc := NewWndProc;
- if newcolor then begin
- setparentbk(true);
- oldcolor:=Taccontrol(control).color;
- Taccontrol(control).color:=fsd.colors[csButtonFace];
- end;
- end;
- Procedure TSkinBox.Unsubclass;
- var b:boolean;
- begin
- b:=true;
- if skinstate=skin_destory then b:=false;
- if b and newcolor and (control<>nil) then begin
- setparentbk(false);
- Taccontrol(control).color:=oldcolor;
- end;
- skinstate:=skin_uninstall;
- end;
- function copypchar(pstr:pchar;len:integer):string;
- begin
- if len>0 then begin
- setlength(result,len);
- move(pstr,result[1],len);
- end;
- end;
- procedure MyDrawCaption(acanvas: TCanvas; rc:TRect;
- text:widestring; enabled,defaulted:boolean;Alignment: TAlignment=taCenter);
- const
- Alignments: array[TAlignment] of Word = (DT_LEFT,DT_RIGHT,DT_CENTER );
- var
- r1: TRect;
- DrawStyle: Longint;
- begin
- DrawStyle := DT_EXPANDTABS or DT_SINGLELINE or Alignments[Alignment];
- r1 := rc;
- SetBkMode(aCanvas.Handle, TRANSPARENT);
- with ACanvas do begin
- Brush.Style := bsClear;
- font.style:=[];
- // Calculate vertical layout
- // DrawText(ACanvas.Handle,PChar(Text),Length(Text),r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
- tnt_drawtextw(ACanvas.Handle,Text,r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
- OffsetRect(r1, ((rc.right - rc.left) - (r1.right - r1.left)) div 2,
- ((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2);
- if not enabled then
- Font.Color := clBtnShadow;
- //DrawText(ACanvas.Handle, PChar(Text),Length(Text),r1,DrawStyle);
- Tnt_DrawTextW(ACanvas.Handle,Text,r1,DrawStyle);
- end;
- end;
- procedure DrawArrow(ACanvas: TCanvas; X, Y, Orientation: integer);
- begin
- case Orientation of
- 0:
- begin
- ACanvas.MoveTo(X, Y);
- ACanvas.LineTo(X, Y-1);
- ACanvas.MoveTo(X + 1, Y + 1);
- ACanvas.LineTo(X + 4, Y + 4);
- ACanvas.MoveTo(X, Y + 1);
- ACanvas.LineTo(X + 3, Y + 4);
- ACanvas.MoveTo(X, Y + 2);
- ACanvas.LineTo(X + 2, Y + 4);
- ACanvas.MoveTo(X - 1, Y + 1);
- ACanvas.LineTo(X - 4, Y + 4);
- ACanvas.MoveTo(X, Y + 2);
- ACanvas.LineTo(X - 3, Y + 4);
- ACanvas.MoveTo(X, Y + 1);
- ACanvas.LineTo(X - 2, Y + 4);
- end;
- 1:
- begin
- ACanvas.MoveTo(X, Y+3);
- ACanvas.LineTo(X, Y+4);
- ACanvas.MoveTo(X + 1, Y + 2);
- ACanvas.LineTo(X + 4, Y - 1);
- ACanvas.MoveTo(X, Y + 2);
- ACanvas.LineTo(X + 3, Y - 1);
- ACanvas.MoveTo(X, Y + 1);
- ACanvas.LineTo(X + 2, Y + 0);
- ACanvas.MoveTo(X - 1, Y + 2);
- ACanvas.LineTo(X - 4, Y - 1);
- ACanvas.MoveTo(X, Y + 2);
- ACanvas.LineTo(X - 3, Y - 1);
- ACanvas.MoveTo(X, Y + 1);
- ACanvas.LineTo(X - 2, Y + 0);
- end;
- 2://left
- begin
- ACanvas.MoveTo(X, Y);
- ACanvas.lineTo(X+1, Y+2);
- ACanvas.LineTo(X+1, Y-2);
- ACanvas.LineTo(X-1,Y);
- ACanvas.LineTo(X+1,Y+2);
- end;
- 3://right
- begin
- ACanvas.MoveTo(X, Y);
- ACanvas.lineTo(X-1, Y+2);
- ACanvas.LineTo(X-1, Y-2);
- ACanvas.LineTo(X+1,Y);
- ACanvas.LineTo(X-1,Y+2);
- end;
- end;
- end;
- procedure MyDrawImgCaption(acanvas: TCanvas; rc:TRect;
- ImgList:TCustomImageList;imgIndex:integer;
- text:string; enabled,defaulted:boolean;Alignment: TAlignment=taCenter);
- const
- Alignments: array[TAlignment] of Word = (DT_LEFT,DT_RIGHT,DT_CENTER );
- var
- r1: TRect;
- DrawStyle: Longint;
- begin
- DrawStyle := DT_EXPANDTABS or DT_SINGLELINE or Alignments[Alignment];
- r1.Left := rc.Left + 6;
- r1.Top := rc.Top + 1;
- r1.Right := r1.Left + 16;
- r1.Bottom := r1.Top + 16;
- if (ImgIndex>-1) and (ImgIndex <ImgList.Count) then
- ImgList.Draw(ACanvas, r1.Left, r1.Top, ImgIndex,Enabled);
- rc.left:=r1.right;
- r1:=rc;
- SetBkMode(aCanvas.Handle, TRANSPARENT);
- with ACanvas do begin
- Brush.Style := bsClear;
- // if Default then
- // Font.Style := Font.Style + [fsBold];
- font.style:=[];
- DrawText(Handle,PChar(Text),Length(Text),r1,DrawStyle or DT_CALCRECT or DT_NOCLIP);
- OffsetRect(r1, ((rc.right - rc.left) - (r1.right - r1.left)) div 2,
- ((rc.Bottom - rc.Top) - (r1.Bottom - r1.Top)) div 2);
- if not enabled then
- Font.Color := clBtnShadow;
- // DrawText(Handle, PChar(Text),Length(Text),r1,DrawStyle);
- Tnt_DrawTextW(Handle,Text,r1,DrawStyle);
- end;
- end;
- function TSkinTransObj.BeforeProc(var Message: TMessage):boolean;
- begin
- result:=true;
- case message.msg of
- WM_ERASEBKGND: begin
- ERASEBKGND(message.wparam);
- message.result:=1;
- result:=false;
- end;
- WM_Paint: begin
- SetBkColor(message.wparam,fsd.colors[csButtonFace]);
- end;
- else result := inherited beforeproc(message);
- end;
- end;
- procedure TSkinTransObj.AfterProc(var Message: TMessage);
- begin
- inherited;
- end;
- procedure TSkinTransObj.ERASEBKGND( dc:HDC);
- var rc,r1:Trect;
- n:integer;
- begin
- GetWindowRect( hWnd, rc );
- OffsetRect( rc, -rc.left, -rc.top );
- fillbg(dc,rc);
- end;
- constructor TSkinTab.Create(AOwner: TComponent);
- begin
- inherited create(aowner);
- tabbmp:=Tbitmap.create;
- borderbmp:=Tbitmap.create;
- Drawtemp:=Tbitmap.create;
- Drawtemp.PixelFormat:= pf24bit;
- showclose := false;
- end;
- destructor TSkinTab.Destroy;
- begin
- tabbmp.free;
- borderbmp.free;
- Drawtemp.free;
- inherited destroy;
- end;
- function TSkinTab.ClickClose(var Message: TMessage):boolean;
- var p:TPoint;
- i,j: integer;
- begin
- result:=false;
- p := Point(message.LParamLo,message.LParamHi);
- for i:= 0 to high(closerect) do begin
- if PtInrect(closerect[i],p) then begin
- j := sendmessage( TWinskinForm(skinform).Hwnd,CN_TabSheetClose,hwnd,i);
- if j=0 then
- Tpagecontrol(control).Pages[i].free;
- //ShowMessage('Click CloseBtn '+inttostr(i));
- result:=true;
- end;
- end;
- end;
- function TSkinTab.BeforeProc(var Message: TMessage):boolean;
- begin
- case message.msg of
- wm_paint: begin
- // if kind<>2 then begin
- wmpaint(message);
- result:=false;
- // end else result:=true;
- end;
- WM_LBUTTONDOWN: begin
- if showclose and clickclose(message) then begin
- result:=false;
- message.Result:=0;
- exit;
- end else
- result:=inherited beforeProc(message);
- end ;
- else result:=inherited beforeProc(message);
- end;
- end;
- {procedure TSkinTab.AfterProc(var Message: TMessage);
- var i:integer;
- begin
- case message.msg of
- CN_TabSheetClose:begin
- i := sendmessage( TWinskinForm(skinform).Hwnd,message.Msg,hwnd,message.WParam);
- if i=0 then
- Tpagecontrol(control).Pages[message.WParam].free;
- message.result:=0;
- end;
- else inherited AfterProc(message);
- end;
- end;}
- Procedure TSkinTab.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- begin
- inherited init(sf,sd,acanvas,acolor);
- enabled := (GetWindowLong(hWnd,GWL_STYLE) and WS_DISABLED)=0;
- { Focused := (GetFocus= hWnd);
- enabled := (GetWindowLong(hWnd,GWL_STYLE) and WS_DISABLED)=0;
- caption:=getformcaption(hwnd);}
- if (owner.Tag = 7777) and (owner is Tpagecontrol)
- and (Tpagecontrol(control).TabPosition=tpTop) then showclose :=true;
- inittab;
- FindScroll;
- skinned:=true;
- unicode:=IsWindowUnicode(hwnd);
- end;
- Procedure TSkinTab.Inithwnd(ahwnd:Thandle;sd:TSkinData;acanvas:TCanvas;sf:Tcomponent);
- begin
- inherited Inithwnd(ahwnd,sd,acanvas,sf);
- Focused := (GetFocus= hWnd);
- enabled := (GetWindowLong(hWnd,GWL_STYLE) and WS_DISABLED)=0;
- caption:=getformcaption(hwnd);
- inittab;
- FindScroll;
- skinned:=true;
- unicode:=IsWindowUnicode(hwnd);
- end;
- Procedure TSkinTab.SkinChange;
- begin
- inherited skinchange;
- inittab;
- end;
- Procedure TSkinTab.inittab;
- begin
- tabbmp.empty;
- borderbmp.empty;
- GetPosition;
- if (fsd.tab<>nil) and (not fsd.tab.map.empty) then
- CopyBMP(fsd.tab.Map,tabbmp);
- if (fsd.tab.style=0) and (not fsd.tab.maskmap.empty) then
- CopyBMP(fsd.tab.maskMap,borderbmp);
- if (fsd.tab.style=1) and (fsd.TabSheet<>niL) and
- (not fsd.tabsheet.map.empty) then
- CopyBMP(fsd.tabsheet.Map,borderbmp);
- tabbmp.PixelFormat:= pf24bit;
- borderbmp.PixelFormat:= pf24bit;
- case position of
- stleft: begin
- Drehen270Grad(borderbmp);
- end;
- stright: begin
- Drehen90Grad(borderbmp);
- end;
- stbottom: begin
- SpiegelnVertikal(borderbmp);
- SpiegelnVertikal(tabbmp);
- end;
- end;
- { if (fsd.tab<>nil) and (not fsd.tab.map.empty)
- and (not fsd.tab.maskmap.empty) then begin
- // tabbmp.assign(fsd.tab.map);
- // borderbmp.assign(fsd.tab.maskmap);
- CopyBMP(fsd.tab.Map,tabbmp);
- CopyBMP(fsd.tab.maskMap,borderbmp);
- tabbmp.PixelFormat:= pf24bit;
- borderbmp.PixelFormat:= pf24bit;
- case position of
- stleft: begin
- Drehen270Grad(borderbmp);
- end;
- stright: begin
- Drehen90Grad(borderbmp);
- end;
- stbottom: begin
- SpiegelnVertikal(borderbmp);
- SpiegelnVertikal(tabbmp);
- end;
- end;
- end;}
- end;
- {function TSkinTab.BeforeProc(var Message: TMessage):boolean;
- begin
- result:=inherited BeforeProc(message);
- //label dispear in tab
- case message.msg of
- WM_PAINT: begin
- wmpaint(message);
- result:=false;
- end;
- else result:=inherited BeforeProc(message);
- end;
- result:=true;
- case message.msg of
- WM_NCPAINT,WM_PRINTCLIENT: begin
- DrawTabborder(message.wparam);
- Message.Result := 0;
- result:=false;
- end;
- WM_ERASEBKGND: begin
- DrawTabborder(message.wparam);
- message.result:=1;
- result:=false;
- end;
- else result:=inherited BeforeProc(message);
- end;
- end;}
- procedure TSkinTab.DrawTabBorder(adc:HDC);
- var rt:Trect;
- dc:HDC;
- i:integer;
- begin
- if (fsd.tab.maskmap<>nil) and (not fsd.tab.maskmap.empty) then begin
- //if adc=0 then DC := GetWindowDC( hWnd )
- //else dc:=adc;
- DC := GetWindowDC( hWnd );
- GetClientRect(hwnd,rt);
- // i:=SendMessage( hWnd, TCM_ADJUSTRECT, 0, integer(@RT) );
- TabCtrl_AdjustRect( hWnd,false,@RT);
- // GetClientRect(hwnd,rt);
- InflateRect( rt, 4, 2);
- offsetrect( rt, 0, 1);
- DrawRect2(DC,rt,fsd.tab.maskmap,rect(4,5,4,4),1,1);
- //end;
- //if adc=0 then
- ReleaseDC( hwnd, DC );
- end;
- end;
- function TSkinTab.FindScroll:boolean;
- var Wnd: THandle;
- begin
- Wnd := FindWindowEx(hwnd, 0, 'msctls_updown32', nil);
- if (Wnd<>0) and (updown=nil) then begin
- updown:=Tskinupdown.create(self.owner);
- updown.inithwnd(wnd,fsd,fcanvas,skinform);
- end;
- result:= (GetWindowLong(wnd,GWL_STYLE) and WS_visible)>0;
- end;
- procedure TSkinTab.ERASEBKGND( dc:HDC);
- var rc,r1:Trect;
- n:integer;
- begin
- if GetWindowRect( hWnd, rc ) then
- FillRect( dc,rc,fsd.BGbrush);
- end;
- procedure TSkinTab.GetPosition;
- var dwStyle : longint;
- begin
- dwStyle := GetWindowLong( hWnd, GWL_STYLE );
- if (dwStyle and TCS_BOTTOM )>0 then begin
- if (dwStyle and TCS_VERTICAL)>0 then
- position:=stRight
- else
- position:=stBottom;
- end else begin
- if ( dwStyle and TCS_VERTICAL )>0 then
- position:= stLeft
- else
- position:= stTop;
- end;
- end;
- {procedure TSkinTab.WMPaint(var msg:Tmessage);
- var
- DC, MemDC: HDC;
- MemBitmap, OldBitmap: HBITMAP;
- PS: TPaintStruct;
- rc:Trect;
- begin
- // inherited wmpaint(msg);
- getwindowrect(hwnd,rc);
- offsetrect(rc,-rc.left,-rc.top);
- DC := GetDC(0);
- MemBitmap := CreateCompatibleBitmap(DC, rc.Right, rc.Bottom);
- ReleaseDC(0, DC);
- MemDC := CreateCompatibleDC(0);
- OldBitmap := SelectObject(MemDC, MemBitmap);
- try
- DC := BeginPaint(hwnd, PS);
- //control.Perform(WM_ERASEBKGND, MemDC, MemDC);
- SetBkMode(MemDC, TRANSPARENT);
- Msg.wparam := MemDC;
- OldWndProc(msg);
- Msg.wparam := 0;
- BitBlt(DC, 0, 0, rc.Right, rc.Bottom, MemDC, 0, 0, SRCCOPY);
- EndPaint(hwnd, PS);
- finally
- SelectObject(MemDC, OldBitmap);
- DeleteDC(MemDC);
- DeleteObject(MemBitmap);
- end;
- end;}
- procedure TSkinTab.DrawControl( dc:HDC; rc:TRect);
- var i,j,n,m,bw,w,h,x,y,truerect:integer;
- rt,r1,r2,r3,r4:Trect;
- item: TC_ITEM;
- s:string;
- b: boolean;
- acolor:Tcolor;
- TCItemW: TTCItemW;
- TCItem: TTCItem;
- Buffer: array[0.._maxcaption-1] of Char;
- imglist:Himagelist;
- bfont,cfont:Hfont;
- wnd:Thandle;
- ws:widestring;
- isTabcontrol:boolean;
- begin
- b:=(fsd.tab<>nil) and (not fsd.tab.map.empty);
- rt:=rc;
- SendMessage( hWnd, TCM_ADJUSTRECT, 0, integer(@RT) );
- InflateRect( rt, 4, 4 );
- m:= sendmessage(hwnd,TCM_GETITEMCOUNT,0,0);
- n:= sendmessage(hwnd,TCM_GETCURFOCUS,0,0);
- sendmessage(hwnd,TCM_GETITEMRECT,n,integer(@r1));
- imglist:=sendmessage(hwnd,TCM_GETIMAGELIST,0,0);
- case position of
- sttop: inc(rt.top,1);
- stbottom: dec(rt.bottom,1);
- stleft: inc(rt.left,1);
- stright: dec(rt.right,1);
- end;
- setlength(closerect,m);
- if b then begin
- //tab area
- case position of
- sttop: r2:=rect(rc.left,rc.top,rc.right,rt.top);
- stbottom: r2:=rect(rc.left,rt.bottom,rc.right,rc.bottom);
- stleft: r2:=rect(rc.left,rc.top,rt.left,rc.bottom);
- stright: r2:=rect(rt.right,rc.top,rc.right,rc.bottom);
- end;
- if position in [sttop,stbottom] then begin
- w:=r2.right-r2.left;
- h:=r2.bottom-r2.top;
- end else begin
- h:=r2.right-r2.left;
- w:=r2.bottom-r2.top;
- end;
- Drawtemp.width:=w;
- Drawtemp.height:=h;
- fillparentbg(Drawtemp.canvas.handle,rect(0,0,w,h));
- // fillbg(Drawtemp.canvas.handle,rect(0,0,w,h));
- // Drawtemp.canvas.Font.Color := fsd.colors[csButtonText];
- bfont:=sendmessage(hwnd,wm_getfont,0,0);
- cfont := selectobject(drawtemp.canvas.handle,bfont);
- for i:= 0 to m-1 do begin
- if unicode then begin
- TCItemW.mask := TCIF_IMAGE or TCIF_STATE or TCIF_TEXT ;
- TCItemW.pszText := Pwidechar(@buffer);
- TCItemW.cchTextMax := _maxcaption;
- SendMessage(Hwnd,TCM_GETITEMW, I,Longint(@TCItemW));
- ws:=_Wstr(TCItemW.pszText,-1);
- end else begin
- TCItem.mask := TCIF_IMAGE or TCIF_STATE or TCIF_TEXT ;
- TCItem.pszText := Pchar(@buffer);
- TCItem.cchTextMax := _maxcaption;
- SendMessage(Hwnd,TCM_GETITEM, I,Longint(@TCItem));
- ws:=StrToWideStr(buffer);
- end;
- TrueRect:=sendmessage(hwnd,TCM_GETITEMRECT,i,integer(@r1));
- if TrueRect=0 then continue;
- case position of
- sttop: offsetrect(r1,0,1);
- stbottom: offsetrect(r1,0,-rt.bottom-1);
- stleft: r1:=rect(w-r1.bottom,r1.left,w-r1.top,r1.right);
- stright: r1:=rect(r1.top-1,rc.right-r1.right,r1.bottom-1,rc.right-r1.left);
- end;
- if i<>n then j:=1 else j:=2;
- drawitem(Drawtemp.canvas.handle,r1,j);
- if showclose then
- drawCloseBtn(r1,i);
- if (position=sttop) or (position=stbottom) then
- selectobject(drawtemp.canvas.handle,bfont);
- if (j=1) then
- SetTextColor(Drawtemp.canvas.handle,ColorToRGB(fsd.tab.normalcolor2));
- if (j=2) then
- SetTextColor(Drawtemp.canvas.handle,ColorToRGB(fsd.tab.overcolor2));
- if unicode then
- DrawImgCaption(Drawtemp.canvas,r1,imglist,TCItemW.iImage,ws)
- else
- DrawImgCaption(Drawtemp.canvas,r1,imglist,TCItem.iImage,ws);
- // DrawImgCaption(Drawtemp.canvas,r1,imglist,TCItem.iImage,ws);
- end; //end for
- selectobject(drawtemp.canvas.handle,cfont);
- if position=stright then
- Drehen90Grad(drawtemp)
- else if position=stleft then
- Drehen270Grad(drawtemp);
- if FindScroll then begin
- clipUpdown(dc,r2);
- end else begin
- BitBlt(dc,r2.left,r2.top,r2.right,r2.bottom,
- drawtemp.Canvas.Handle ,0 ,0 ,SrcCopy);
- end;
- end;
- if (borderbmp.Empty) then exit;
- // istabcontrol := (control<>nil) and (control is Tpagecontrol);
- if (fsd.tab.style=0) then begin
- try
- //DrawBorder(Dc,rt,borderbmp,rect(4,5,4,2),1,1);
- DrawRect2(Dc,rt,borderbmp,rect(4,5,4,4),1,1);
- except
- end;
- end else begin
- DrawRect2(Dc,rt,borderbmp,fsd.TabSheet.r,1,1);
- // DrawBorder(Dc,rt,borderbmp,fsd.TabSheet.r,1,1);
- end;
- //paint control of TTabsheet
- if (control<>nil) and (kind=2) then
- TAcWincontrol(control).PaintControls(dc,nil);
- end;
- procedure TSkinTab.ClipUpdown(dc:HDC;rc:Trect);
- var r1,r2:Trect;
- MyRgn : hRgn;
- begin
- getwindowrect(updown.hwnd,r1);
- getwindowrect(hwnd,r2);
- offsetrect(r1,-r2.left,-r2.top);
- offsetrect(r2,-r2.left,-r2.top);
- MyRgn:=CreateRectRgn(0,0,r2.right,r2.bottom);
- SelectClipRgn(dc, MyRgn);
- ExcludeClipRect(dc,r1.left,r1.top,r1.right,r1.bottom);
- BitBlt(dc,rc.left,rc.top,rc.right,rc.bottom,
- drawtemp.Canvas.Handle ,0 ,0 ,SrcCopy);
- SelectClipRgn(dc, 0);
- DeleteObject(MyRgn);
- end;
- procedure TSkinTab.drawitem( dc:HDC; rc:TRect;I:integer);
- var temp:TBitmap;
- begin
- DrawRect2(DC,rc,tabbmp,fsd.tab.r,i,fsd.tab.frame,
- fsd.tab.trans,fsd.tab.tile);
- end;
- procedure TSkinTab.drawCloseBtn(rc:TRect;i:integer);
- var x,y,bw:integer;
- Acanvas:TCanvas;
- begin
- bw := 6;
- x:= rc.Right-bw-2;
- y:= rc.Top+2;
- acanvas:=Drawtemp.Canvas;
- //acanvas.Pen.Color:=fsd.colors[csButtonShadow] ;
- ACanvas.MoveTo(X, Y);
- ACanvas.LineTo(X+bw, Y);
- ACanvas.LineTo(X+bw, Y+bw);
- ACanvas.LineTo(X, Y+bw);
- ACanvas.LineTo(X, Y);
- ACanvas.LineTo(X+bw, Y+bw);
- ACanvas.MoveTo(X + bw, Y );
- ACanvas.LineTo(X , Y + bw);
- closerect[i] := rect(x,y,x+bw,y+bw);
- end;
- constructor TSkinTab31.Create(AOwner: TComponent);
- begin
- inherited create(aowner);
- tabbmp:=Tbitmap.create;
- end;
- destructor TSkinTab31.Destroy;
- begin
- tabbmp.free;
- inherited destroy;
- end;
- type
- TAcTabset = class(TTabset);
- Procedure TSkinTab31.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- begin
- control:=Twincontrol(owner);
- hwnd:=control.handle;
- inherited inithwnd(hwnd,sd,acanvas,sf);
- inittab;
- if control.Components[0] is Tscroller then begin
- scroller:= TwinControl(control.Components[0]);
- updown:=Tskinupdown.create(self.owner);
- updown.dir:=1;
- updown.inithwnd( scroller.handle,sd,acanvas,skinform);
- end;
- end;
- function TSkinTab31.BeforeProc(var Message: TMessage):boolean;
- var r:Trect;
- begin
- result:=true;
- case message.msg of
- WM_ERASEBKGND: begin
- // GetClientRect(hwnd,r);
- // FillRect( message.wparam,r,fsd.BGbrush);
- message.result:=1;
- result:=false;
- end;
- WM_Paint : begin
- wmpaint(message);
- //result:=false;
- end;
- else result:=inherited BeforeProc(message);
- end;
- end;
- Procedure TSkinTab31.inittab;
- begin
- // tabbmp.assign(nil);
- if (fsd.tab<>nil) and (not fsd.tab.map.empty) then begin
- // tabbmp.assign(fsd.tab.map);
- CopyBMP(fsd.tab.Map,tabbmp);
- SpiegelnVertikal(tabbmp);
- end;
- end;
- Procedure TSkinTab31.SkinChange;
- begin
- inherited skinchange;
- inittab;
- end;
- procedure TSkinTab31.DrawControl( dc:HDC; rc:TRect);
- const
- EdgeWidth = 9; { This controls the angle of the tab edges }
- var i,j,n,m,start,stop,w:integer;
- rt,r1:Trect;
- drawtemp:Tbitmap;
- tabset:TAcTabset;
- begin
- if (fsd.tab=nil) or (fsd.tab.map.empty) then exit;
- drawtemp:=Tbitmap.create;
- tabset := TACTabset(control);
- rt:=rc;
- offsetrect(rt,-rt.left,-rt.Top);
- Drawtemp.width:=rt.right;
- Drawtemp.height:=rt.Bottom;
- fillbg(Drawtemp.canvas.handle,rt);
- Drawtemp.canvas.Font := tabset.canvas.font;
- m:= tabset.tabs.count;
- n:= tabset.tabindex;
- start:=tabset.startmargin;
- stop := rt.right-tabset.endmargin;
- for i:= tabset.FirstIndex to m-1 do begin
- if i<>n then j:=1 else j:=2;
- w:= drawtemp.canvas.TextWidth(tabset.Tabs[i]);
- w:= w+EdgeWidth;
- if (Scroller.visible and ((start+12+w)<=stop)) or
- (not Scroller.visible and ((Start+w) <= Stop)) then begin
- r1 := rect(start,0,start+w,rt.bottom);
- DrawRect2(drawtemp.canvas.handle,r1,tabbmp,fsd.tab.r,j,fsd.tab.frame,
- fsd.tab.trans,fsd.tab.tile);
- if (j=1) then
- SetTextColor(Drawtemp.canvas.handle,fsd.tab.normalcolor2);
- if (j=2) then
- SetTextColor(Drawtemp.canvas.handle,fsd.tab.overcolor2);
- DrawCaption(drawtemp.canvas,r1,tabset.Tabs[i],true,true);
- inc(start,w); { add to list }
- end;
- end;
- // if FindScroll then begin
- // clipUpdown(dc,r2);
- // end else begin
- BitBlt(dc,rc.left,rc.top,rc.right-rc.top,rc.bottom-rc.top,
- drawtemp.Canvas.Handle ,0 ,0 ,SrcCopy);
- // end;
- drawtemp.free;
- end;
- function TSkinCheckBox.BeforeProc(var Message: TMessage):boolean;
- begin
- result:=inherited beforeProc(message);
- case message.msg of
- wm_paint,wm_print:
- if kind = 1 then begin
- wmpaint(message);
- result:=false;
- end;
- WM_ERASEBKGND:
- if trans then begin
- WMERASEBKGND(message);
- message.Result:=1;
- result:=false;
- end ;
- end;
- end;
- procedure TSkinCheckBox.AfterProc(var Message: TMessage);
- begin
- case message.msg of
- WM_LBUTTONDOWN, WM_LBUTTONDBLCLK:
- Invalidate;
- BM_SETCHECK: begin
- state:=message.WParam+1;
- Invalidate;
- end;
- WM_LBUTTONUP:Invalidate;
- CM_BASE+208 :Invalidate; //LMD control CM_LMDAFTEREXIT
- // WM_USER+1011 :Invalidate;
- //CM_MOUSELEAVE,CM_MOUSEENTER: Invalidate;
- CM_EXIT:Invalidate; //TMS Control
- // WM_ERASEBKGND: if kind=0 then WMERASEBKGND(message);
- else inherited AfterProc(message);
- end;
- end;
- Procedure TSkinCheckBox.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- var s:string;
- begin
- inherited init(sf,sd,acanvas,acolor);
- state:=0;
- kind:=0;
- if control=nil then exit;
- if (fsd.Button=nil) or (fsd.button.checkmap.empty) then
- kind:=0
- else kind:=1;
- if (control.Tag=5555) or (xoTransparent in fsd.options) then
- trans:=true;
- end;
- procedure TSkinCheckBox.DrawControl( dc:HDC; rc:TRect);
- var cs,n,i,w,bs,w1,j,h:integer;
- oldmode:integer;
- dw:Dword;
- r,r1,r2:Trect;
- PropInfo:PPropInfo;
- s:string;
- cState: TCheckBoxState;
- bfont,cfont:Hfont;
- oldc :COLORREF;
- begin
- if (fsd.Button=nil) or (fsd.button.checkmap.empty) then begin
- kind:=0;
- // if control<>nil then control.Invalidate;
- exit;
- end;
- n:= fsd.button.checkframe;
- w:= fsd.button.checkmap.width div n;
- cs:= fsd.button.checkmap.height;
- //w1:=GetSystemMetrics(SM_CXMENUCHECK);
- if w<15 then w1:=w
- else w1 := w;
- // w1:=15;
- bs:=sendmessage(hwnd,BM_GETSTATE,0,0);
- i:=1;
- if (bs and BST_CHECKED)=BST_CHECKED then i:=2;
- // else if (bs and BST_UNCHECKED)=BST_UNCHECKED then i:=1;
- if (control<>nil) then begin
- PropInfo:=GetPropInfo(control,'State');
- if PropInfo<>nil then begin
- s:=lowercase(GetEnumProp(control,PropInfo));
- if pos('uncheck',s)>0 then i:=1
- else if pos('check',s)>0 then i:=2
- else if pos('gray',s)>0 then i:=4;
- end else begin
- PropInfo:=GetPropInfo(control,'Checked');
- if PropInfo<>nil then begin
- s:=lowercase(GetEnumProp(control,PropInfo));
- if s='true' then i:=2
- else i:=3;
- end;
- end;
- PropInfo:=GetPropInfo(control,'DataField');
- if (PropInfo<>nil) and (state<>0) then begin
- i:=state;
- if state=3 then i:=4
- end;
- PropInfo:=GetPropInfo(control,'DataBinding');
- if (PropInfo<>nil) then begin
- i:=1;
- end;
- end;
- dw:=GetWindowLong(hWnd,GWL_STYLE) ;
- if ((dw and WS_DISABLED)>0) then i:=i+2;
- if (bs and BST_INDETERMINATE)=BST_INDETERMINATE then i:=4;
- if n=12 then begin
- j:=i;
- case j of
- 2: i:=5;
- 3: i:=4;
- 4: i:=8;
- end;
- if (bs and BST_INDETERMINATE)=BST_INDETERMINATE then begin
- if ((dw and WS_DISABLED)>0) then i:=12
- else i:=9;
- end;
- end;
- r.top := rc.top + ( rc.bottom-rc.top- cs ) div 2;
- r.bottom := r.top+cs;
- r1:=rc;
- r2:=rc;
- if (dw and BS_LEFTTEXT)=0 then begin
- // if w>14 then r.left:=rc.left +2
- // else r.left:=rc.left+(14-w) div 2 +1;
- r.left:=rc.left;
- r.right:=r.left+w1;
- //r1.Right:=r1.Left+w1+1;
- r2.Left := r.Right+2;
- dw := DT_Left;
- if (control<>nil) and (control.BiDiMode = bdRighttoLeft) then
- dw := dw or dt_RtlReading;
- end else begin
- //if w>15 then r.right:=rc.right-1
- //else r.right:=rc.right-(15-w) div 2;
- r.right:=rc.right ;
- r.left:=r.right-w1;
- // r1.left:=r1.right-w1-3;
- r2.Right:=r.Left-2;
- if (control<>nil) and (control.BiDiMode=bdRightToLeft) then
- dw := DT_Right or dt_RtlReading
- else dw := DT_Left;
- end;
- dw := dw or DT_EXPANDTABS or dt_WordBreak;
- if (kind=1) and (not trans) then begin
- fillBG(dc,rc);
- end ;
- DrawSkinMap2(dc,r,fsd.button.checkmap,i,N);
- if kind=0 then exit;
-
- caption:=getformcaption(hwnd);
- if (control<>nil) then begin
- caption := GetStringProp(control,'Caption');
- end else
- caption:=getformcaption(hwnd);
- bfont:=sendmessage(hwnd,wm_getfont,0,0);
- if (control<>nil) then begin
- bfont := Taccontrol(control).font.Handle;
- if control.Enabled then
- oldc:=settextcolor(dc,ColorToRGB(Taccontrol(control).font.Color))
- else
- oldc := SetTextColor(dc,ColorToRGB(clBtnShadow));
- end;
- cfont:=selectobject(dc,bfont);
- oldcolor := setbkcolor(dc,fsd.colors[csButtonFace]);
- OldMode := SetBkMode(dc, TRANSPARENT);
- // h:=TextHeight(dc,'0');
- // offsetrect(r2,0, (r2.Bottom-r2.Top-h) div 2);
- r1:=r2;
- Tnt_DrawTextW(dc, caption,r1,dw or DT_CALCRECT or DT_NOCLIP);
- offsetrect(r2,0, (r2.Bottom-r2.Top-r1.bottom) div 2);
- // if not control.Enabled then
- if (GetFocus= hWnd) and (length(caption)>0) and isvista then
- DrawFocus(dc,caption,r2,dw);
- Tnt_DrawTextW(dc,caption,r2,dw );
- SetBkMode(dc, OldMode);
- SetTextColor(dc,oldc);
- setbkcolor(dc,oldcolor);
- selectobject(dc,cfont);
- end;
- procedure TSkinRadioButton.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- var s:string;
- begin
- inherited init(sf,sd,acanvas,acolor);
- kind :=0;
- if control=nil then exit;
- if (fsd.Button=nil) or (fsd.button.radiomap.empty) then
- kind:=0
- else kind:=1;
- if (control.Tag=5555) or (xoTransparent in fsd.options) then
- trans:=true;
- end;
- procedure TSkinRadioButton.AfterProc(var Message: TMessage);
- begin
- case message.msg of
- WM_LBUTTONDOWN, WM_LBUTTONDBLCLK: Invalidate;
- WM_LBUTTONUP:Invalidate;
- BM_SETCHECK: Invalidate;
- CM_BASE+208 :Invalidate; //LMD control CM_LMDAFTEREXIT
- CM_EXIT:
- Invalidate; //TMS Control
- // WM_ERASEBKGND:
- // if kind=0 then WMERASEBKGND(message);
- else inherited AfterProc(message);
- end;
- end;
- function TSkinRadioButton.BeforeProc(var Message: TMessage):boolean;
- begin
- result:=inherited beforeProc(message);
- case message.msg of
- wm_paint,wm_print:// begin
- if kind=1 then begin
- wmpaint(message);
- result:=false;
- end;
- WM_ERASEBKGND:
- if trans then begin
- WMERASEBKGND(message);
- message.Result:=1;
- result:=false;
- end ;
- // else inherited beforeProc(message);
- end;
- end;
- procedure TSkinRadioButton.DrawControl( dc:HDC; rc:TRect);
- var cs,n,i,w,w1,j,h:integer;
- oldmode:integer;
- r,r1,r2:Trect;
- bs:integer;
- dw:Dword;
- PropInfo:PPropInfo;
- s:string;
- bfont,cfont:Hfont;
- oldc :COLORREF;
- begin
- if (fsd.Button=nil) or (fsd.button.radiomap.empty) then begin
- kind:=0;
- // if control<>nil then control.Invalidate;
- exit;
- end;
- n:= fsd.button.radioframe;
- w:= fsd.button.radiomap.width div n;
- cs:= fsd.button.radiomap.height;
- //w1:=GetSystemMetrics(SM_CXMENUCHECK);
- if w<15 then w1:=w
- else w1:=w;
-
- i:=1;
- bs:=sendmessage(hwnd,BM_GETCHECK,0,0);
- if (bs and BST_CHECKED)=BST_CHECKED then i:=2
- else if (bs and BST_UNCHECKED)=BST_UNCHECKED then i:=1;
- r1:=rc;
- if control<>nil then begin
- PropInfo:=GetPropInfo(control,'Checked');
- if PropInfo<>nil then begin
- s:=lowercase(GetEnumProp(control,PropInfo));
- if s='true' then i:=2
- else i:=1;
- end;
- end;
- dw:=GetWindowLong(hWnd,GWL_STYLE) ;
- if (dw and WS_DISABLED)>0 then i:=i+2;
- if n=8 then begin
- j:=i;
- case j of
- 2: i:=5;
- 3: i:=4;
- 4: i:=8;
- end;
- end;
- r.top := rc.top + ( rc.bottom-rc.top- cs ) div 2;
- r.bottom := r.top+cs;
- r2:=rc;
- if (dw and BS_LEFTTEXT)=0 then begin
- {if w>14 then r.left:=rc.left
- else r.left:=rc.left+(14-w) div 2;}
- r.Left := rc.Left;
- r.right:=r.left+w1;
- //r1.right:=r1.left+w1+1;
- dw := DT_Left ;
- r2.Left := r.Right+2;
- if (control<>nil) and (control.BiDiMode = bdRightToLeft) then
- dw := dw or dt_RtlReading;
- end else begin
- {if w>14 then r.right:=rc.right-1
- else r.right:=rc.right-(14-w) div 2;}
- r.Right := rc.Right-1;
- r.left:=r.right-w1;
- //r1.left:=r1.right-w1-3;
- if (control<>nil) and (control.BiDiMode=bdRightToLeft) then
- dw := DT_Right or dt_RtlReading
- else dw := DT_Left;
- {if control.BiDiMode = bdLeftToRight then
- dw := DT_Left
- else dw := DT_Right or dt_RtlReading;}
- r2.Right := r.left-2;
- end;
- dw := dw or DT_EXPANDTABS or dt_WordBreak;
- if (kind=1) and (not trans) then begin
- fillBG(dc,rc);
- end ;
- DrawSkinMap2(dc,r,fsd.button.radiomap,i,N);
- if kind=0 then exit;
-
- caption:=getformcaption(hwnd);
- if (control<>nil) then begin
- caption := GetStringProp(control,'Caption');
- end;
- bfont:=sendmessage(hwnd,wm_getfont,0,0);
- if (control<>nil) then begin
- bfont := Taccontrol(control).font.Handle;
- if control.Enabled then
- oldc:=settextcolor(dc,ColorToRGB(Taccontrol(control).font.Color))
- else
- oldc := SetTextColor(dc,ColorToRGB(clBtnShadow));
- end;
- cfont:=selectobject(dc,bfont);
- oldcolor := setbkcolor(dc,fsd.colors[csButtonFace]);
- OldMode := SetBkMode(dc, TRANSPARENT);
- r1:=r2;
- Tnt_DrawTextW(dc, caption,r1,dw or DT_CALCRECT or DT_NOCLIP);
- offsetrect(r2,0, (r2.Bottom-r2.Top-r1.bottom) div 2);
- if (GetFocus= hWnd) and (length(caption)>0) and isvista then
- DrawFocus(dc,caption,r2,dw);
- Tnt_DrawTextW(dc,caption,r2,dw);
- SetBkMode(dc, oldmode);
- SetTextColor(dc,oldc);
- setbkcolor(dc,oldcolor);
- selectobject(dc,cfont);
- end;
- procedure TSkinTrackBar.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- begin
- inherited Init(sf,sd,acanvas,acolor);
- //caused pagecontrol flicker
- // skinchange;
- end;
- procedure TSkinTrackBar.Skinchange;
- var h:Thandle;
- begin
- h := setfocus(hwnd);
- if h<>hwnd then setfocus(h);
- end;
- procedure TSkinTrackBar.Unsubclass;
- begin
- inherited unsubclass;
- // skinchange;
- end;
- function TSkinTrackBar.BeforeProc(var Message: TMessage):boolean;
- begin
- result:=true;
- case message.msg of
- {WM_ERASEBKGND: begin
- message.result:=1;
- result:=false;
- end; }
- WM_Notify,CN_NOTIFY : begin
- if TWMNotify(message).NMHdr^.code=NM_CUSTOMDRAW then begin
- message.Result:=CustomDraw(PNMCustomDraw(message.lParam));
- result:=false;
- end;
- end;
- else result:=inherited BeforeProc(message);
- end;
- end;
- function TSkinTrackBar.CustomDraw(PDraw:PNMCustomDraw):integer;
- var r:Trect;
- begin
- case Pdraw^.dwDrawStage of
- {CDDS_POSTERASE:begin
- GetClientRect(hwnd,r);
- fillBG(pdraw^.hdc,r);
- result:=CDRF_SKIPDEFAULT;
- end; }
- CDDS_PREPAINT :
- result:=CDRF_NOTIFYITEMDRAW;
- CDDS_ITEMPREPAINT : begin
- case Pdraw^.dwItemSpec of
- TBCD_TICS: result:=CDRF_DODEFAULT;
- TBCD_THUMB : begin
- Drawthumb(pdraw);
- result:=CDRF_SKIPDEFAULT;// CDRF_DODEFAULT;
- end;
- TBCD_CHANNEL : begin
- DrawTrack(pdraw);
- result:=CDRF_SKIPDEFAULT;//CDRF_DODEFAULT;
- end;
- end;
- end;
- end;
- end;
- procedure TSkinTrackBar.DrawTrack(PDraw:PNMCustomDraw);
- var r,dst,src:TRect;
- bmp:Tbitmap;
- w,h,x,y:integer;
- dwstyle : dword;
- dc:HDC;
- begin
- sendmessage(hwnd,TBM_GETCHANNELRECT,0,integer(@r));
- dwstyle:= GetWindowLong(hWnd,GWL_STYLE);
- dc:= pdraw^.hdc;
- if ((dwstyle and TBS_VERT)>0) and (fsd.trackbarvert<>nil) then begin
- dst := rect(r.top,r.Left,r.Bottom,r.Right);
- src := fsd.TrackBarVert.r;
- bmp:= fsd.TrackBarVert.map;
- w:=bmp.Width;
- h:=bmp.Height;
- if bmp.Width<(dst.Right-dst.Left) then
- x:= (dst.Right-dst.Left-bmp.Width) div 2
- else x:=0;
- // DrawRectV(pdraw^.hdc,r,fsd.TrackBarVert.map,fsd.TrackBarVert.r,1,1);
- StretchBlt(dc,dst.Left+x,dst.Top,w,src.Top,
- bmp.canvas.handle,0,0,w,src.Top,SRCCOPY);
- StretchBlt(dc,dst.Left+x,dst.Top+src.Top,w,dst.Bottom-dst.Top-src.Top-src.Bottom,
- bmp.canvas.handle,0,src.Top,w,h-src.Top-src.Bottom,SRCCOPY);
- StretchBlt(dc,dst.Left+x,dst.Bottom-src.Bottom,w,src.Bottom,
- bmp.canvas.handle,0,y+h-src.Bottom,w,src.Bottom,SRCCOPY);
- end else if (fsd.trackbar<>nil) then begin
- dst := r;
- src := fsd.TrackBar.r;
- bmp:= fsd.TrackBar.map;
- w:=bmp.Width;
- h:=bmp.Height;
- if h<(dst.bottom-dst.top) then
- y:= (dst.bottom-dst.top) div 2
- else y:=0;
- //DrawRectH(pdraw^.hdc,r,fsd.TrackBar.map,fsd.TrackBar.r,1,1);
- StretchBlt(dc,dst.Left,dst.Top+y,src.Left,h,
- bmp.canvas.handle,0,0,src.Left,h,SRCCOPY);
- StretchBlt(dc,dst.Left+src.Left,dst.Top+y,dst.Right-dst.Left-src.Left-src.Right,h,
- bmp.canvas.handle,src.Left,0,w-src.Left-src.Right,h,SRCCOPY);
- StretchBlt(dc,dst.Right-src.Right,dst.Top+y,src.Right,h,
- bmp.canvas.handle,w-src.Right,0,src.Right,h,SRCCOPY);
- end;
- end;
- {procedure TSkinTrackBar.Drawthumb(PDraw:PNMCustomDraw);
- var r:TRect;
- temp:Tbitmap;
- w,h,x:integer;
- adc:HDC;
- begin
- sendmessage(hwnd,TBM_GETTHUMBRECT,0,integer(@r));
- temp:=Tbitmap.create;
- w:=bmp.width div n;
- h:=bmp.height;
- temp.height:=rc.bottom-rc.top;
- temp.width:=rc.right-rc.left;
- x:=(i-1)*w;
- temp.canvas.copyrect( rect(0,0,rc.right-rc.left,rc.bottom-rc.top),
- bmp.canvas,rect(x,0,x+w,h));
- adc:= fcanvas.handle;
- fcanvas.handle:=dc;
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- // temp.Transparentcolor:=temp.Canvas.Pixels[0, 0];
- fcanvas.draw(rc.left,rc.top,temp);
- temp.free;
- fcanvas.handle:=adc;
- end; }
- procedure TSkinTrackBar.Drawthumb(PDraw:PNMCustomDraw);
- var r:TRect;
- acolor:Tcolor;
- temp:Tbitmap;
- dwstyle : dword;
- ftemp:Tcanvas;
- begin
- if (not IsWindow(hwnd)) then begin
- exit;
- if control<>nil then
- hwnd := control.handle
- else Exit;
- end;
- dwstyle:= GetWindowLong(hWnd,GWL_STYLE);
- sendmessage(hwnd,TBM_GETTHUMBRECT,0,integer(@r));
- temp:=nil;
- if ((dwstyle and TBS_VERT)>0) and (fsd.trackvert<>nil) then
- temp := fsd.TrackVert.Map
- else if (fsd.trackhorz<>nil) then
- temp := fsd.TrackHorz.Map;
- if temp<>nil then begin
- DrawSkinMap1(pdraw^.hdc,r,temp,2,5)
- end else begin
- ftemp:=Tcanvas.create;
- ftemp.Handle := pdraw^.hdc;
- ftemp.pen.color:=fsd.colors[csButtonShadow];
- ftemp.Rectangle(r);
- ftemp.free;
- end;
- end;
- Procedure TSkinToolbar.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- var c0:Tcolor;
- begin
- inherited init(sf,sd,acanvas,acolor);
- c0 := fsd.GetCaptionColor();
- gradCol1:= Blend(clgray,c0, 150) ;
- gradCol2:= Blend(fsd.colors[csButtonFace],clwhite, 150) ;
- end;
- function TSkinToolbar.BeforeProc(var Message: TMessage):boolean;
- begin
- result:=true;
- case message.msg of
- WM_ERASEBKGND: begin
- ERASEBKGND(message);
- message.result:=1;
- result:=false;
- end;
- WM_Notify,CN_NOTIFY : begin
- { if TWMNotify(message).NMHdr^.code=NM_CUSTOMDRAW then begin
- message.Result:=CustomDraw(PNMCustomDraw(message.lParam));
- result:=false;
- end; }
- end;
- else result:=inherited BeforeProc(message);
- end;
- end;
- procedure TSkinToolbar.ERASEBKGND(msg:Tmessage);
- var Brush: HBrush;
- r:Trect;
- old:integer;
- begin
- GetClientRect(hwnd,r);
- if fsd.Toolbar<>nil then begin
- old:=SetStretchBltMode(msg.WParam,STRETCH_DELETESCANS);
- StretchBlt(msg.WParam,r.left,r.top,r.right-r.left,r.bottom-r.top,
- fsd.Toolbar.map.canvas.handle,0,0,fsd.Toolbar.map.Width,fsd.Toolbar.map.Height,SRCCOPY);
- SetStretchBltMode(msg.WParam,old);
- end else
- GradFill(msg.WParam,r,gradCol2,gradCol1);
- end;
- procedure TSkinUpDown.DrawBackGround(msg:Tmessage);
- var Brush: HBrush;
- r:Trect;
- begin
- if control=nil then begin
- GetClientRect(hwnd,r);
- Brush := CreateSolidBrush(clwhite);
- fillrect(msg.wparam,r,brush);
- DeleteObject(Brush);
- end;
- end;
- function TSkinUpDown.BeforeProc(var Message: TMessage):boolean;
- begin
- result:=true;
- case message.msg of
- WM_LBUTTONDOWN, WM_LBUTTONDBLCLK: begin
- default(message);
- state:=state+[scDown];
- PaintControl;
- result:=false;
- end;
- WM_LBUTTONUP: begin
- state:=state-[scDown];
- default(message);
- PaintControl;
- result:=false;
- end;
- WM_ERASEBKGND: begin
- DrawBackGround(message);
- message.result:=1;
- result:=false;
- end;
- WM_Paint : begin
- wmpaint(message);
- result:=false;
- end;
- else result:=inherited BeforeProc(message);
- end;
- end;
- function TSkinProgress.BeforeProc(var Message: TMessage):boolean;
- begin
- {$IFDEF progress}
- result:=true;
- case message.msg of
- WM_ERASEBKGND: begin
- message.result:=1;
- result:=false;
- end;
- WM_Paint : begin
- if (fsd.Progress<>nil) and (not fsd.progress.map.empty) then begin
- wmpaint(message);
- message.result:=0;
- result:=false;
- end;
- end;
- else result:=inherited BeforeProc(message);
- end;
- {$ELSE}
- result:=inherited BeforeProc(message);
- {$ENDIF}
- end;
- procedure TSkinUpDown.DrawControl( dc:HDC; rc:TRect);
- var r,r1,r2:Trect;
- p: TPoint;
- h,i,l: integer;
- temp:Tbitmap;
- dwstyle:dword;
- b:boolean;
- Brush: HBrush;
- phwnd:Thandle;
- begin
- //getclientrect(hwnd,r1);
- if inedit then begin
- //GetWindowRect(hwnd,r);
- //offsetrect(r,-r.Left,-r.Right);
- getclientrect(hwnd,r);
- Brush := CreateSolidBrush(clwhite);
- fillrect(dc,r,brush);
- DeleteObject(Brush);
- // InflateRect(rc,-1,-1);
- phwnd:=getparent(hwnd);
- getwindowrect(phwnd,r2);
- getwindowrect(hwnd,r1);
- if (r1.Top-r2.Top)<3 then inc(rc.Top,3-(r1.Top-r2.Top));
- if (r2.Bottom-r1.Bottom)<3 then dec(rc.Bottom,3-(r2.Bottom-r1.Bottom));
- if (r2.right-r1.Right)<3 then dec(rc.Right,3-(r2.right-r1.Right));
- end;
- r1:=rc;
- offsetrect(r1,-r1.Left,-r1.Top);
- r2:=r1;
- temp:=Tbitmap.create;
- temp.width:=r1.right;
- temp.height:=r1.bottom;
- temp.canvas.brush.color:=fsd.colors[csButtonFace];
- temp.canvas.fillrect(rect(0,0,r1.right,r1.bottom));
- GetCursorPos(p);
- ScreenToClient(hwnd,p);
- dwstyle:= GetWindowLong(hWnd,GWL_STYLE);
- enabled := (dwstyle and WS_DISABLED)=0;
- i:=1;
- b:= (dwstyle and UDS_HORZ )=0;
- if dir=1 then b:=false;
- if b then begin //vert
- h := (r1.Bottom - r1.Top) div 2;
- if (p.Y < H) then begin
- if (scDown in state) then i:=2
- else if (scMouseIn in state) then i:=4;
- end;
- if not enabled then i:=3;
- r:=rect(r1.left,r1.top,r1.right,r1.top+h);
- // b:=(fsd.VSpin<>nil) and (not fsd.VSpin.MaskMap.empty);
- b:=(fsd.VSpin<>nil) ;
- if b then
- DrawSkinButton(temp.canvas.handle,r,i,0)
- else
- DrawButton(temp.canvas,r,i,0);
- i:=1;
- if (p.Y >=H) then begin
- if (scDown in state) then i:=2
- else if (scMouseIn in state) then i:=4;
- end;
- if not enabled then i:=3;
- r:=rect(r1.left,r1.top+h,r1.right,r1.bottom);
- if b then
- DrawSkinButton(temp.canvas.handle,r,i,1)
- else
- DrawButton(temp.canvas,r,i,1);
- end else begin
- h := (r1.right - r1.left) div 2;
- if (p.x < H) then begin
- if (scDown in state) then i:=2
- else if (scMouseIn in state) then i:=4;
- end;
- if not enabled then i:=3;
- r:=rect(r1.left,r1.top,r1.left+h,r1.bottom);
- // b:=(fsd.HSpin<>nil) and (not fsd.HSpin.MaskMap.empty);
- b:=(fsd.HSpin<>nil);
- if b then
- DrawSkinButton(temp.canvas.handle,r,i,2)
- else
- DrawButton(temp.canvas,r,i,2);
- i:=1;
- if (p.x >=H) then begin
- if (scDown in state) then i:=2
- else if (scMouseIn in state) then i:=4;
- end;
- if not enabled then i:=3;
- r:=rect(r1.left+h,r1.top,r1.right,r1.bottom);
- if b then DrawSkinButton(temp.canvas.handle,r,i,3)
- else
- DrawButton(temp.canvas,r,i,3);
- end;
- BitBlt(dc,rc.left,rc.top,r1.right,r1.bottom,
- temp.Canvas.Handle ,0 ,0 ,SrcCopy);
- temp.free;
- end;
- procedure TSkinUpDown.DrawSkinButton(dc:HDC;rc:TRect;n,ar:integer);
- var i,w,h:integer;
- r1:Trect;
- begin
- if ar>1 then begin
- i:= (ar-2)*4+n;
- DrawRect1( dc,rc,fsd.HSpin.map,i,fsd.HSpin.frame,1);
- if not fsd.HSpin.MaskMap.empty then begin
- w:= fsd.HSpin.MaskMap.Width div fsd.HSpin.frame;
- r1.Left:= rc.left+(rc.Right-rc.Left - w ) div 2;
- r1.Top := rc.Top+(rc.Bottom-rc.Top - fsd.HSpin.MaskMap.height) div 2;
- r1.right := r1.left+w;
- r1.Bottom := r1.Top + fsd.HSpin.MaskMap.height;
- DrawRect1( dc,r1,fsd.HSpin.maskmap,i,fsd.HSpin.frame,1);
- end;
- end else begin
- i:= ar*4+n;
- // DrawSkinMap2( dc,rc,fsd.VSpin.map,i,fsd.VSpin.frame);
- DrawRect1(DC,rc,fsd.VSpin.map,i,fsd.VSpin.frame,1);
- if not fsd.VSpin.MaskMap.empty then begin
- w:= fsd.VSpin.MaskMap.Width div fsd.VSpin.frame;
- // if
- r1.Left:= rc.left+(rc.Right-rc.Left - w ) div 2;
- r1.Top := rc.Top+(rc.Bottom-rc.Top - fsd.VSpin.MaskMap.height) div 2;
- r1.right := r1.left+w;
- r1.Bottom := r1.Top + fsd.VSpin.MaskMap.height;
- DrawRect1( dc,r1,fsd.VSpin.maskmap,i,fsd.VSpin.frame,1);
- end;
- end;
- end;
- procedure TSkinUpDown.DrawButton(acanvas:Tcanvas;rc:TRect;n,ar:integer);
- var hb,ob:Hbrush;
- adc:HDC;
- begin
- case n of
- 1: acanvas.brush.color:=fsd.colors[csButtonFace];
- 2: acanvas.brush.color:=fsd.colors[csButtonShadow];
- 3: acanvas.brush.color:=fsd.colors[csButtonFace];
- 4: acanvas.brush.color:=fsd.colors[csButtonShadow];
- end;
- acanvas.pen.color:=fsd.colors[csButtonDkshadow];
- acanvas.Rectangle(rc);
- if ar<2 then
- DrawArrow(acanvas, rc.Left + ((rc.Right - rc.Left) div 2),
- rc.Top + ((rc.Bottom - rc.Top) div 2) -2, ar)
- else
- DrawArrow(acanvas, rc.Left + ((rc.Right - rc.Left) div 2),
- rc.Top + ((rc.Bottom - rc.Top) div 2) , ar)
- end;
- procedure TSkinProgress.DrawControl( dc:HDC; rc:TRect);
- var r,r1:Trect;
- pbmp,temp:TBitMap;
- // bmax,bpos:Int64;
- bmax,bpos,bmin:Integer;
- style:dword;
- begin
- if (fsd.Progress=nil) or fsd.progress.map.empty then exit;
- style := GetWindowLong(hWnd,GWL_STYLE);
- if (fsd.Progress.style=1) then begin
- DrawControl1( dc,rc);
- exit;
- end;
- pbmp:=Tbitmap.create;
- pbmp.PixelFormat:= pf24bit;
- // fcanvas.handle:=dc;
- r1:=rc;
- if (style and PBS_VERTICAL )>0 then
- r1:=Rect(0,0,rc.bottom-rc.top,rc.right-rc.left);
- pbmp.width:=r1.right;
- pbmp.height:=r1.bottom;
- pbmp.canvas.brush.color:=fsd.colors[csButtonFace];
- pbmp.canvas.fillrect(r1);
- temp:=GetHMap(r1,fsd.Progress.map,fsd.Progress.r,1,2,fsd.Progress.tile);
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- pbmp.canvas.draw(r1.left,r1.top,temp);
- temp.free;
- bpos:=sendmessage(hwnd,PBM_GETPOS,0,0);
- bmax:=sendmessage(hwnd,PBM_GETRANGE,0,0);
- bmin:=sendmessage(hwnd,PBM_GETRANGE,1,0);
- if (bmax>0) and (bpos>0) then begin
- r:=r1;
- // r.right:= r1.left+round((r1.right-r1.left)/bmax*bpos);
- r.right:= r1.left+MulDiv((r1.right-r1.left),(bpos-bmin), (bmax-bmin));
- if (r.right>r.left) then begin
- temp:=GetHMap(r,fsd.Progress.map,fsd.Progress.r,2,2,fsd.Progress.tile);
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- pbmp.canvas.draw(r1.left,r1.top,temp);
- temp.free;
- end;
- end;
- if (style and PBS_VERTICAL )>0 then
- Drehen270Grad(pbmp);
- // temp
- BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.Top,
- pbmp.Canvas.Handle ,0 ,0 ,Srccopy);
- pbmp.Free;
- end;
- {procedure TSkinProgress.DrawControl( dc:HDC; rc:TRect);
- var r,r1:Trect;
- pbmp,temp:TBitMap;
- bmax,bpos:integer;
- begin
- if (fsd.Progress=nil) or fsd.progress.map.empty then exit;
- if (fsd.Progress.style=1) then begin
- DrawControl1( dc,rc);
- exit;
- end;
- r:=rc;
- // fcanvas.handle:=dc;
- r1:=rc;
- bg.width:=r1.right;
- bg.height:=r1.bottom;
- bg.canvas.brush.color:=fsd.colors[csButtonFace];
- bg.canvas.fillrect(r1);
- temp:=GetHMap(rc,fsd.Progress.map,fsd.Progress.r,1,2,fsd.Progress.tile);
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- bg.canvas.draw(rc.left,rc.top,temp);
- temp.free;
- bpos:=sendmessage(hwnd,PBM_GETPOS,0,0);
- bmax:=sendmessage(hwnd,PBM_GETRANGE,0,0);
- if (bmax>0) and (bpos>0) then begin
- r.right:= rc.left+(rc.right-rc.left)*bpos div bmax;
- temp:=GetHMap(r,fsd.Progress.map,fsd.Progress.r,2,2,fsd.Progress.tile);
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- bg.canvas.draw(rc.left,rc.top,temp);
- temp.free;
- end;
- BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.Top,
- bg.Canvas.Handle ,0 ,0 ,Srccopy);
- end;}
- procedure TSkinProgress.DrawControl1( dc:HDC; rc:TRect);
- var r,r1:Trect;
- temp,pbmp:TBitMap;
- i,n,w,h,y,bmax,bpos:integer;
- style:dword;
- begin
- if (fsd.progressChunk=nil) or fsd.progressChunk.map.empty then exit;
- style := GetWindowLong(hWnd,GWL_STYLE);
- pbmp:=Tbitmap.create;
- pbmp.PixelFormat:= pf24bit;
- // fcanvas.handle:=dc;
- r1:=rc;
- if (style and PBS_VERTICAL )>0 then
- r1:=Rect(0,0,rc.bottom-rc.top,rc.right-rc.left);
- r:=r1;
- pbmp.width:=r1.right;
- pbmp.height:=r1.bottom;
- pbmp.canvas.brush.color:=fsd.colors[csButtonFace];
- pbmp.canvas.fillrect(r1);
- //always be strech
- temp:=GetHMap(r1,fsd.Progress.map,fsd.Progress.r,1,1,0);//fsd.Progress.tile);
- temp.Transparent:=true;
- temp.Transparentcolor:=clFuchsia;
- pbmp.canvas.draw(r1.left,r1.top,temp);
- // temp.free; // we use in trunck
- bpos:=sendmessage(hwnd,PBM_GETPOS,0,0);
- bmax:=sendmessage(hwnd,PBM_GETRANGE,0,0);
- if (bmax>0) and (bpos>0) then begin
- // r.right:= rc.left+(rc.right-rc.left)*bpos div bmax;
- r.right:= r1.left+MulDiv((r1.right-r1.left),bpos, bmax);
- h:= fsd.progressChunk.map.height;
- w:= fsd.progressChunk.map.width;
- y:= (r.Bottom-h) div 2;
- if fsd.ProgressChunk.tile=1 then begin
- temp.Width := r.Right-r.Left;
- temp.Height:= h;
- n:= (r.Right-r.Left) div w;
- for i:= 0 to n do begin
- temp.canvas.draw(i*w,0,fsd.progressChunk.map);
- end;
- pbmp.canvas.draw(2+fsd.progressChunk.r.left,rc.top+y,temp);
- end else begin
- temp.width:=r.right;
- temp.height:=r.bottom-4;
- drawrectH(temp.Canvas.Handle,r,fsd.progresschunk.Map,fsd.progresschunk.r,
- 1,1,fsd.progresschunk.Tile);
- pbmp.canvas.draw(2,2,temp);
- //r1:=rect(0,0,fsd.progressChunk.map.width,fsd.progressChunk.map.Height);
- //pbmp.canvas.copyrect(r,fsd.progressChunk.map.canvas,r1);
- end;
- end;
- if (style and PBS_VERTICAL )>0 then
- Drehen270Grad(pbmp);
- BitBlt(dc,rc.left ,rc.top,rc.right-rc.left,rc.bottom-rc.Top,
- pbmp.Canvas.Handle ,0 ,0 ,Srccopy);
- temp.free;
- pbmp.free;
- // fcanvas.handle:=dc;
- // fcanvas.draw(rc.left,rc.top,BG);
- end;
- {procedure TSkinEdit.Init(aControl:Twincontrol;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- begin
- inherited Init(acontrol,sd,acanvas,acolor);
- FindUPDown(hwnd,sd,acanvas);
- end;
- procedure TSkinEdit.inithwnd(ahwnd:Thandle;sd:TSkinData;acanvas:TCanvas);
- begin
- inherited Inithwnd(ahwnd,sd,acanvas);
- FindUPDown(ahwnd,sd,acanvas);
- end; }
- procedure TSkinEdit.AfterProc(var Message: TMessage);
- var BEMsg: TMessage;
- begin
- //inherited AfterProc(message);
- //exit;
- case message.msg of
- CM_BEPAINT: begin
- if Message.LParam = BE_ID then begin
- if Message.WParam <> 0 then begin
- BEMsg.Msg := WM_PAINT;
- BEMsg.WParam := Message.WParam;
- BEMsg.LParam := 0;
- Default(BEMsg);
- end;
- Message.Result := BE_ID;
- end;
- end;
- WM_Print:
- PaintControl1(message.WParam);
- WM_Paint: begin
- PaintControl(message.WParam);
- end;
- else inherited AfterProc(message);
- end;
- end;
- procedure TSkinEdit.FindUPDown(ahwnd:Thandle;sd:TSkinData;acanvas:TCanvas);
- var hctrl : Thandle;
- s:string;
- begin
- hCtrl := GetTopWindow( ahWnd );
- while ( hCtrl<>0 ) do begin
- s:= lowercase(getwindowclassname(hctrl));
- if (s='msctls_updown32') or (pos('spin',s)>0) or (pos('updown',s)>0) then begin
- updown:=Tskinupdown.create(self.owner);
- updown.inithwnd(hCtrl,sd,acanvas,skinform);
- updown.inedit:=true;
- break;
- end;
- hCtrl := GetNextWindow( hCtrl, GW_HWNDNEXT );
- end;
- end;
- {procedure TSkinEdit.DrawControl( dc:HDC; rc:TRect);
- var r,r1:Trect;
- acolor:Tcolor;
- s:string;
- begin
- if updown=nil then findupdown(hwnd,fsd,fcanvas);
- getclientrect(hwnd,r1);
- r:=rc;
- if (r.right=(r1.right-r1.left)) or
- (r.bottom=(r1.bottom-r1.top)) then exit;
- fcanvas.handle:=dc;
- fcanvas.brush.handle:=GetCurrentObject(dc,OBJ_BRUSH);
- InflateRect(rc,-1,-1);
- fcanvas.FrameRect(rc);
- if updown=nil then begin
- InflateRect(rc,-1,-1);
- fcanvas.FrameRect(rc);
- end;
- acolor:=fcanvas.brush.color;
- fcanvas.brush.color:=fsd.colors[csButtonShadow];
- fcanvas.FrameRect(r);
- fcanvas.brush.color:=acolor;
- end;}
- procedure TSkinEdit.DrawControl( dc:HDC; rc:TRect);
- var r,r1:Trect;
- acolor:Tcolor;
- c1:Tcolor;
- b1,b2:HBRUSH;
- s:string;
- begin
- if (xcSpin in Fsd.SkinControls) and (updown=nil) then findupdown(hwnd,fsd,fcanvas);
- getclientrect(hwnd,r1);
- r:=rc;
- if (r.right=(r1.right-r1.left)) or
- (r.bottom=(r1.bottom-r1.top)) then exit;
- r1:=rc;
- B1:=CreateSolidBrush(fsd.colors[csButtonShadow]);
- FrameRect(dc,r1,b1);
- c1:=clwhite;
- B2:=CreateSolidBrush(c1);
- InflateRect(r1,-1,-1);
- FrameRect(dc,r1,b2);
- InflateRect(r1,-1,-1);
- FrameRect(dc,r1,b2);
- // dec(r1.Bottom);
- // FrameRect(dc,r1,b2);
- deleteobject(B2);
- deleteobject(B1);
- end;
- procedure TSkinEdit.PaintControl1(adc:HDC=0);
- var dc:HDC ;
- rc:TRect;
- begin
- if GetWindowRect( hWnd, rc ) then begin;
- try
- boundsrect:=rc;
- OffsetRect( rc, -rc.left, -rc.top );
- if adc=0 then DC := GetWindowDC( hWnd )
- else dc:=adc;
- try
- Drawcontrol1(dc,rc);
- finally
- if adc=0 then ReleaseDC( hwnd, DC );
- end;
- except
- end;
- end;
- end;
- procedure TSkinEdit.DrawControl1( dc:HDC; rc:TRect);
- var r,r1:Trect;
- acolor:Tcolor;
- s:string;
- begin
- // if updown=nil then findupdown(hwnd,fsd,fcanvas);
- getclientrect(hwnd,r1);
- r:=rc;
- {$IFDEF edittest}
- s:=format('Edit rect %1x %1d %1d %1d %1d',[hwnd,rc.left,rc.top,rc.right,rc.bottom]);
- skinaddlog(s);
- s:=format('Edit Clientrect %1d %1d %1d %1d',[r1.left,r1.top,r1.right,r1.bottom]);
- skinaddlog(s);
- {$ENDIF}
- if (r.right<=(r1.right-r1.left+2)) or
- (r.bottom<=(r1.bottom-r1.top+2)) then exit;
- fcanvas.handle:=dc;
- fcanvas.brush.handle:=GetCurrentObject(dc,OBJ_BRUSH);
- InflateRect(rc,-1,-1);
- fcanvas.FrameRect(rc);
- acolor:=fcanvas.brush.color;
- fcanvas.brush.color:=fsd.colors[csButtonShadow];
- fcanvas.FrameRect(r);
- fcanvas.brush.color:=acolor;
- fcanvas.handle:=0;
- end;
- constructor TSkinCombox.Create(AOwner: TComponent);
- begin
- inherited create(aowner);
- isDrop:= false;
- HasButton:=false;
- // box:=Tskinscrollbar.create(nil);
- end;
- destructor TSkinCombox.Destroy;
- begin
- // box.free;
- if (hbtn<>0) and (fbtnobjectinst<>nil) then begin
- SetWindowLong(hbtn, GWL_WNDPROC,LongInt(FbtnPrevWndProc));
- FreeObjectInstance(FbtnObjectInst);
- fbtnobjectinst:=nil;
- hbtn:=0;
- end;
- if vb<>nil then begin
- vb.free; vb:=nil;
- end;
- inherited destroy;
- end;
- procedure TSkinCombox.Unsubclass;
- begin
- inherited unsubclass;
- if (hbtn<>0) and (fbtnobjectinst<>nil) then begin
- SetWindowLong(hbtn, GWL_WNDPROC,LongInt(FbtnPrevWndProc));
- FreeObjectInstance(FbtnObjectInst);
- fbtnobjectinst:=nil;
- hbtn:=0;
- end;
- if vb<>nil then begin
- vb.Unsubclass;
- vb.free; vb:=nil;
- end;
- if db<>nil then begin
- db.Unsubclass;
- db.free; db:=nil;
- end;
- end;
- procedure TSkinCombox.FindBtn;
- begin
- hbtn := GetTopWindow( hWnd );
- if hbtn<>0 then begin
- FBtnObjectInst := MakeObjectInstance(ButtonProc);
- FBtnPrevWndProc := Pointer(GetWindowLong(hbtn,GWL_WNDPROC));
- SetWindowLong(hbtn, GWL_WNDPROC,LongInt(FBtnObjectInst));
- end;
- end;
- Procedure TSkinCombox.Init(sf:Tcomponent;sd:TSkinData;acanvas:TCanvas;acolor:boolean=false);
- begin
- if inited then exit;
- inherited init(sf,sd,acanvas,acolor);
- dwStyle := GetWindowLong( hWnd, GWL_STYLE );
- vb:=nil;
- if ((dwStyle and CBS_SIMPLE)= CBS_SIMPLE) and
- ((dwStyle and CBS_DROPDOWN)=0) then begin
- fillchar(info,sizeof(info),#0);
- info.cbSize:=sizeof(tagCOMBOBOXINFO);
- if (@pGetComboBoxInfo<>nil) and pGetComboBoxInfo(hwnd,info) then begin
- hList:=info.hwndList ;
- dwStyle := GetWindowLong( hlist, GWL_STYLE );
- if not ispopupwindow(hlist) and
- (dwstyle and ws_child > 0) then begin
- vb:=TSkinScrollbarH.Create(owner);
- vb.Inithwnd(hlist,sd,nil,skinform);
- // db:=TComboxScrollbar.Create(owner);
- // db.Inithwnd(hlist,sd,nil,skinform);
- end;
- end;
- end else begin
- {$IFDEF demo}
- {$else}
- SkinDropList;
- {$endif}
- if not isunicode then findbtn;
- hList:=0;
- end;
- end;
- Procedure TSkinCombox.Inithwnd(ahwnd:Thandle;sd:TSkinData;acanvas:TCanvas;sf:Tcomponent);
- begin
- if inited then exit;
- inherited Inithwnd(ahwnd,sd,acanvas,sf);
- dwStyle := GetWindowLongEx( hWnd, GWL_STYLE );
- vb:=nil;
- if ((dwStyle and CBS_SIMPLE)= CBS_SIMPLE) and
- ((dwStyle and CBS_DROPDOWN)=0) then begin
- fillchar(info,sizeof(info),#0);
- info.cbSize:=sizeof(tagCOMBOBOXINFO);
- if (@pGetComboBoxInfo<>nil) and pGetComboBoxInfo(hwnd,info) then begin
- hList:=info.hwndList ;
- dwStyle := GetWindowLongEx( hlist, GWL_STYLE );
- if not ispopupwindow(hlist) and
- (dwstyle and ws_child > 0) then begin
- // vb:=TSkinScrollbarH.Create(owner);
- // vb.Inithwnd(hlist,sd,nil,skinform);
- end;
- end;
- end else begin