SHOW A BITMAP ON A DIALOG AND TO PRINTER

SHOW A BITMAP ON A DIALOG AND TO PRINTER

Postby Silvio » Tue Mar 02, 2010 5:25 pm

i HAVE A BITMAP FILE WITH THIS SIZE 612x403

I MUST SHOW THIS BITMAP ON DIALOG FIRST TO INSERT ON IT DATA INFORMATION AND THEN i MUST PRINT IT

THEN I MUST PRINT THE BITMAP : IT MUST BE WITH THESE MEASURES :

HEIGHT 2.125 ( INCHES) -> 5,39 CM
WIDTH 3.375'' (INCHES) -> 8 CM

1.) How I can show the bimap on a dialog inches -> pixel ?
2.) How I can print the bitmap on printer with that measures ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: SHOW A BITMAP ON A DIALOG AND TO PRINTER

Postby Silvio » Tue Mar 02, 2010 5:59 pm

I make a test to understand my problem


the bitmap

Image

the test

Code: Select all  Expand view
#include "FiveWin.ch"

#define  BADGE_H    3.375       //8 CM
#define  BADGE_V    2.125       //5,39 CM

#define HORZSIZE          4
#define VERTSIZE          6
#define HORZRES           8
#define VERTRES          10
#define LOGPIXELSX       88
#define LOGPIXELSY       90


#define Badge0001 "badge000.bmp"

STATIC oBack

Function test()
    Local oDlg

       DEFINE DIALOG oDlg  FROM 317, 612 TO 830, 1250 PIXEL

       oDlg:SetColor(0,RGB(143,172,230))

       SIZE_H :=  nInches2Pixels( oDlg:hdc, BADGE_H, .F. )
       SIZE_V :=  nInches2Pixels( oDlg:hdc, BADGE_V, .T. )

       @ 2.3,1.5 BITMAP oBack  FILENAME Badge0001    TRANSPARENT  SIZE  SIZE_H, SIZE_V
      oBack:ltransparent:=.T.


ACTIVATE DIALOG oDlg   CENTERED


FUNCTION nInches2Pixels( hDC, nInches, lVertical )
Return (nInches * GetDeviceCaps( hDC, If(lVertical, LOGPIXELSY, LOGPIXELSX) ) )
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: SHOW A BITMAP ON A DIALOG AND TO PRINTER

Postby Daniel Garcia-Gil » Tue Mar 02, 2010 6:58 pm

Silvio...

1. becarefull with the bitmap filename... in you sample the bmp name is "badge006.bmp" and the define is "badge000.bmp"

2. in function nInches2Pixels you need a valid Dialog HDC... you should do oDlg:GetDC() before and oDlg:ReleaseDC() after use

3. you need to learn debug you own code ( 2 suggestions )
3.1 verify all parameters values sent and returned
3.2 trace step by step all process

Code: Select all  Expand view

#include "FiveWin.ch"

#define  BADGE_H    3.375       //8 CM
#define  BADGE_V    2.125       //5,39 CM

#define HORZSIZE          4
#define VERTSIZE          6
#define HORZRES           8
#define VERTRES          10
#define LOGPIXELSX       88
#define LOGPIXELSY       90


#define Badge0001 "badge006.bmp"

STATIC oBack

Function test()
    Local oDlg

       DEFINE DIALOG oDlg  FROM 317, 612 TO 830, 1250 PIXEL

       oDlg:SetColor(0,RGB(143,172,230))

       oDlg:GetDC()
       SIZE_H :=  nInches2Pixels( oDlg:hdc, BADGE_H, .F. )
       SIZE_V :=  nInches2Pixels( oDlg:hdc, BADGE_V, .T. )
       
       oDlg:ReleaseDC()
       @ 2.3,1.5 BITMAP oBack  FILENAME Badge0001 TRANSPARENT  SIZE  SIZE_H, SIZE_V NOBORDER
      oBack:ltransparent:=.T.


ACTIVATE DIALOG oDlg   CENTERED


