Help me ! VB to FWH

Help me ! VB to FWH

Postby fafi » Thu Apr 30, 2009 10:21 am

Hi ! Friends
I'm creating class FWH from VB..
Please! someone help me to translate .. my VB to FWH or C language

Code: Select all  Expand view

Private Type TRIVERTEX
    x As Long
    y As Long
    Red As Integer 'Ushort value
    Green As Integer '
Ushort value
    Blue As Integer 'ushort value
    Alpha As Integer '
ushort
End Type
 


Thanks for help..

Regards
Fafi
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: Help me ! VB to FWH

Postby nageswaragunupudi » Thu Apr 30, 2009 11:10 am

if you want to create a C Struct
Code: Select all  Expand view
typedef struct _TRIVERTEX { ;
  long x;
  long y;
  unsigned short red;
  unsigned short green;
  unsigned short blue;
  unsigned short alpha;
} TRIVERTEX;
 

If you want to construct a Harbour Class
Code: Select all  Expand view

class Trivertex
   data x
   data y
   data Red
   data Greem
   data Blue
   data Alpha

   method new()
endclass
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Help me ! VB to FWH

Postby ukoenig » Thu Apr 30, 2009 2:01 pm

Hello,

maybe a solution, in case You have still something more to convert :
With the shareware-version You can convert max. 600 lines of source.
I think, because functions are not very big and have just a few lines, it will be helpful.
Download : http://www.vbto.net/

Image

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Help me ! VB to FWH

Postby fafi » Fri May 01, 2009 1:52 am

Thanks to all !

Thanks for help

I try to publish my Class, if I finished it..
Sorry for my Bad English

Greeting from Indonesia.. keep my country Green

Antonio,
Do you mind if I publish my Class here..


Best Regards
Fafi
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: Help me ! VB to FWH

Postby fafi » Fri May 01, 2009 3:29 am

Hello Mr. Rao

Please Help me.. just to know .. how to use with FWH :
Code: Select all  Expand view


Private Type TRIVERTEX
    x As Long
    y As Long
    Red As Integer 'Ushort value
    Green As Integer '
Ushort value
    Blue As Integer 'ushort value
    Alpha As Integer '
ushort
End Type
Private Type GRADIENT_RECT
    UpperLeft As Long  'In reality this is a UNSIGNED Long
    LowerRight As Long '
In reality this is a UNSIGNED Long
End Type

Const GRADIENT_FILL_RECT_H As Long = &H0 'In this mode, two endpoints describe a rectangle. The rectangle is
'
defined to have a constant color (specified by the TRIVERTEX structure) for the left and right edges. GDI interpolates
'the color from the top to bottom edge and fills the interior.
Const GRADIENT_FILL_RECT_V  As Long = &H1 '
In this mode, two endpoints describe a rectangle. The rectangle
' is defined to have a constant color (specified by the TRIVERTEX structure) for the top and bottom edges. GDI interpolates
'
the color from the top to bottom edge and fills the interior.
Const GRADIENT_FILL_TRIANGLE As Long = &H2 'In this mode, an array of TRIVERTEX structures is passed to GDI
'
along with a list of array indexes that describe separate triangles. GDI performs linear interpolation between triangle vertices
'and fills the interior. Drawing is done directly in 24- and 32-bpp modes. Dithering is performed in 16-, 8.4-, and 1-bpp mode.
Const GRADIENT_FILL_OP_FLAG As Long = &HFF

Private Declare Function GradientFillRect Lib "msimg32" Alias "GradientFill" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long

Private Function LongToUShort(Unsigned As Long) As Integer
    '
A small function to convert from long to unsigned short
    LongToUShort = CInt(Unsigned - &H10000)
End Function

Private Sub Form_Load()
    Me.ScaleMode = vbPixels
End Sub

Private Sub Form_Paint()
    Dim vert(1) As TRIVERTEX
    Dim gRect As GRADIENT_RECT

    'from black
    With vert(0)
        .x = 0
        .y = 0
        .Red = 0&
        .Green = 0& '
&HFF& '0&
        .Blue = 0&
        .Alpha = 0&
    End With

    '
to blue
    With vert(1)
        .x = Me.ScaleWidth
        .y = Me.ScaleHeight
        .Red = 0&
        .Green = 0&
        .Blue = LongToUShort(&HFF00&)
        .Alpha = 0&
    End With

    gRect.UpperLeft = 0
    gRect.LowerRight = 1

    GradientFillRect Me.hdc, vert(0), 2, gRect, 1, GRADIENT_FILL_RECT_H

End Sub

 


Please help me Sir.. !


Thanks for help
Regards
Fafi
Last edited by fafi on Fri May 01, 2009 8:47 am, edited 1 time in total.
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: Help me ! VB to FWH

Postby nageswaragunupudi » Fri May 01, 2009 5:19 am

It is possible to make a class like this.
But this is reinventing the wheel
FWH GradientFill function simplifies this task for us. Mr Antonio has already built in this same functionality into FWH and made the usage extremely simple for us.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Help me ! VB to FWH

Postby fafi » Fri May 01, 2009 7:39 am

nageswaragunupudi wrote:It is possible to make a class like this.
But this is reinventing the wheel
FWH GradientFill function simplifies this task for us. Mr Antonio has already built in this same functionality into FWH and made the usage extremely simple for us.


Mr. Rao

Yes ! I know.. I mean..

I you don't mind .. please guide me .. how to use structure with FWH, here is my sample VB
Code: Select all  Expand view

/*

Private Type GdiplusStartupInput
    GdiplusVersion As Long
    DebugEventCallback As Long
    SuppressBackgroundThread As Long
    SuppressExternalCodecs As Long
End Type


Private Declare Function GdiplusStartup Lib "GDIPlus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long


'Windows API calls into the GDI+ library

Private Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As Long, bitmap As Long) As Long
Private Declare Function GdipCreateHBITMAPFromBitmap Lib "GDIPlus" (ByVal bitmap As Long, hbmReturn As Long, ByVal background As Long) As Long
Private Declare Function GdipDisposeImage Lib "GDIPlus" (ByVal image As Long) As Long
Private Declare Function GdiplusShutdown Lib "GDIPlus" (ByVal token As Long) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PICTDESC, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long


call in VB :

' Procedure:    LoadPictureGDI
' Purpose:      Loads an image using GDI+
' Returns:      The image as an IPicture Object
Public Function LoadPictureGDI(ByVal sFilename As String) As IPicture

    Dim uGdiInput As GdiplusStartupInput
    Dim hGdiPlus As Long
    Dim lResult As Long
    Dim hGdiImage As Long
    Dim hBitmap As Long

    'Initialize GDI+
    uGdiInput.GdiplusVersion = 1
    lResult = GdiplusStartup(hGdiPlus, uGdiInput)

    If lResult = 0 Then

        'Load the image
        lResult = GdipCreateBitmapFromFile(StrPtr(sFilename), hGdiImage)

        If lResult = 0 Then

            'Create a bitmap handle from the GDI image
            lResult = GdipCreateHBITMAPFromBitmap(hGdiImage, hBitmap, 0)

            'Create the IPicture object from the bitmap handle
            Set LoadPictureGDI = CreateIPicture(hBitmap)

            'Tidy up
            GdipDisposeImage hGdiImage
        End If

        'Shutdown GDI+
        GdiplusShutdown hGdiPlus
    End If

End Function




*/


How to Use with FWH :

DLL32 FUNCTION GdiplusStartup( token AS LONG, inputbuf AS ??????, @outputbuf AS LONG ) AS LONG ;
PASCAL FROM "GdiplusStartup" LIB "gdiplus.dll"


 

?????? = that is my problem Sir !

Thanks for help ..

Regards
Fafi
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 114 guests