6
68686688
Unregistered / Unconfirmed
GUEST, unregistred user!
我自己做写了一个按钮空间,但老是有错误。
经常会提示
Error reading MBTN15.Image.Date:Win32 Error、Code:87 参数错误
DRY Error reading bRIGHT Data: WIN32 Error.Code 87
不知道是为什么?请各位大虾帮我看一下,谢谢了。
constructor TmpBTN.Create( AOwner:TComponent );
begin
inherited Create( AOwner );
Width := 90;
Height := 49;
ControlStyle := ControlStyle + [csOpaque] ;
Font.Name := '宋体';
Font.Size := 10;
Font.Charset := GB2312_CHARSET;
Font.Style :=[];
Font.Color := ifCOLOR;
FSelection:=clBlue;
FBackground:= $00F7D8C1;
COLOR := FBackground;
FBitMap:=TBitmap.Create;
myBML:=TBitmap.Create;
myBMC:=TBitmap.Create;
myBMR:=TBitmap.Create;
APPLICATION.CreateForm( TmpBTNform1, mpBTNform1);
myBML.Assign( mpBTNform1.bLEFT.Picture.Bitmap);
myBMC.Assign( mpBTNform1.bCENTER.Picture.Bitmap);
myBMR.Assign( mpBTNform1.bRIGHT.Picture.Bitmap);
mpBTNform1.FREE;
end;
......
procedure TmpBTN.Paint;
const
PEN_WIDTH = 2;
Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK);
var
Area,BitRect: TRect;
b : TBitmap;
L, R : INTEGER;
mB : BOOLEAN;
begin
b:=TBitmap.Create;
b.Width :=Width;
Height := myBML.Height;
b.Height:=Height;
L := myBML.Width;
B.Canvas.Draw( 0, 0, myBML);
R := B.Width-myBMR.Width;
B.Canvas.Draw( R, 0, myBMR);
WHILE L<R DO
BEGIN
B.Canvas.Draw( L, 0, myBMC);
L := L + myBMC.Width;
END;
TRY
mB := FBitMap.Empty;
IF NOT mB THEN
BEGIN
TRY
FBitMap.TransparentColor := CLWHITE;
FBitMap.Transparent := TRUE;
FINALLY
END;
R := (height-FBitMap.Height)DIV 2;
L := WIDTH-B.Canvas.TextWidth( CAPTION)-FBitMap.Width-10;
L := L DIV 2;
B.Canvas.Draw( L, R, FBitMap);
END;
EXCEPT
mB := TRUE;
END;
BitRect:= B.Canvas.ClipRect;
BitRect.Top := BitRect.Bottom-b.height;
BitRect.Right:=Width;
b.Canvas.CopyRect(b.Canvas.ClipRect,B.Canvas,BitRect);
Area:=b.Canvas.ClipRect;
Area.Left :=Area.Left;
Area.Right:=Area.Right;
b.canvas.Brush.Style := BsClear;
b.canvas.Font := Font;
IF NOT ENABLED THEN B.Canvas.Font.Color := dfCOLOR;
L := WIDTH-B.Canvas.TextWidth( CAPTION);
IF mB THEN L := L DIV 2 ELSE
BEGIN
TRY
L := WIDTH-B.Canvas.TextWidth( CAPTION)-FBitMap.Width-10;
L := L DIV 2;
L := L + FBitMap.Width + 10;
EXCEPT
END;
END;
R := (height-B.Canvas.TextHeight(CAPTION))DIV 2;
B.Canvas.TextOut( L, R, CAPTION);
IF lmBUTTON_Down THEN
BEGIN
Canvas.Draw( 1, 1, b);
END ELSE Canvas.Draw( 0, 0, b);
b.Free;
end;
经常会提示
Error reading MBTN15.Image.Date:Win32 Error、Code:87 参数错误
DRY Error reading bRIGHT Data: WIN32 Error.Code 87
不知道是为什么?请各位大虾帮我看一下,谢谢了。
constructor TmpBTN.Create( AOwner:TComponent );
begin
inherited Create( AOwner );
Width := 90;
Height := 49;
ControlStyle := ControlStyle + [csOpaque] ;
Font.Name := '宋体';
Font.Size := 10;
Font.Charset := GB2312_CHARSET;
Font.Style :=[];
Font.Color := ifCOLOR;
FSelection:=clBlue;
FBackground:= $00F7D8C1;
COLOR := FBackground;
FBitMap:=TBitmap.Create;
myBML:=TBitmap.Create;
myBMC:=TBitmap.Create;
myBMR:=TBitmap.Create;
APPLICATION.CreateForm( TmpBTNform1, mpBTNform1);
myBML.Assign( mpBTNform1.bLEFT.Picture.Bitmap);
myBMC.Assign( mpBTNform1.bCENTER.Picture.Bitmap);
myBMR.Assign( mpBTNform1.bRIGHT.Picture.Bitmap);
mpBTNform1.FREE;
end;
......
procedure TmpBTN.Paint;
const
PEN_WIDTH = 2;
Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK);
var
Area,BitRect: TRect;
b : TBitmap;
L, R : INTEGER;
mB : BOOLEAN;
begin
b:=TBitmap.Create;
b.Width :=Width;
Height := myBML.Height;
b.Height:=Height;
L := myBML.Width;
B.Canvas.Draw( 0, 0, myBML);
R := B.Width-myBMR.Width;
B.Canvas.Draw( R, 0, myBMR);
WHILE L<R DO
BEGIN
B.Canvas.Draw( L, 0, myBMC);
L := L + myBMC.Width;
END;
TRY
mB := FBitMap.Empty;
IF NOT mB THEN
BEGIN
TRY
FBitMap.TransparentColor := CLWHITE;
FBitMap.Transparent := TRUE;
FINALLY
END;
R := (height-FBitMap.Height)DIV 2;
L := WIDTH-B.Canvas.TextWidth( CAPTION)-FBitMap.Width-10;
L := L DIV 2;
B.Canvas.Draw( L, R, FBitMap);
END;
EXCEPT
mB := TRUE;
END;
BitRect:= B.Canvas.ClipRect;
BitRect.Top := BitRect.Bottom-b.height;
BitRect.Right:=Width;
b.Canvas.CopyRect(b.Canvas.ClipRect,B.Canvas,BitRect);
Area:=b.Canvas.ClipRect;
Area.Left :=Area.Left;
Area.Right:=Area.Right;
b.canvas.Brush.Style := BsClear;
b.canvas.Font := Font;
IF NOT ENABLED THEN B.Canvas.Font.Color := dfCOLOR;
L := WIDTH-B.Canvas.TextWidth( CAPTION);
IF mB THEN L := L DIV 2 ELSE
BEGIN
TRY
L := WIDTH-B.Canvas.TextWidth( CAPTION)-FBitMap.Width-10;
L := L DIV 2;
L := L + FBitMap.Width + 10;
EXCEPT
END;
END;
R := (height-B.Canvas.TextHeight(CAPTION))DIV 2;
B.Canvas.TextOut( L, R, CAPTION);
IF lmBUTTON_Down THEN
BEGIN
Canvas.Draw( 1, 1, b);
END ELSE Canvas.Draw( 0, 0, b);
b.Free;
end;