Why the JPG is not displayed ?

Why the JPG is not displayed ?

Postby HunterEC » Thu Jun 03, 2010 5:34 am

Guys:

This should be an easy one, but I don't know why the JPG is not painted. What I'm trying to do is adjust the dialog size to the image size with a little more space for buttons. Here's the code:
Code: Select all  Expand view
#define NO_OF_COLS   INT(GetSysMetrics(0) / 7.933884297520661157)
#define NO_OF_ROWS   INT(GetSysMetrics(1) / 15.18987341772151898)

#include "Common.ch"
#include "Fivewin.ch"
#include "Image.ch"


//----------------------------------------------------------------------------//

function Main (cFile, cTitle)
   #define NDLG_HEIGHT  GetSysMetrics(1)
   #define NDLG_WIDTH   GetSysMetrics(0)
   #define NIMG_HEIGHT  oBMP1:nHeight()
   #define NIMG_WIDTH   oBMP1:nWidth()

   LOCAL oDlg, oBMP1, oSay1


   DEFAULT cFile  TO "Tempsig.jpg"
   DEFAULT cTitle TO "Default Title"

   // Your Image :
   DEFINE IMAGE oBmp1 FILENAME cFile
   IF OpenFile (@oBmp1, @cFile)
      DEFINE DIALOG oDlg FROM 00,00 TO NIMG_HEIGHT + 20,NIMG_WIDTH + 85 PIXEL
      oDlg:nTop    := NDLG_HEIGHT - NIMG_HEIGHT - 85
      oDlg:nLeft   := NDLG_WIDTH - NIMG_WIDTH - 105
      oDlg:nBottom := NDLG_HEIGHT - 65
      oDlg:nRight  := NDLG_WIDTH - 10

      @ 00,00 SAY oSay1 VAR cTitle OF oDlg CENTERED PIXEL SIZE NIMG_WIDTH - 10, 10;
             COLOR nRGB(255,255,255), nRGB(0,0,255)
      @ 10,00 IMAGE oBmp1 SIZE NIMG_WIDTH, NIMG_HEIGHT OF oDlg SCROLL PIXEL
      @ 10,NIMG_WIDTH + 5 BUTTON "&Imprimir" SIZE 30,10 OF oDlg PIXEL ;
        ACTION PrintImage( oBmp1)

      @ 55,NIMG_WIDTH + 5 BUTTON "&Terminar" SIZE 30,10 OF oDlg PIXEL ACTION oDlg:End()

      @ 110,NIMG_WIDTH + 5 CHECKBOX oBmp1:lStretch PROMPT "&Agrandar" SIZE 75, 10 OF oDlg ;
                PIXEL ON CHANGE ( oBmp1:ScrollAdjust(), oBmp1:Refresh() )

      ACTIVATE DIALOG oDlg ON PAINT oBmp1:SetFocus()
   ENDIF

   #undef NIMG_HEIGHT
   #undef NIMG_WIDTH

RETURN NIL
// EOF: Main

//----------------------------------------------------------------------------//

FUNCTION OpenFile (oImage, cFile)
   LOCAL lPass

   IF ! (lPass := FILE(cFile))
      MsgInfo("Esta Imagen No Existe: " + cFile)
   ELSE
      oImage:LoadBmp(cFile)
   ENDIF
RETURN (lPass)
* EOF: OpenFile


FUNCTION PrintImage( oImage )

   LOCAL oPrn

   PRINT oPrn NAME "Image Printing" PREVIEW
      PAGE
         oPrn:SayImage( 0, 0, oImage )
      ENDPAGE
   ENDPRINT

RETURN NIL
* EOF: PrintImage
 
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Why the JPG is not displayed ?

Postby ukoenig » Thu Jun 03, 2010 11:12 am

Some changes needed.

Image

DIALOG oDlg ON PAINT returns the calculated Size-Values : 592 x 422 ( OK ! )
Width : 500 + 85 + Border
Height : 375 + 20 + Dialog-Title + Border

to calculate exact Control-Positions, it works only with these changes :
@ 20, 255 BUTTON oBtn1 PROMPT "&Imprimir" SIZE 30,10 OF oDlg PIXEL ;
ACTION PrintImage( oBmp1)

@ 55, 255 BUTTON oBtn2 PROMPT "&Terminar" SIZE 30,10 OF oDlg PIXEL ACTION oDlg:End()

ACTIVATE DIALOG oDlg ON PAINT ( oBMP1:LoadBmp(cFile), ;
oDlg:Move( 50, 50, .f. ), ; // Move Dialog
oBmp1:Move( 10, 0, NIMG_WIDTH, NIMG_HEIGHT, .f. ) , ; // Move Image
oBtn1:Move( 20, oDlg:nWidth - 75, .f. ), ; // Move Button1
oBtn2:Move( 80, oDlg:nWidth - 75, .f. ) ) // Move Button2

Code: Select all  Expand view

#define NO_OF_COLS   INT(GetSysMetrics(0) / 7.933884297520661157)
#define NO_OF_ROWS   INT(GetSysMetrics(1) / 15.18987341772151898)

#include "Common.ch"
#include "Fivewin.ch"
#include "Image.ch"

//----------------------------------------------------------------------------//

function Main ()

// not needed because calculated from Image-Size
//   #define NDLG_HEIGHT  GetSysMetrics(1)
//   #define NDLG_WIDTH   GetSysMetrics(0)

// cannot work because Image not open !!!
//   #define NIMG_HEIGHT  oBMP1:nHeight()
//   #define NIMG_WIDTH   oBMP1:nWidth()

