DDE - C - sendmessage

Just starting out? Need help? Post your questions and find answers here.
patrick88
User
User
Posts: 18
Joined: Sat May 03, 2003 10:30 am

DDE - C - sendmessage

Post by patrick88 »

hi

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) ;
no particular problem for "adapt" this code
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
thanks

patrick88
eriansa
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Mar 17, 2004 12:31 am
Contact:

Post by eriansa »

looks good to me. (it's a pointer to a bytearray)
Post Reply