dcsimg
Results 1 to 3 of 3

Thread: Api for drawing graphic in picbox

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2018
    Posts
    2

    Api for drawing graphic in picbox

    Hello,
    Using API to draw special graphic on picbox (moon appearance in the sky) i need some information to complete my work.
    How to rotate an object drawn in picbox , are any functions (api) doing this task ?

    I use the functions below to draw moon (phase):


    'Déclaration des APIs Windows pour l'utilisation des régions

    Public Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    Public Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
    Public Declare Function OffsetRgn Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
    Public Declare Function PaintRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,619

    Re: Api for drawing graphic in picbox

    Yes, there is a SetWorldTransform API call which will allow you to place and rotate the coordinate system used to draw with. Perhaps depending on the language you're using to draw with you may have to use the SetGraphicsMode API call first (setting the mode to GM_ADVANCED (= 2)) to enable the drawing functions to use the drawing matrix setup by the SetWorldTransform API.

    I've only done it from VB6 and you had to call SetGraphicsMode first to set it to GM_ADVANCED. This might be require for any window you want to use a drawing matrix with.
    In VB6, I know I saved the return value from the SetGraphicsMode, did my drawing with rotations, etc..., then called SetGraphicsMode again after the drawing, passing it the saved value so the drawing mode was returned to its "normal" state when I finished my drawing.

    I don't know which language you're using, but if you would be interested in a VB6 example, at least one is posted already on the forum somewhere.
    p.s. One later modified version or an earlier simpler version found in this post.
    Last edited by passel; Jul 12th, 2018 at 04:26 PM.

  3. #3

    Thread Starter
    Registered User
    Join Date
    Jul 2018
    Posts
    2

    Re: Api for drawing graphic in picbox

    Quote Originally Posted by passel View Post
    Yes, there is a SetWorldTransform API call which will allow you to place and rotate the coordinate system used to draw with. Perhaps depending on the language you're using to draw with you may have to use the SetGraphicsMode API call first (setting the mode to GM_ADVANCED (= 2)) to enable the drawing functions to use the drawing matrix setup by the SetWorldTransform API.

    I've only done it from VB6 and you had to call SetGraphicsMode first to set it to GM_ADVANCED. This might be require for any window you want to use a drawing matrix with.
    In VB6, I know I saved the return value from the SetGraphicsMode, did my drawing with rotations, etc..., then called SetGraphicsMode again after the drawing, passing it the saved value so the drawing mode was returned to its "normal" state when I finished my drawing.

    I don't know which language you're using, but if you would be interested in a VB6 example, at least one is posted already on the forum somewhere.
    p.s. One later modified version or an earlier simpler version found in this post.
    thank you for your useful answer and link for the Api subject.
    I wrote several specific applic. (astro navigation, geodesy, ship stability)
    , etc ...) under VB6.
    Since MS decide to abandon VB6, i migrate to RealBasic (Xojo now) they are
    very similar, easy for me because i am not professional programmer.
    Otherwise Xojo is fully OOP and Cross Platform compiler.
    Even for Api (windows) ... , so i continue to rewrite VB6 to Xojo.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width