oMeta difference FW & FWH?

oMeta difference FW & FWH?

Postby Marc Vanzegbroeck » Fri Aug 10, 2007 7:25 pm

Hi,

I'am moving a appliation from FW to FWH and have a problem with showing meta-files.

I have created a little sample that works in FW and not in FWH

Code: Select all  Expand view
#INCLUDE "fivewin.CH"
static sWnd
static sscaling  :=  3
func test()
   local oS: =5200
   local sx_offset := 0
   local sy_offset := 0
   local sregio    :=  3000

   DEFINE WINDOW sWnd TITLE 'Test' VSCROLL HSCROLL
   oMeta := TMetaFile():New( 38, 0, sregio+38, sregio,'tmp.dt',sWnd,CLR_BLACK,CLR_WHITE,sscaling,sscaling )

   ACTIVATE WINDOW sWnd MAXIMIZED ;
   VALID ( sWndOpen := .f. , .t.) on init sscale()

RETURN nil

FUNCTION sscale()
   local vverhouding:=1
   IF (sWnd:nright)-(sWnd:nleft) / (sWnd:nbottom - sWnd:ntop ) > 1.34
      vverhouding =(1024/768)/ ((sWnd:nright-sWnd:nleft) / (sWnd:nbottom - sWnd:ntop )) *1.15
   ENDIF
   sscaling := 5200 / ((sWnd:nright-sWnd:nleft) / 1032*  vverhouding)
   oMeta:nWidth  := sscaling
   oMeta:nHeight := sscaling
   oMeta:Refresh()
RETURN nil


The meta file is located
http://www.vms.be/FWTest/tmp.dt

Can anyone tell me why this is not working in FWH?
Thanks,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Fri Aug 10, 2007 8:53 pm

Marc,

Keep in mind that FWH uses 32 bits enhanced metafiles (EMF) instead of 16 bits Windows metafiles (WMF). Anyhow, if you rename it with .WMF extension, FWH will manage it too.

What file type is inside your DT file ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Fri Aug 10, 2007 9:39 pm

Antonio,

The tmp.dt file is a WMF-file create with the CreateMetaFile() function.
If I rename it to tmp.wmf , it still is't working.
Should I use CreateEnhMetaFile() function? I have tried it but did't succeed to get it to work.