LOCAL oDlg, oBMP1, oSay1, oBrush1, NIMG_HEIGHT := 0, NIMG_WIDTH := 0, ;
    cFile := ".\system\Tempsig.jpg", ;  // 500 x 375 Pixel
    cTitle := "Default Title"

oTextFont := TFont():New("Arial",0,-12,.F.,.T.,0,0,0,.T. )

IF File (cFile) // Ask if Image exists ( no Function )
    DEFINE IMAGE oBmp1 FILENAME cFile
        DEFINE BRUSH oBrush1 FILENAME ".\SYSTEM\Marble.bmp"
    NIMG_HEIGHT := oBMP1:nHeight() // 375
    NIMG_WIDTH := oBMP1:nWidth() // 500

    DEFINE DIALOG oDlg FROM 00,00 TO NIMG_HEIGHT + 20,NIMG_WIDTH + 85 ;
    BRUSH oBrush1  PIXEL TRANSPARENT
     
       // not needed and cannot work because Dialog is not opend !!!
       // oDlg:nTop    := NDLG_HEIGHT - NIMG_HEIGHT - 85
       // oDlg:nLeft   := NDLG_WIDTH - NIMG_WIDTH - 105
       // oDlg:nBottom := NDLG_HEIGHT - 65
       // oDlg:nRight  := NDLG_WIDTH - 10

      @ 0, 0 SAY oSay1 VAR cTitle OF oDlg CENTERED PIXEL SIZE oDlg:nWidth - 50, 10 ;
      COLOR 0 FONT oTextfont

      @ 10, 0 IMAGE oBmp1 OF oDlg SIZE NIMG_WIDTH, NIMG_HEIGHT SCROLL PIXEL
 
      @ 20, 255 BUTTON "&Imprimir" SIZE 30,10 OF oDlg PIXEL ;
        ACTION PrintImage( oBmp1)

      @ 55, 255  BUTTON "&Terminar" SIZE 30,10 OF oDlg PIXEL ACTION oDlg:End()

      @ 110, 255  CHECKBOX oBmp1:lStretch PROMPT "&Agrandar" SIZE 40, 10 OF oDlg ;
                PIXEL ON CHANGE ( oBmp1:ScrollAdjust(), oBmp1:Refresh() ) FONT oTextFont

      ACTIVATE DIALOG oDlg ON PAINT ( oBMP1:LoadBmp(cFile), ;
                                        oDlg:Move( 50, 50, .f. ))  // Move Dialog                                          
ELSE  
       MsgInfo("Esta Imagen No Existe: " + cFile)
ENDIF

oTextFont:End()

// not needed
//   #undef NIMG_HEIGHT
//   #undef NIMG_WIDTH

RETURN NIL
// EOF: Main

// --------------------------

FUNCTION PrintImage( oImage )

   LOCAL oPrn

   PRINT oPrn NAME "Image Printing" PREVIEW
      PAGE
         oPrn:SayImage( 0, 0, oImage )
      ENDPAGE
   ENDPRINT

RETURN NIL
* EOF: PrintImage
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Why the JPG is not displayed ?

Postby HunterEC » Fri Jun 04, 2010 4:39 am

Uwe:

Thank for your help. I'm using FiveWin 8.10 (October 2008) and compiling the program that you posted the image displays outside the dialog. Any ideas ? Also I'm trying to display the image at the bottom right corner of the screen. Thank you.

PD.: I don't know how to post the screenshot. :oops:
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Why the JPG is not displayed ?

Postby ukoenig » Fri Jun 04, 2010 10:52 pm

That is the Syntax, to show the Image together with the Post.

[img] at start
[/img] at End
A place where to store the Image ( my homepage with a Subdir \Pictures )
Image

I think a better Solution, for that what You want to do is :
1. creating the Dialog with all needed Controls ( Gets, Says, Buttons, Checkboxes ... )
2. Show the Image on a defined Position inside the Dialog.
not calculating the Dialog in Relation to the Image-Size,
because You want to use a Image-Scroll to keep the original Image-Size.

You can send a Screenshot to my Email-address, if You like.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Why the JPG is not displayed ?

Postby ukoenig » Tue Jun 08, 2010 10:31 pm

Hello Gustavo,

I had a look at Your Screenshot. I understand the Image is displayed twice
( 1 outside of the Window ) ?

For a quick Design, I'm working on a little painter.
You can resize the Window and place the Controls on the Positions You need.

There are Buttons to show all Control-positions,
create the PRG- and EXE-file of the Design,
and define a Image or Brush for the Background.

Rearange the Controls and place the non needed to a unused Area
You will get a PRG and Exe-File of the selected Settings
Delete the unused Controls from the Prg.
The PRG is shown with a Editor, before You will be asked to create the EXE-file.

Image

Easy to use :

A Test with :
a resized Window and Image,
a selected Gradient-Background
and 5 selected Buttons

Image

Each Control performs a Action on Right Mouseclick ( because of DESIGN Mode )
This Sample shows the define of the 1. Gradient-Color

Image

Best Regards
Uwe :lol:
Last edited by ukoenig on Wed Jun 09, 2010 3:06 pm, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Why the JPG is not displayed ?

Postby HunterEC » Wed Jun 09, 2010 11:51 am

Uwe:

Thank you. I'll wait for your tool.

Gustavo
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Why the JPG is not displayed ?

Postby ukoenig » Wed Jun 09, 2010 12:21 pm

Hello Gustavo,

I tested Your Sample and noticed non activated Buttons.
I added one Line and got it working :

Image

Best regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 135 guests