Announcement

Collapse
No announcement yet.

Type problem – C++ to PB

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

  • Type problem – C++ to PB

    Code:
    // hyperlink behavior is using this to send its "clicks" state
    struct NMHL_HYPERLINK
    {
      enum type { ENTER = 1, LEAVE, CLICK };
     
      NMHDR hdr;
      type     action;
      WCHAR    szHREF[MAX_URL_LENGTH];
      WCHAR    szTarget[MAX_URL_LENGTH];
      HELEMENT he;
    };
    I have:
    Code:
    TYPE NMHL_HYPERLINK
      typeC    AS LONG
      hdr      AS NMHDR
      action   AS ????                                                        ‘What type?
      szHREF   AS ASCIIZ*%MAX_URL_LENGTH
      szTarget AS ASCIIZ*%MAX_URL_LENGTH
      he       AS DWORD
    END TYPE
    Keith


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


    [This message has been edited by Keith Waters (edited April 13, 2005).]

  • #2
    Code:
    TYPE NMHL_HYPERLINK
      hdr AS NMHDR
      action AS LONG
      szHREF AS STRING * (%MAX_URL_LENGTH * 2 - 1)
      szTarget AS STRING * (%MAX_URL_LENGTH * 2 - 1)
      he AS DWORD
    END TYPE

    ------------------
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Jose – Many thanks. Care to educate me?
      Code:
        enum type { ENTER = 1, LEAVE, CLICK };
      Ok – this declares “type” which should be LONG – I can see that. But why should szHRef and szTarget be STRING, when Hungarian notation says ASCIIZ and why *(%MAX_URL_LENGTH * 2 - 1)?

      Keith


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

      Comment


      • #4
        Ok after some searching, under Windows API wchar is 16 bit. That explains the *2, I think.

        Keith


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

        Comment


        • #5
          WCHAR means that it is an unicode string contained in an asciiz string.
          Unicode is a two byte encoding, so we have to multiply by 2, but as it
          is contained in an asciiz string it must be terminated with a single
          $NUL, not two, so we have to substract one. I'm using a fixed-length
          string instead of an asciiz string because the PB compilers will stop
          at the first $NUL if it is an asciiz string.

          You can find similar translations in the Win32Api.inc file, i.e.:
          Code:
          typedef struct {
              DWORD cbSize;
              DWORD dwSignature;
              CHAR szTarget[MAX_PATH];
              WCHAR swzTarget[MAX_PATH];
          } EXP_SZ_LINK, *LPEXP_SZ_LINK;
          translated as:
          Code:
          TYPE EXP_SZ_LINK
              cbSize AS DWORD                    ' Size of this extra data block
              dwSignature AS DWORD               ' signature of this extra data block
              szTarget AS STRING * %MAX_PATH     ' ANSI target name w/EXP_SZ in it
              swzTarget AS STRING * (%MAX_PATH * 2 - 1) ' UNICODE target name w/EXP_SZ in it
          END TYPE

          ------------------
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            Excellent Jose – much appreciated.

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

            Comment


            • #7
              Hey Jose, I don't know if you saw my post concerning the high
              level graphic tool called OGRE (www.ogre3d.org) that works on
              top of either DirectX or OpenGL. The SDKs are intended for
              C++ (except one for Python), and the writeup mentions both
              Objects and COM. Would you care comment on what you think it
              would take to adapt the available code there to work with PB?
              I really like the idea of some degree of independence from
              having to chose between DirectX (Windows only) and OpenGL (cross
              platform graphical package).

              ------------------
              Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

              Comment


              • #8
                I don't see how it could be used with PB. There is not a flat API, but
                a bunch of OOP C++ classes. Some time ago I began to make wrappers for
                DirectX9, but I had to stop because I had problems with the CreateDevice
                method causing some sort of memory corruption. The main problem is that
                I know low level COM programming, but I have no idea of graphics programming.


                [This message has been edited by José Roca (edited April 14, 2005).]
                Forum: http://www.jose.it-berater.org/smfforum/index.php

                Comment


                • #9
                  Shoot. Well, I figured it might be a reach. You did a good job
                  with JAComp, and I figured that if you could see a way to do it,
                  it would be worth attempting.

                  I've also thought about writing extensions with PureBasic, since
                  it uses OGRE and has integrated commands for graphics into the
                  language. But I get confused between what is known in PureBasic,
                  what is known in PowerBasic, and what needs to be passed from one
                  to the other. It's not as clean as I would like, because it is
                  a struggle between devising a graphical effect and trying to
                  write code in one language that takes advantage of features in
                  another language that is suppose to create that effect.

                  Of course one problem with trying to write extensions with
                  PureBasic is that the license for use forbids writing just
                  wrapper functions for use with other languages. Now how much
                  code needs to be written before it is no longer just a wrapper
                  process is not clear.

                  Another issue is the scope of certain operations. For instance,
                  different images require different image encoders and decoders.
                  In PureBasic, I can elect which plugins to incorporate. But
                  once the PureBasic DLL is created, I cannot make further
                  elections from the language being used with that DLL. So either
                  you have the functionality included by default, or you have to
                  have the ability to revise or extend the DLL code when needed.

                  I see a need for a forum devoted to just interfacing issues when
                  trying to use PB in conjunction with DLLs, static libraries,
                  header file conversions, data type conversions, database engines,
                  web tools and languages, and a host of other issues. Maybe it could
                  be called INTERFACES or something. The idea is to bring together
                  those that are trying to find answers to similar problems.
                  Right now that information is scattered over several forums and
                  goes back into the archives, and search results are dependent on
                  you ability to pick the right words or recognize the work of
                  some of the contributors and follow their past posts.

                  ------------------
                  Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                  Comment

                  Working...
                  X