FUNCTION nInches2Pixels( hDC, nInches, lVertical )
Return (nInches * GetDeviceCaps( hDC, If(lVertical, LOGPIXELSY, LOGPIXELSX) ) )
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: SHOW A BITMAP ON A DIALOG AND TO PRINTER

Postby Silvio » Tue Mar 02, 2010 8:52 pm

thanks a lot
then I have another problem perhaps
I use Tregla class, an old class to show a ruler on dialog and the measure are not equal to bitmap

look this image first
Image

THEN THE BITMAP OF EMPLOYER NOT IS TRANSPARENT. i USE BMP,JPG,GIF
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: SHOW A BITMAP ON A DIALOG AND TO PRINTER

Postby Daniel Garcia-Gil » Tue Mar 02, 2010 9:03 pm

Silvio...

i did explained you in this post

http://forums.fivetechsupport.com/viewtopic.php?p=95402#p95402

the transparency come from parent brush... look you bitmap posted, you can see the "SAY" transparent with parent brush.... if you want make a employed bitmap you should convert the badge006.bmp like a brush

i never used class TRegla sorry
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: SHOW A BITMAP ON A DIALOG AND TO PRINTER

Postby Silvio » Tue Mar 02, 2010 9:37 pm

I not understand How make it
PERHAPS i CORRECT THE RULER but not the transparent bitmap

Image



if I converte the badge as a brush then I cannot insert the ruler ...BUTTONBAR AND MESSAGEBAR





LOOK IT PLEASE

Image


the code

Code: Select all  Expand view









Function test()
    Local oDlg
    Local oBrush :=Badge0001

         DEFINE BRUSH oBrush FILE Badge0001
         DEFINE DIALOG oDlg  size 612,403 PIXEL BRUSH oBrush
 ACTIVATE DIALOG oDlg   CENTERED  ;
     ON INIT( BuildControls( oDlg ),Paint_foto(oDlg))
RETURN NIL


Function paint_foto(oWnd)
   Local cfoto := "dip.gif"
   Local cImpresa:= "<< Empresa >>"
   Local cSede:= "<< Address >>"
   Local oSay[10],oFont[10]
   Local oImg

           DEFINE FONT oFont[1] NAME "Arial" SIZE 0,-24
           DEFINE FONT oFont[2] NAME "Arial" SIZE 0,8

     @ 3, 2 SAY oSay[1] PROMPT cImpresa OF  oWnd  DESIGN SIZE 250, 24   TRANSPARENT    FONT oFont[1]
     @ 4, 2 SAY oSay[2] PROMPT cSede OF  oWnd  DESIGN SIZE 80, 20   TRANSPARENT      FONT oFont[2]
     @ 13, 12 IMAGE oImg FILENAME cFoto OF oWnd DESIGN   SIZE 180,210  NOBORDER TRANSPARENT


     return nil

static Function BuildControls( oDlg )
local oMenu, oBar
MENU oMenu  2007
   MENUITEM "&Information"
     MENU
       MENUITEM "&Informa......"
       SEPARATOR
       MENUITEM "&Exit" ACTION oDlg:End()
     ENDMENU

   MENUITEM "&?"    ACTION MsgAbout()
ENDMENU
oDlg:SetMenu( oMenu )
DEFINE BUTTONBAR oBar OF oDlg    2007
  SET MESSAGE OF  oDlg TO "test badge"  NOINSET   2007
   DEFINE MSGITEM   oRowCursor  OF oDlg:oMsgBar SIZE  60 COLOR "R+/W" TOOLTIP "Row mm"
   DEFINE MSGITEM   oColCursor  OF oDlg:oMsgBar SIZE  60 COLOR "R+/W" TOOLTIP "Col mm"
return( 0 )
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: SHOW A BITMAP ON A DIALOG AND TO PRINTER

Postby Silvio » Tue Mar 02, 2010 9:41 pm

do you think about to insert a dialog with style nor 4 with the size of badge into the main dialog ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 94 guests