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