Update WrappedText on PictureBox Control

Started by AutoKAD, December 04, 2009, 05:03:47 PM

Previous topic - Next topic

AutoKAD

I'm trying to toggle between two strings of text on a picturebox control when the control is clicked using DrawWrappedText.  I've tried several ideas, but I can't get it to work.  Anyone got any ideas to what I am doing wrong?  Thanks.

Kevin

Kerry

#1

Kevin,
This is the closest I can get to what I think you want.

By my understanding, the OnPaint event fires on OnMouseEntered, OnMouseMovedOff and OnClicked ( as you can see from the Command line prompt I've added)

SO,
I've removed the DrawWrappedText call from all event traps except for the OnPaint and used a global variable to hold the dynamic text value.

The (dcl_PictureBox_Refresh UpdatePicText_Form1_PictureBox1) call in the OnClicked fixes the text Overdraw issue.

Depending on the complexity of the PictureBox population you MAY need to look at using the PictureBox_StoreImage method to save the piccy except for the Text. (this will need confirmation, 'cause I haven't tried it )





Code (autolisp) Select

(vl-load-com)
(command "OPENDCL")


(defun c:doit (/ cnt PDRaw_Loc PDRaw_Open ChrFilter_Open )
 
 (setq g:textValue "Original"
       g:val 0
 )
 
 (dcl_Project_Load "UpdatePicText" T)
 (dcl_Form_Show UpdatePicText_Form1)
 (dcl_Form_Center UpdatePicText_Form1)

 (princ)
)

(defun c:UpdatePicText_Form1_OnClose (UpperLeftX UpperLeftY /)  
 (setq g:textValue nil
         g:val nil )
)


(defun c:UpdatePicText_Form1_PictureBox1_OnPaint (HasFocus /)
 (dcl_PictureBox_DrawWrappedText UpdatePicText_Form1_PictureBox1
                                 (list (list 6 3 144 -19 -24 g:textValue 0))
 )
 (princ (strcat "\n OnPaint Fired :" (itoa (setq g:val (1+ g:val)) )))
)


(defun c:UpdatePicText_Form1_PictureBox1_OnMouseEntered (/)
 (dcl_Control_SetBackColor UpdatePicText_Form1_PictureBox1 2)
 
)
(defun c:UpdatePicText_Form1_PictureBox1_OnMouseMovedOff (/)
 (dcl_Control_SetBackColor UpdatePicText_Form1_PictureBox1 1)

)

(defun c:UpdatePicText_Form1_PictureBox1_OnClicked (/)
 (if
   (= (dcl_Control_GetToolTipTitle UpdatePicText_Form1_PictureBox1) "Old Text")
    (setq g:textValue "New Text")
    ;; else
    (setq g:textValue "Old Text")
 )
 (dcl_PictureBox_Refresh UpdatePicText_Form1_PictureBox1)
 (dcl_Control_SetToolTipTitle UpdatePicText_Form1_PictureBox1 g:textValue)
 
)
Perfection is not optional.
My other home is TheSwamp

Kerry



Owen,

The wrappedText survived being hidden behind the Properties Dialog, Plot Dialog, CUI editor and a few others I can't remember ..
BUT the NEW and OPEN dialogs wipe out the Text.
I assume this is because they are different technology ... ?
.. and somehow the redraw notification gets lost.

Kerry

Perfection is not optional.
My other home is TheSwamp

owenwengerd

Owen Wengerd (Outside The Box) / ManuSoft

Kerry

Perfection is not optional.
My other home is TheSwamp

AutoKAD

Kerry,

This solution works for me.  The only change I'll be making is switching dcl_Control_SetBackColor to dcl_Control_SetPicture in the OnMouseEntered and OnMouseMovedOff events.

Thanks for the help!

Kevin