Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2007
    Posts
    158

    The real Drawing Pad

    To make drawing environment like paint; we can use timer or on mouse events like attached project, but it's not the real thing cause when we draw fast it gives some distant dots, How can we fix this? any ideas?
    Attached Files

  2. #2
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534
    Use reteset's WinApi plugin.
    Action Plugins
    AllOn | Box | Class | Code | Cursor | DXML | Error | Frames | GlobalPaths | Group | INIPlus |KeyBind | KeyLock | MathEx | Menu | Name | Project | Resize | StatusBar
    Download

  3. #3
    Join Date
    Jul 2007
    Posts
    158
    Thanks for reminding, but is there any other way except merging windows?

  4. #4
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    arb,
    Here's something I did a while ago - same problem with the 'dots' not keeping up with the mouse... maybe IR can explain why...?

    http://www.indigorose.com/forums/thr...d-for-Children

  5. #5
    Join Date
    May 2006
    Posts
    1,443
    calling , MoveTo() and LineTo() Windows GDI functions with a proper GDI pen would do that very good

    in your sample you are creating objects continuously
    when you look from another side it is equivalent of creating shape objec plugin in each time you create a dot
    when i run the arb's sample project and after 10 seconds of mouse activity
    application's memory utilization goes from 7 mb to 15 mb ,you simply flood the memory

  6. #6
    Join Date
    Jul 2007
    Posts
    158
    Quote Originally Posted by holtgrewe View Post
    arb,
    Here's something I did a while ago - same problem with the 'dots' not keeping up with the mouse... maybe IR can explain why...?

    http://www.indigorose.com/forums/thr...d-for-Children
    Yeah i saw that, very nice design !

    Quote Originally Posted by reteset View Post
    calling , MoveTo() and LineTo() Windows GDI functions with a proper GDI pen would do that very good
    Sounds promising, but i have no idea how to do that

  7. #7
    Join Date
    May 2006
    Posts
    1,443
    here is a simple drawing example
    this is not a complete sample , it only shows how to draw lines with GDI API
    please keep in mind :
    all the drawings will be lost after next window redraw
    you will need to catch WM_PAINT message of app window to replicate previous drawings

    there are two ways to do it
    one; save current dc as a memory bitmap (using GDI API)
    another way ; store mouse positions in a lua table and call moveto /lineto functions through that table in next time

    also saving positions to a table ,may help you to save drawings to a file and load in next time
    this is how graphic programs work (save as project)
    Attached Files

  8. #8
    Join Date
    Jul 2007
    Posts
    158
    Wow, that was sweeeeeeeeet, Thank you very much for this.

    I wish i learn more about windows capabilities.

    Thanks again reteset

  9. #9
    Join Date
    Sep 2010
    Location
    Barcelona Spain
    Posts
    599
    Quote Originally Posted by reteset View Post
    here is a simple drawing example
    this is not a complete sample , it only shows how to draw lines with GDI API
    please keep in mind :
    all the drawings will be lost after next window redraw
    @reteset,

    I tryed to change the pen properties when calling the PenCreate function, theoretically the variable pStyle should be an string like PS_SOLID, PS_DASH...PS_INSIDEFRAME, however the placeholder for this variable is a number %d instead of %s, I could not find if the aforementioned strings have a number value.



    Code:
    CreatePen = function(pStyle,pSize,pColor)
      local va_arg = string.format("%d,%d,%d",pStyle,pSize,pColor);
      return DLL.CallFunction("Gdi32.dll", "CreatePen", va_arg, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    end
    When I change the pSize to a number greater than Zero, (more than one pixel) I have a delay when mouving the mouse, no drawn at all is seen untill few elapsed seconds or when moving the window along the screen.

    Is this behaviour normal, my OS W7 Media center, AMS version 8.0.4.0.?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts