Is there more information/examples about OnScreenCurve, OnScreenHandle and OnScreenText?

These seem like great functions to help user interactions, but the best I could manage so far was a very specifically sized and colored text box

'Gotta have some shape set as S
Dim Test As New OnScreenText
Test.SetTextAndPosition "This is the bad shape!", S.CenterX, S.CenterY
Test.SetTextColor (RGB(255, 0, 0))
Test.Show

The SetTextColor command did nothing (I may be using the wrong colort type, but there was no error message). The font is fairly specific and small.

Is there more information or examples of these functions anywhere? Ideally I would like to draw a box around corrupt shapes, for example. Or even better an outline to the shape, etc.

But how?

  • Former Member
    0 Former Member over 4 years ago

    Maybe your RGB function has been return a invalid number after auto cast, RGB function returns a float number, SetTextColor expects a int number.

    This exemple show how draw a curve onScreen, 

    Making a Zig Zag Tool for CorelDRAW and Corel DESIGNER - Docs & Tutorials - Developer Area - CorelDRAW Community

    I have this code too, 

    SelectByWay/SelectByWay.cs at master · bonus630/SelectByWay (github.com)

    Is in C#, but the call to corel API is the same

    • Thanks a lot, I figured how to show curves, which is pretty cool (if a little annoying that you cannot have text and curves at once (as far as I can tell)).

      After digging through documentation, I realized that the RGB() function returns Long. So I built this:

      Sub OnScreenTest()
      
          Set S = ActiveSelectionRange.Shapes.First
          Dim Col As New Color
          Col.RGBAssign 255, 0, 0
          
          Dim Test As New OnScreenText
          Test.SetTextAndPosition "This is the bad shape!", S.CenterX, S.CenterY
          Test.SetTextColor RGB(255, 0, 0)
          Test.Show
          
          Dim Zest As OnScreenCurve
          Set Zest = Application.CreateOnScreenCurve()
          Zest.SetCurve S.DisplayCurve
          Zest.SetPen RGB(255, 0, 0), 200, cdrOnScreenCurvePenDash
          Zest.Show
      
      End Sub
      

      Well, there are no error messages, but there are zero changes anywhere either.

      Am I doing something wrong or is this functionality just half baked?

      • Former Member
        0 Former Member over 4 years ago in reply to Joe

        apparently this function is broken

        • Eh, not the thing I wanted to hear...

          Well, there's still hope that someone may know some undocumented workaround. Small hope, but still.

          • Former Member
            0 Former Member over 4 years ago in reply to Joe

            You can try some hacks to display curve and a text, use only CreateOnScreenCurve(), to display a curve of a text joined yours others curves

                try
                        {
                            Color color = app.CreateColor();
                            color.RGBAssign(255, 0, 0);
            
                            string text = "Test";
                            double positionX = 0;
                            double positionY = 0;
            
                            app.Optimization = true;
                            OnScreenCurve ui = app.CreateOnScreenCurve();
                            
                            Shape q = app.ActiveLayer.CreateRectangle2(positionX, positionY, 1, 1);
                            Shape t = app.ActiveLayer.CreateArtisticText(positionX, positionY, text);
                            q.ConvertToCurves();
                            t.ConvertToCurves();
            
                            Curve c = app.CreateCurve();
                            c.AppendCurve(q.DisplayCurve);
                            c.AppendCurve(t.DisplayCurve);
            
                            t.Delete();
                            q.Delete();
            
                            ui.SetCurve(c);
                            ui.SetPen(color.RGBValue, 10, cdrOnScreenCurvePenStyle.cdrOnScreenCurvePenSolid);
                            
                            app.Optimization = false;
                            app.Refresh();
                            ui.Show();
                        }
                        catch(Exception e)
                        {
                            
                        }
                        finally
                        {
                            app.Optimization = false;
                            app.Refresh();
                        }
            
            • Former Member
              0 Former Member over 4 years ago in reply to Former Member

              Color dont change

              • Well, there are no error messages, but there are zero changes anywhere either.
                Am I doing something wrong or is this functionality just half baked?

                My experience with OnScreenCurve is limited to using rectangles, e.g., in my Weed Box macro, to show where the box is going to be created.

                That uses OnScreenCurve.SetRectangle.

                As a test, you might try that to see if you can successfully create and show an OnScreenCurve, set the pen properties, etc.

                Edited to add:

                I just tried testing this myself, and it's not working for me with .SetRectangle, either.

                I may have to look back at my Weed Box macro and see what I did differently there (where it is working).