Now I use something like:
Code: Select all  Expand view
hDCOut := CreateMetaFile('tmp.dt')
...
LineTo( hDCOut    , y_cor(inLeft + sx_offset ) ,  x_cor(430 - (inTop + sy_offset ))       , hPen)
...
TextOut( hDCOut, y_cor(y+3), x_cor(x), substr(text,1,at('.',text)-1)
...
CloseMetaFile( hDCOut )


How do I use CreateEnhMetaFile()? I see that I have to give 3 parameters instead of 1.

Thanks,
Marc[/code]
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Fri Aug 10, 2007 11:56 pm

Marc,

You have an example of its use at source\classes\printer.prg:

AAdd( ::aMeta, ::cDir + cTempFile( "\", "emf" ) )
::hDCOut := CreateEnhMetaFile( ::hDC, ATail( ::aMeta ), ::cDocument )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Sat Aug 11, 2007 8:33 am

Antonio,

That's where I found the example, but wat should I use for ' ::hDC'?
I see in the printer.prg that it is ' GetPrintDC()', but I don't want to print it. I only want to show it on screen.
I suppose that '::cDocument ' is a desciption of the file. Is that correct?

Regards,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Sat Aug 11, 2007 9:39 am

Marc,

You can do hdc = GetDC( 0 ) use it and finally do ReleaseDC( 0, hdc ).

Yes, cDocument is the name of the document.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Sat Aug 11, 2007 11:30 am

Antonio,

I have succeed to create te EMF-file, but if I want to display it I get the following error when I want to display it.

Code: Select all  Expand view
Application
===========
   Path and name: C:\FWH\Projects\oMeta\METATEST.exe (32 bits)
   Size: 1,272,832 bytes
   Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 08/11/07, 13:24:55
   Error description: Error BASE/1083  Argument error: *
   Args:
     [   1] = N   100.00
     [   2] = U   

Stack Calls
===========
   Called from: TMETAFIL.PRG => TMETAFILE:PAINT(0)
   Called from: TMETAFIL.PRG => (b)TMETAFILE:TMETAFILE(0)
   Called from:  => TMETAFILE:DISPLAY(0)
   Called from: CONTROL.PRG => TMETAFILE:HANDLEEVENT(0)
   Called from: WINDOW.PRG => _FWH(0)
   Called from:  => UPDATEWINDOW(0)
   Called from: WINDOW.PRG => TWINDOW:ACTIVATE(0)
   Called from: METATEST.PRG => TEST(18)


The code to read is is the same as in previous message, only 'tmp.dt' is changed in 'tmp.emf'

The emf file is
http://www.vms.be/FWTest/tmp.emf

Thanks,
Marc[/code]
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Sat Aug 11, 2007 12:18 pm

Marc,

Fixed. Are you using Harbour or xHarbour ? to email you a new lib.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Sat Aug 11, 2007 1:23 pm

Antonio,

I'am using xHarbour.

Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Sat Aug 11, 2007 1:49 pm

We already emailed you a modified LIB for xHarbour.

Please try your code again, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Sat Aug 11, 2007 2:48 pm

Thanks Antonio for the quick support.

It' working!!!

Best regards,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Sat Aug 11, 2007 5:25 pm

good :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Sat Aug 11, 2007 9:11 pm

Antonio,

There is only one problem if I want to create a second EMF-file. Then I get 'Error (32) creating Enhanced metafile'

Here is an example
Code: Select all  Expand view
#INCLUDE "fivewin.CH"
static sWnd
static nZFactor
FUNCTION test()
   local hPEN := CreatePen( 0 , 1, 0 )
   local w := getsysmetrics(0) - 10
   local h := getsysmetrics(1) - 68
   nZFactor = 1

   hdc = GetDC( 0 )
   hDCOut := CreateEnhMetaFile(hdc,'tmp.emf','testje')

   MoveTo( hDCOut, 0        , 0 )
   LineTo( hDCOut, 0        ,h      , hPen)

   LineTo( hDCOut, w     ,   h    , hPen)
   LineTo( hDCOut, w     ,   0    , hPen)
   LineTo( hDCOut, 0     ,   0    , hPen)
   LineTo( hDCOut, w     ,   h    , hPen)
   LineTo( hDCOut, w     ,   0    , hPen)
   LineTo( hDCOut, 0     ,   h    , hPen)

   CloseEnhMetaFile( hDCOut )
   ReleaseDC( 0, hdc )

   DEFINE WINDOW sWnd TITLE 'Test' VSCROLL HSCROLL
   oMeta := TMetaFile():New( 38, 0, w, h,'tmp.emf',sWnd,CLR_BLACK,CLR_WHITE,h,w )

   ACTIVATE WINDOW sWnd MAXIMIZED ;
   VALID ( sWndOpen := .f. , .t.)

   hdc = GetDC( 0 )
   hDCOut := CreateEnhMetaFile(hdc,'tmp.emf','testje')

   MoveTo( hDCOut, 0        , 0 )
   LineTo( hDCOut, 0        ,h      , hPen)

   LineTo( hDCOut, w     ,   h    , hPen)
   LineTo( hDCOut, w     ,   0    , hPen)
   LineTo( hDCOut, 0     ,   0    , hPen)

   CloseEnhMetaFile( hDCOut )
   ReleaseDC( 0, hdc )

   DEFINE WINDOW sWnd TITLE 'Test' VSCROLL HSCROLL
   oMeta := TMetaFile():New( 38, 0, w, h,'tmp.emf',sWnd,CLR_BLACK,CLR_WHITE,h,w )


   ACTIVATE WINDOW sWnd MAXIMIZED ;
   VALID ( sWndOpen := .f. , .t.)

RETURN nil


Can you tell me what I'm doing wrong?

Thanks,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Sat Aug 11, 2007 11:04 pm

Marc,

The error 32 means that the EMF file is still open ( "sharing violation" ) so you can not create it again.

You may use a different EMF filename as it seems that Windows takes some time to close it, even if we force it to do so:

ACTIVATE WINDOW sWnd MAXIMIZED ;
VALID ( sWndOpen := .f., DeleteEnhMetaFile( oMeta:hMeta ), .t.)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Tue Aug 14, 2007 5:58 am

Antonio

Everything is working fine but I have a question using 'hdc = GetDC( 0 )' with CreateEnhMetaFile(hdc,'tmp.emf','testje').
Using this, the dimentions of the meta-file is the same as the screen resolution. Is it possible to have a bigger meta-file. My program is creating drawings, and somethimes they are bigger than the screen resolution, and with the 16bit version, the meta file was bigger then the screen. I used the scroll-bars to show the rest.

Thanks,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 54 guests