procedure TTransparentMemo.WMVScroll(var Message: TWMVScroll); begin SendMessage(Handle,TMWM__SpecialInvalidate,0,0); inherited; PostMessage(Handle,TMWM__SpecialInvalidate,0,0); end;
procedure c(X,Y:Integer;t:TCanvas);stdcall; begin a:=a shl 1; if a =0 then a:=1; if (a and 224)>0 then t.Pixels[X,Y]:=clWhite else t.Pixels[X,Y]:=clBlack; end;
procedure TTransparentMemo.CNCTLCOLOREDIT(var Message:TWMCTLCOLOREDIT); var i:integer; begin with Message do begin SetBkMode(ChildDC,TRANSPARENT); Result:=GetStockObject(HOLLOW_BRUSH); if FBB then Exit; Canvas.Brush.Color := clBlack; Canvas.Pen.Width:=1; LineDDA(0,0,Width,0,@c,LongInt(Canvas)); LineDDA(Width-1,0,Width-1,Height,@c,LongInt(Canvas)); LineDDA(0,0,0,Height,@c,LongInt(Canvas)); LineDDA(0,Height-1,Width,Height-1,@c,LongInt(Canvas)); for I := 1 to 8 do Canvas.Rectangle (FRectList [I].Left-1, FRectList [I].Top-1,FRectList [I].Right-1, FRectList [I].Bottom-1); end; end;
procedure TTransparentMemo.WMSetText(var Message:TWMSetText); begin inherited; if not (csDesigning in ComponentState) then PostMessage(Handle,TMWM__SpecialInvalidate,0,0); end;
procedure TTransparentMemo.SpecialInvalidate(var Message:TMessage); var r:TRect; begin if Parent<>nil then begin r:=ClientRect; r.TopLeft:=Parent.ScreenToClient(ClientToScreen(r.TopLeft)); r.BottomRight:=Parent.ScreenToClient(ClientToScreen(r.BottomRight)); InvalidateRect(Parent.Handle,@r,true); RedrawWindow(Handle,nil,0,RDW_FRAME+RDW_INVALIDATE); end; end;
procedure TTransparentMemo.WMKeyDown(var Message: TWMKeyDown); begin SendMessage(Handle,TMWM__SpecialInvalidate,0,0); inherited; PostMessage(Handle,TMWM__SpecialInvalidate,0,0); end;
procedure TTransparentMemo.WMEraseBkgnd(var Message: TWMEraseBkgnd); begin Message.Result := 1; if SelText=' then PostMessage(Handle,WM_KEYDOWN,0,0); end;
procedure TTransparentMemo.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); with Params do begin ExStyle:=ExStyle or WS_EX_TRANSPARENT and not WS_EX_WINDOWEDGE and not WS_EX_STATICEDGE and not WS_EX_DLGMODALFRAME and not WS_EX_CLIENTEDGE; end; end;
function TTransparentMemo.GetCanvas: TControlCanvas; begin Result:=FCanvas; end;
procedure TTransparentMemo.WmNcHitTest(var Msg: TWmNcHitTest); var Pt: TPoint; I: Integer; begin Pt := Point (Msg.XPos, Msg.YPos); Pt := ScreenToClient (Pt); Msg.Result := 0; for I := 1 to 8 do if PtInRect (FRectList [I], Pt) then Msg.Result := FPosList [I]; if Msg.Result = 0 then inherited; end;
procedure TTransparentMemo.WmSize(var Msg: TWmSize); begin FRectList [1] := Rect (0, 0, 5, 5); FRectList [2] := Rect (Width div 2 - 3, 0,Width div 2 + 2, 5); FRectList [3] := Rect (Width - 5, 0, Width, 5); FRectList [4] := Rect (Width - 5, Height div 2 - 3,Width, Height div 2 + 2); FRectList [5] := Rect (Width - 5, Height - 5,Width, Height); FRectList [6] := Rect (Width div 2 - 3, Height - 5,Width div 2 + 2, Height); FRectList [7] := Rect (0, Height - 5, 5, Height); FRectList [8] := Rect (0, Height div 2 - 3,5, Height div 2 + 2); inherited; end;
procedure TTransparentMemo.SizerEnter(Sender: TObject); begin FBB:=False; PostMessage(Handle,WM_SIZE,0,0); end;
procedure TTransparentMemo.SizerExit(Sender: TObject); begin if Text=' then begin Free; Exit; end; FBB:=True; if SelText<>' then PostMessage(Handle,WM_ERASEBKGND,0,0); PostMessage(Handle,WM_SIZE,0,0); end;
procedure TTransparentMemo.SetMapText(const Value: String); begin FMapText := Value; Lines.Text:=Value; end;
procedure TTransparentMemo.WmLButtonDown(var Msg: TWmLButtonDown); begin if (Msg.XPos<=2) or (Msg.YPos<=2) or ((Msg.XPos<=Width) and (Msg.XPos>=(Width-2))) or ((Msg.YPos<=Height) and (Msg.YPos>=(Height-2))) then begin Perform (wm_SysCommand, sc_DragMove, 0); PostMessage(Handle,WM_Size,0,0); end else inherited; end;
procedure TTransparentMemo.cmMousemove(var Msg: TWMMouseMove); begin if (Msg.XPos<=2) or (Msg.YPos<=2) or ((Msg.XPos<=Width) and (Msg.XPos>=(Width-2))) or ((Msg.YPos<=Height) and (Msg.YPos>=(Height-2))) then Cursor:=crHandPoint else Cursor:=crDefault; end;
procedure TTransparentMemo.Change(Sender: TObject); begin FMapText:=Lines.Text; end;