Dynomotion

Group: DynoMotion Message: 13702 From: shannonjdavenport Date: 8/12/2016
Subject: kmotioncnc v 4.34a
Attachments :


Hi Tom,

Several months ago you made a modification to kmotioncnc which allowed my to open g code files in kmotioncnc from VB6.  That feature no longer works and pops up an error message in version 4.34a.  I attached the error message.  I'll go back to using Ver 4.33q.

Thanks, Shannon

  @@attachment@@
Group: DynoMotion Message: 13704 From: Tom Kerekes Date: 8/12/2016
Subject: Re: kmotioncnc v 4.34a [1 Attachment]
Attachments :

Hi Shannon,

Sorry we made changes to the interface to pass the filename string as a Unicode String rather than an Ascii String to support other languages.  KMotionCNC also now expects a return Window handle.  We have updated the SimpleFormsCS example (attached).  Please try making the following changes to your code.  Hopefully something similar exists in VB6?

Regards

TK


Add:

        static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, ref COPYDATASTRUCT lParam);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]


change:

            cds.dwData = 0;
            cds.lpData = (int)Marshal.StringToHGlobalAnsi(message);
            cds.cbData = message.Length+1;

            IntPtr KMotionCNCWindow = FindWindow("KMotionCNC", null);
            SendMessage(KMotionCNCWindow, (int)WM_COPYDATA, 0, ref cds);

to:

            cds.lpData = (int)Marshal.StringToHGlobalUni(message);
            cds.cbData = message.Length * 2 + 1;

            IntPtr KMotionCNCWindow = FindWindow("KMotionCNC", null);
            SendMessage(KMotionCNCWindow, (int)WM_COPYDATA, this.Handle, ref cds);



On 8/12/2016 10:07 AM, shannonjdavenport@... [DynoMotion] wrote:
 


Hi Tom,

Several months ago you made a modification to kmotioncnc which allowed my to open g code files in kmotioncnc from VB6.  That feature no longer works and pops up an error message in version 4.34a.  I attached the error message.  I'll go back to using Ver 4.33q.

Thanks, Shannon


  @@attachment@@
Group: DynoMotion Message: 13705 From: Shannon Davenport Date: 8/12/2016
Subject: Re: kmotioncnc v 4.34a [1 Attachment]
Thank you Tom,
I'll dig into it on Monday.

On Fri, Aug 12, 2016 at 3:18 PM, Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from Tom Kerekes included below]

Hi Shannon,

Sorry we made changes to the interface to pass the filename string as a Unicode String rather than an Ascii String to support other languages.  KMotionCNC also now expects a return Window handle.  We have updated the SimpleFormsCS example (attached).  Please try making the following changes to your code.  Hopefully something similar exists in VB6?

Regards

TK


Add:

        static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, ref COPYDATASTRUCT lParam);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]


change:

            cds.dwData = 0;
            cds.lpData = (int)Marshal. StringToHGlobalAnsi(message);
            cds.cbData = message.Length+1;

            IntPtr KMotionCNCWindow = FindWindow("KMotionCNC", null);
            SendMessage(KMotionCNCWindow, (int)WM_COPYDATA, 0, ref cds);

to:

            cds.lpData = (int)Marshal. StringToHGlobalUni(message);
            cds.cbData = message.Length * 2 + 1;

            IntPtr KMotionCNCWindow = FindWindow("KMotionCNC", null);
            SendMessage(KMotionCNCWindow, (int)WM_COPYDATA, this.Handle, ref cds);



On 8/12/2016 10:07 AM, shannonjdavenport@... [DynoMotion] wrote:
 


Hi Tom,

Several months ago you made a modification to kmotioncnc which allowed my to open g code files in kmotioncnc from VB6.  That feature no longer works and pops up an error message in version 4.34a.  I attached the error message.  I'll go back to using Ver 4.33q.

Thanks, Shannon



Group: DynoMotion Message: 13706 From: Shannon Davenport Date: 8/15/2016
Subject: Re: kmotioncnc v 4.34a
Hey Tom,
VB6 has a convert to unicode function so all I needed to do was add/change the highlighted lines.
Much Thanks,
Shannon


If GetHandleFromPartialCaption(lhWndP, "KMotionCNC") = True Then
    fn = StrConv(file, vbUnicode)
    CopyMemory buf(1), ByVal fn, Len(fn)
    cds.cbData = Len(file) * 2 + 1
    cds.lpData = VarPtr(buf(1))
    SendMessage lhWndP, WM_COPYDATA, Me.hwnd, cds
    SendMessage lhWndP, WM_COMMAND, 33018, 0
End If

On Fri, Aug 12, 2016 at 4:18 PM, Shannon Davenport sdavenport.roa@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Thank you Tom,
I'll dig into it on Monday.

On Fri, Aug 12, 2016 at 3:18 PM, Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from Tom Kerekes included below]

Hi Shannon,

Sorry we made changes to the interface to pass the filename string as a Unicode String rather than an Ascii String to support other languages.  KMotionCNC also now expects a return Window handle.  We have updated the SimpleFormsCS example (attached).  Please try making the following changes to your code.  Hopefully something similar exists in VB6?

Regards

TK


Add:

        static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, ref COPYDATASTRUCT lParam);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]


change:

            cds.dwData = 0;
            cds.lpData = (int)Marshal.StringToHGlobalAn si(message);
            cds.cbData = message.Length+1;

            IntPtr KMotionCNCWindow = FindWindow("KMotionCNC", null);
            SendMessage(KMotionCNCWindow, (int)WM_COPYDATA, 0, ref cds);

to:

            cds.lpData = (int)Marshal.StringToHGlobalUn i(message);
            cds.cbData = message.Length * 2 + 1;

            IntPtr KMotionCNCWindow = FindWindow("KMotionCNC", null);
            SendMessage(KMotionCNCWindow, (int)WM_COPYDATA, this.Handle, ref cds);



On 8/12/2016 10:07 AM, shannonjdavenport@... [DynoMotion] wrote:
 


Hi Tom,

Several months ago you made a modification to kmotioncnc which allowed my to open g code files in kmotioncnc from VB6.  That feature no longer works and pops up an error message in version 4.34a.  I attached the error message.  I'll go back to using Ver 4.33q.

Thanks, Shannon