Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling VFP form in .NET
Message
De
16/06/2007 04:10:41
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Calling VFP form in .NET
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01233711
Message ID:
01233711
Vues:
45
I'm doing something wrong here and cant quite put my finger on it. Class gets created ok but I can't get the VFP form to display anywhere. Hoping someone has an idea for me.

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TestClass
{
  public partial class Form1 : Form
    {
    public Form1()
      {
      InitializeComponent();
      }

    // ** I did this from a toolbar, but could go anywhere. **
    private void xonclick(object sender, EventArgs e)
      {
      //*********************************************
      myserver.myclass xform = new myserver.myclass();
      int prnt = (int) this.Handle;
      int y = xform.SetParent(prnt);
      //*********************************************
      }
    }
}
VFP
*This entirely self-contained program will build a COM server 
* called "myserver.myclass"
* It will unregister a prior instance, if any
IF PROGRAM() != "MYCLASS"
   ?"this file MUST BE NAMED 'myclass.prg'"
   return
ENDIF
IF FILE("myclass.dll")
   DECLARE integer DllUnregisterServer IN myclass.dll
   DllUnregisterServer()
   CLEAR DLLS
ENDIF
BUILD PROJECT myserver FROM myclass
BUILD DLL myserver from myserver recomp
*now test this COM server:
*ox = CreateObject("myserver.myclass")    && create the server object
*ox.mydocmd("USE home(1)+'samples\data\customer'")    && use a table
*?ox.myeval("RECCOUNT()")    && get the record count

DEFINE CLASS myclass AS Form OLEPUBLIC
   FUNCTION SetParent(ParentHWnd AS Long) AS Byte 

     *********************************************
     *********************************************
     DECLARE INTEGER SetParent IN user32;
        INTEGER hWndChild, INTEGER hWndNewParent

     IF SetParent(THIS.HWnd, ParentHWnd) <> 0
       THIS.Top     = 1
       THIS.Left    = 1
       THIS.Width   = 190
       THIS.Height  = 190
       THIS.Visible = .T.
       RETURN 1
     ENDIF
     RETURN 0
     *********************************************
     *********************************************

   ENDFUNC 
   FUNCTION Error(nError, cMethod, nLine)
      COMreturnerror(cMethod+'  err#='+str(nError,5)+;
         '  line='+str(nline,6)+' '+message(),_VFP.ServerName)
      && this line is never executed
   ENDFUNC 
ENDDEFINE
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform