Announcement

Collapse
No announcement yet.

Convert from C

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

  • Convert from C

    I don't know C and have to convert some code. Can someone tell me if I have converted the folling code correctly?

    C code
    Code:
    #define MDPLUGIN_MSG     22000
    #define MDPLUGIN_DISPLAY 22001
    
    extern "C" void _stdcall MessageFunc(HWND Parent, const char* File)
    {
      COPYDATASTRUCT Packet;
      
      char Buffer[512];
      sprintf(Buffer, "Now processing: %s", File);
    
      Packet.dwData = MDPLUGIN_DISPLAY;
      Packet.cbData = strlen(Buffer);
      Packet.lpData = Buffer;
      
      SendMessage(Parent, MDPLUGIN_MSG, MDPLUGIN_DISPLAY, 
                  (LPARAM)(PCOPYDATASTRUCT)&Packet);
    }
    My Convertion
    Code:
    %MDPLUGIN_MSG     = 22000
    %MDPLUGIN_DISPLAY = 22001
    
    SUB MessageFunc(HWND AS DWORD, File AS ASCIIZ) EXPORT
      DIM Packet AS COPYDATASTRUCT
      DIM Buffer AS ASCIIZ * 512
      
      Buffer = "Now processing: " & File
      
      Packet.dwData = %MDPLUGIN_DISPLAY
      Packet.cbData = LEN(Buffer)
      Packet.lpData = VARPTR(Buffer)
                                    
      SendMessage HWND, %MDPLUGIN_MSG, %MDPLUGIN_DISPLAY, Packet                                
    
    END SUB
    ------------------
    -- Doug



    [This message has been edited by Doug Bulmer (edited November 04, 2004).]
    --
    Doug

  • #2
    Couple changes...

    ByVal hParent As Dword (1st param)
    zFile As Asciiz (2nd param, File is a reserved word)

    And the last parameter of SendMessage should be "VarPtr(Packet)"

    Other than that, looks good to me

    ------------------
    email
    http://www.kgpsoftware.com
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Thanks Kev. It is working now.


      ------------------
      -- Doug
      --
      Doug

      Comment


      • #4
        SUB MessageFunc (BYVAL HWND AS DWORD, zFile AS ASCIIZ) ALIAS "MessageFunc" EXPORT


        ------------------
        Tom Hanlin, PowerBASIC Staff
        Opinions expressed may not be those of my employer or myself

        Comment

        Working...
        X