Page 1 of 2
oMeta difference FW & FWH?
Posted:
Fri Aug 10, 2007 7:25 pm
by Marc Vanzegbroeck
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.dtCan anyone tell me why this is not working in FWH?
Thanks,
Marc
Posted:
Fri Aug 10, 2007 8:53 pm
by Antonio Linares
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 ?
Posted:
Fri Aug 10, 2007 9:39 pm
by Marc Vanzegbroeck
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]
Posted:
Fri Aug 10, 2007 11:56 pm
by Antonio Linares
Marc,
You have an example of its use at source\classes\printer.prg:
AAdd( ::aMeta, ::cDir + cTempFile( "\", "emf" ) )
::hDCOut := CreateEnhMetaFile( ::hDC, ATail( ::aMeta ), ::cDocument )
Posted:
Sat Aug 11, 2007 8:33 am
by Marc Vanzegbroeck
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
Posted:
Sat Aug 11, 2007 9:39 am
by Antonio Linares
Marc,
You can do hdc = GetDC( 0 ) use it and finally do ReleaseDC( 0, hdc ).
Yes, cDocument is the name of the document.
Posted:
Sat Aug 11, 2007 11:30 am
by Marc Vanzegbroeck
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.emfThanks,
Marc[/code]
Posted:
Sat Aug 11, 2007 12:18 pm
by Antonio Linares
Marc,
Fixed. Are you using Harbour or xHarbour ? to email you a new lib.
Posted:
Sat Aug 11, 2007 1:23 pm
by Marc Vanzegbroeck
Antonio,
I'am using xHarbour.
Marc
Posted:
Sat Aug 11, 2007 1:49 pm
by Antonio Linares
We already emailed you a modified LIB for xHarbour.
Please try your code again, thanks
Posted:
Sat Aug 11, 2007 2:48 pm
by Marc Vanzegbroeck
Thanks Antonio for the quick support.
It' working!!!
Best regards,
Marc
Posted:
Sat Aug 11, 2007 5:25 pm
by Antonio Linares
good
Posted:
Sat Aug 11, 2007 9:11 pm
by Marc Vanzegbroeck
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
Posted:
Sat Aug 11, 2007 11:04 pm
by Antonio Linares
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.)
Posted:
Tue Aug 14, 2007 5:58 am
by Marc Vanzegbroeck
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