dcl-PictureBox-DrawText not running in "Oninitialize"?

Started by Peter2, August 09, 2016, 07:36:27 AM

Previous topic - Next topic

Peter2

I have this code to
- load and display a picture (WMF)
- load and display a tooltip
- create a temp-text with dcl-PictureBox-DrawText
- convert the temp-text to image with dcl-PictureBox-StoreImage

Code (autolisp) Select
(progn
    ; a) show image
    (dcl-PictureBox-LoadPictureFile (eval (read WMFViewName)) WMFName T)
    ; b) handle tooltip
    (dcl-Control-SetToolTipTitle (eval (read WMFViewName)) tafel)
    ; c) create temp-text
    (dcl-PictureBox-DrawText (eval (read WMFViewName)) (list (list 5 0 2 5 tafel 0)))
    ; d) store text as Image
    (dcl-PictureBox-StoreImage (eval (read WMFViewName)))
)

It works fine when the dialogue is open and I use buttons and lists and so on. But if I call the code from "Oninitialize", only a) and b) are done. c) (and of course d) does nothing. Is it a limitation of the function?

Thanks

Peter
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

Yes, DrawText writes to the display. If nothing is displayed, there is nowhere for it to write. You might try using OnPaint to delay initialization until the control is visible.
Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Quote from: owenwengerd on August 09, 2016, 06:41:42 PM
....You might try using OnPaint to delay initialization until the control is visible.
Thanks for the hint. I tried it and normally it would works, but with 20 controls and dynamic content and different display commands it is more complex then expected. In this case I will search another way ...  ;)
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10