i would to convert a c code to purebasic
this code make a DDE link between a extern program and autocad
Code: Select all
HWND hwnd_Acad;
WORD wm_acad;
char *ac = "\3\3ligne 0.0,0.0 3.4,4.5 6.6,7.7 \n";
wm_acad = registerwindowmessage("WM_ACAD");
hwnd_Acad = FindWindow("AUTOCAD.gfx",NULL);
If (hwnd_Acad != NULL)
  SendMessage(hwnd_Acad, wm_acad, 0, (LONG)(LPBYTE)ac) ;
except on the line code :
SendMessage(hwnd_Acad, wm_acad, 0, (LONG)(LPBYTE)ac)
i'm don't know to convert this (LONG)(LPBYTE)ac
my "convert" code
Code: Select all
Global chaine.s 
Global Acad_title.s
chaine = "ligne 0.0,0.0 3.4,4.5 6.6,7.7"+Chr(0)
Procedure ListWindows (window, parameter) 
    MemoryID = ReAllocateMemory (0, 255)
    GetClassName_ (window, MemoryID, 255) 
    class$ = PeekS (MemoryID) 
    
    MemoryID = ReAllocateMemory (0, 255)
    GetWindowText_ (window, MemoryID, 255) 
    title$ = PeekS (MemoryID) 
    FreeMemory (0) 
    
    ;Debug Chr (34) + title$ + Chr (34) + " / Class: " + class$ 
    If FindString(UCase(title$),"AUTOCAD",1)=1
      Acad_title = title$
    EndIf
    
    ProcedureReturn #True 
EndProcedure 
EnumWindows_ (@ListWindows (), 0)
CallDebugger
  
wm_acad.w = registerwindowmessage_("WM_ACAD")
hwnd_Acad.l = FindWindow_(0,Acad_title)
If hwnd_Acad<>0
  result.l = SendMessage_(hwnd_Acad,wm_acad,0,@chaine)  
EndIf
Debug "fini"
End
patrick88

