MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Mathlink Question

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg801] Mathlink Question
  • From: Paolo Aldeghi <ALDEGHI at imimnvx.irfmn.mnegri.it>
  • Date: Fri, 21 Apr 1995 01:40:20 -0400

Dear Sirs,
  
  I'm developing a program to study two dimensional Dinamical System. My 
application uses Mathematica Kernel to make simbolic and numeric calculous.
I'm writing in Microsoft Visual C++ and I use Mathlink to connect to 
Mathematica kernel. To draw the postscript output that Mathematica produce
to the window screen, I use the three functions included in MVPOST.DLL. 
These three functions are:

         PSStart(char *)
         PSAddData(char *)
         PSDraw(HWND,HDC,int,int,int,int)

  Because I don't find any documentation about them, I saw the FE Visual 
Basic Example that is included in MathLink distribution disckette. In that
example, the call to PSDraw function, is the following:


         hPS = PSDraw(Form1!PSOut.hWnd, Form1!PSOut.hDC, 0, 0, 
                  Form1!PSOut.ScaleWidth, Form1!PSOut.ScaleHeight)
                  
  If I understand, PSDraw create a new bitmap and a new DC. In the
bitmap it draw the graphic output and then insert the bitmap in the
DC created. PSDraw return the handle of device context created. 
Infact, used in this mode, with a call to the subsequent BitBlt 
function, the graphic appear in the window. My problem is the 
following:

  because a Device Context must be deleted with DeleteDC function 
when it does not be usefull, and because it must hold the initial 
handle of bitmap when I try to delete it, I can't make it because 
the handle of the initial bitmap was lost in DLL function call. 
This produce some errors in my program, when I execute it because 
the Debuger tell me "Too many GetDC call. GetDC cache is full".
I tried to put a initial object from another DC in the device 
context returned from PSDraw and then Delete it, but it doesn't 
seem to work. By this trick, I could minimizing the lost of memory
because I could delete the bitmap returned from SelectObject. But
the device context produce always the same error.

However, also the Fe.exe example program produce same errors when
it draw the graphic output of Mathematica. Infact, fe.exe lost the
memory used by PSDraw to create the bitmap.

  Also, I'd like to know why I must call PSDraw with HWND and HDC, 
and if someone know if the handle returned by PSDraw is from a GetDC 
or from a CreateCompatibleDC, or from CreateDC call.

  If someone know a host where I can find some document about my 
problem, or if someone know the solution of it, I'll be grateful.

Best Regards.               
                                                
               Paolo Aldeghi
               Istituto di Ricerche Farmacologiche Mario Negri
               via Eritrea 62
               20157 Milano
               Italy       
               
               ALDEGHI at IMIMNVX.IRFMN.MNEGRI.IT
               ALDEGHI at GHOST.DSI.UNIMI.IT
               


  • Prev by Date: Programming Options for Power Expand
  • Next by Date: Re: Extracting data points from Plot[]
  • Previous by thread: Re: Programming Options for Power Expand
  • Next by thread: Factorization package