Announcement

Collapse
No announcement yet.

HANDLE HWND and others...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    One point: an ATOM is actually a LONG or a DWORD, not a 16-bit integer as implied above.

    Also, anything prefixed with LP is a pointer, which is therefore 32-bits wide, but the target size depends on the variable type.



    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Hi,
    This' from the MSDN:
    Code:
    C language 
    data type        In Visual Basic declare as Call with 
    ATOM             ByVal variable As Integer An expression that evaluates to an Integer 
    BOOL             ByVal variable As Long An expression that evaluates to a Long 
    BYTE             ByVal variable As Byte An expression that evaluates to a Byte 
    CHAR             ByVal variable As Byte An expression that evaluates to a Byte 
    COLORREF         ByVal variable As Long An expression that evaluates to a Long 
    DWORD            ByVal variable As Long An expression that evaluates to a Long 
    HWND, HDC,
    HMENU,etc.       ByVal variable As Long An expression that evaluates to a Long 
    INT, UINT        ByVal variable As Long An expression that evaluates to a Long 
    LONG             ByVal variable As Long An expression that evaluates to a Long 
    LPARAM           ByVal variable As Long An expression that evaluates to a Long 
    LPDWORD          variable As Long An expression that evaluates to a Long 
    LPINT, LPUINT    variable As Long An expression that evaluates to a Long 
    LPRECT           variable As type Any variable of that user-defined type 
    LPSTR, LPCSTR    ByVal variable As String An expression that evaluates to a String 
    LPVOID           variable As Any Any variable (use ByVal when passing a string) 
    LPWORD           variable As Integer An expression that evaluates to an Integer 
    LRESULT          ByVal variable As Long An expression that evaluates to a Long 
    NULL             As Any or ByVal variable As Long, 
                     ByVal Nothing,
                     or ByVal 0&,
                     or vbNullString 
    SHORT            ByVal variable As Integer An expression that evaluates to an Integer 
    VOID             Sub procedure Not applicable 
    WORD             ByVal variable As Integer An expression that evaluates to an Integer 
    WPARAM           ByVal variable As Long An expression that evaluates to a Long
    Hope That helps?

    ------------------
    [email protected]

    Leave a comment:


  • Guest's Avatar
    Guest replied
    I haven't done anything in Delphi, but I heard that they made a big mess with their variable types 'between' version 1 and 2, so these informations may not be reliable. For example in some versions a dword seems only to be in the positive range of a long.

    Andreas


    ------------------

    Leave a comment:


  • Tom Hanlin
    replied
    int64 is not a standard C type, although it's easy to guess that they
    mean a 64-bit integer, which is a QUAD in PowerBASIC. PB doesn't have
    an unsigned 64-bit integer type, but QUAD should suffice for that as
    well in most cases, in the same way you can generally get away with
    using a LONG instead of a DWORD for a HANDLE value.

    Delphi, by the way, uses integer conventions similar to C, although
    the names are case-insensitive, as with BASIC. That is, a Delphi
    INTEGER value may be either a PowerBASIC INTEGER or LONG, depending
    on whether the Delphi code is 16-bit or 32-bit.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Dan Soper
    replied
    C's 'int64' and/or 'UINT64' correspond to PB's 'QUAD'?

    ------------------
    --Dan

    Leave a comment:


  • Tom Hanlin
    replied
    When dealing with C, intrinsic types are in lowercase. Defined
    types are in all caps by convention. C is case-sensitive. Integer-class
    types can take a modifier of "signed" or "unsigned", and are signed by
    default. The size of a type may vary according to the compiler but,
    typically, the following applies for DOS and Windows C implementations:

    "char" (or "signed char"): a signed byte. The PB translation may be BYTE
    or STRING * 1 depending on the situation.

    "unsigned char": a byte. The PB translation will usually be BYTE, although
    there may be cases where STRING * 1 will be appropriate. You will
    frequently see defined C types that mean the same thing, such as
    "UCHAR" or "BYTE".

    "int" (or "signed int"): a signed integer. If it's 16-bit C code, the PB
    translation is INTEGER. If it's 32-bit C code, the PB translation is LONG.

    "unsigned int": an unsigned integer. If it's 16-bit C code, the PB
    translation is WORD. If it's 32-bit C code, the translation is DWORD.
    Often defined in C as a "UINT" or "DWORD" type.

    "short": a signed 16-bit integer. In PB, INTEGER. Sometimes seen in C
    as the defined type "SHORT".

    "long": a signed 32-bit integer. In PB, LONG. Sometimes seen in C as the
    defined type "LONG".

    C arrays are defined by the number of elements and are indexed from zero:

    "char foo[32]" translates to DIM foo(0 TO 31) AS BYTE or, more likely,
    DIM foo AS STRING * 32, depending on the context.


    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Kev Peel
    replied
    Hi,

    Any chance that a good C\C++ or Delphi programmer could draw up a table with all the data-type translations to PowerBASIC, you won't believe the amount of time I spend converting code from other languages!

    Regards,

    ------------------
    Kev G Peel
    KGP Software, Bridgwater, UK.
    www.go.to/kgpsoftware

    Leave a comment:


  • Lance Edmonds
    replied
    One thing to watch out for is that in some dialects of C code, a "bool" and a "BOOL" are not the same thing... while a BOOL is always a 32-bit variable, but often a "bool" is a byte variable. The catch is that the lowercase instance is not *guaranteed* to be a byte... it depends on the C compiler involved.

    Since we have so many knowledgable folks here, has anyone actually seen a good reference or table that cross-references variable types used by the various compilers?

    If not, is anyone willing to help me construct such a table for a FAQ? Email or postings here are gratefully accepted!

    Here is a list of PB and some C data types (done from off the top of my head, E&OE) to help kick this off:
    Code:
    PowerBASIC             C/C++
    ===============================================
    ?    BYTE              bool
    ??   WORD              
    ???  DWORD             UINT32
    %    INTEGER           SHORT
    &    LONG              INT, INT32, BOOL
    &&   QUAD               
    !    SINGLE            FLOAT
    #    DOUBLE
    ##   EXTENDED
    @    CURRENCY (CUR)
    @@   EXTENDED (CUX)
    $    STRING            BSTR 
         STRING * n        <byte array>
         ASCIIZ            <byte array + $NUL>
    n@   POINTER           *var, &var
    Don (if you are listening), some help with the Delphi data types would be a good start, as you have an excellent grip on that platform.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Knuth Konrad
    replied
    Originally posted by Tom Hanlin:
    I suspect a BOOLEAN is a BYTE type.
    According to Dan Appleman's book a BOOL is (VB-)Long where zero is FALSE, all other values are TRUE. BOOL and BOOLEAN should be identical.
    And yes, FLOAT translates to Single.

    Knuth

    ------------------
    http://www.softAware.de

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Hello Dan,

    I believe that an INT is defined as 32Bit integer starting with
    Windows 95/98/NT/2000. Under earlier version of windows it should
    be a 16Bit integer. Now as for a "SHORT", I think its always a
    16Bit integer.



    ------------------
    Cheers

    Leave a comment:


  • Dan Soper
    replied
    Related question: when attempting to port some C code to PB, I've encountered variables of types INT and SHORT.
    Are these not the same thing, a 16-bit signed integer?

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Thanks Tom,

    Just go's to show you what billions of dollars, a couple thousand
    programmers, and one little nerd at the top of the pile can come
    up with!

    Good old Microsoft!

    ------------------
    Cheers

    Leave a comment:


  • Tom Hanlin
    replied
    Microsoft doesn't define the values outside of the API headers, as far as I know.

    A HANDLE or HWND is actually a DWORD, although LONG is close enough for most purposes. A BOOL is a LONG. A COLORREF is a DWORD.

    I think a FLOAT corresponds to a SINGLE. I suspect a BOOLEAN is a BYTE type. An ATOM is probably a DWORD. That's just guessing, though.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Guest's Avatar
    Guest started a topic HANDLE HWND and others...

    HANDLE HWND and others...

    Hello All!


    I was wondering if someone could help me find the API defines are
    for these and other variable types...

    HANDLE = LONG
    HWND = LONG
    ATOM = ?
    BOOL = ?
    BOOLEAN = ?
    COLORREF = ?
    FLOAT = ?
    etc...


    I know what those two are but there are other "windows" defined
    variable types that I would like to know what PB or C variable
    type they are made up from.

    Surly there is a page in the MSDN that decribes what each variable
    type really is. I have tried to use "find text" on the VisualStudio
    include files but there are far too many to search through.


    Thanks

    ------------------
    Cheers
Working...
X