DotNet Draw in Label

Hi. It’s not like it’s impossible to make the text be on top of the DrawRectangle during the Draft and after releasing the MouseUp everything goes back.

    try(destroydialog drawRol) catch()
    rollout drawRol "Draw in Label"
    (
     dotNetControl lb "System.Windows.Forms.Label" width:240 height:30 pos:[10, 10]
 
     local PaintRdy = false
 
     on lb mouseDown s e do
     (
    	 PaintRdy = true
     )
 
     on lb mouseUp s e do
     (
    	 PaintRdy = false
     )
 
     on lb mouseMove s e do
     (
    	if PaintRdy do
    	(
    	 	local RectBrush = dotnetobject "System.Drawing.SolidBrush" s.Backcolor.Red
    	        local RectPen = dotnetobject "System.Drawing.Pen" s.Backcolor.Black 2
    	 	RectPen.alignment = (dotnetclass"System.Drawing.Drawing2D.PenAlignment").inset
    	 	DraGra = s.createGraphics()
 
    		 if (e.x <= s.bounds.width) then (paintX = e.x) else (paintX = s.bounds.width)
 
     	 	RectObj = Rectangle 0 0 paintX s.bounds.height
     	 	DraGra.FillRectangle RectBrush RectObj
     	 	DraGra.DrawRectangle RectPen RectObj
 
    	)
    )
 
    on drawRol open do
    	 (
             lb.text = "Test Label Brush"
    	 )
 
    )
    createdialog drawRol width:300 height:50

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
freemanpro's picture

new

True, I still did not understand how to return back to its original state, except how to assign label.image

obaida's picture

nice one , but : RectObj =

nice one , but :
RectObj = dotnetobject "System.Drawing.Rectangle" 0 0 paintX s.bounds.height

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.