Nueva funcion MsgImage()

Nueva funcion MsgImage()

Postby RSalazarU » Mon Mar 30, 2015 1:03 am

Amigos del foro:

Estoy probando esta funcion, haber si la mejoramos entre todos.

En la siguiente imagen se tiene una imagen asociada a un producto, y MsgImage() muestra la imagen en una ventana separada cada vez que se mueve el cursor.
Image

Code: Select all  Expand view
//---------------------------------//
//cBuffer: carga la imagen de memoria
//cResource: carga la imagen de recurso
//cFile: carga la imagen desde archivo
//cTitulo: titulo de la ventana
//nStyle: Style del dialogo
//lModal:
//nTime: si es NO modal, indica el tiempo que permanecera abierto la ventana
//lWndAdjust: indica si la ventana se ajustara al tamaño de la imagen
//lImgAdjust: indica si la imagen se ajustara al tamaño de la ventana
//nTop, nLeft, nWidth, nHeight: si no se pasa estos parametros, la imagen aparece centrada en la pantalla
function MsgImage( cBuffer, cResource, cFile, cTitulo, nStyle, lModal, nTime, lWndAdjust, lImgAdjust, nTop, nLeft, nWidth, nHeight )
   local oDlg, oImage, oTmr

   DEFAULT cTitulo := "Mostrando la imagen.. / Showing image..",;
       lModal := .T.,;
       lWndAdjust := .T.,;
       lImgAdjust := .F.

   if !EMPTY(cBuffer)// <> NIL

      DEFINE IMAGE oImage
      oImage:LoadFromMemory( cBuffer )

   elseif !EMPTY(cResource)// <> NIL

      DEFINE IMAGE oImage RESOURCE cResource

   elseif !EMPTY(cFile)// <> NIL

      cFile := alltrim( cFile )
      if .not. "." $ cFile
         cFile += ".BMP"
      endif
      DEFINE IMAGE oImage FILE cFile

   endif

   if oImage <> NIL
      DEFAULT nWidth := oImage:nWidth(),;
              nHeight := oImage:nHeight()
      if lWndAdjust
         nWidth := MAX(48,oImage:nWidth())
         nHeight := MAX(48,oImage:nHeight())
      endif

      if nTop=NIL .AND. nLeft=NIL
         DEFINE DIALOG oDlg TITLE cTitulo ;
         SIZE MIN(600,nWidth), MIN(400,nHeight) ;
         STYLE nStyle ;
     PIXEL
      else
         DEFINE DIALOG oDlg TITLE cTitulo ;
         FROM nTop, nLeft TO if(nTop=NIL,0,nTop) + MIN(400,nHeight), if(nLeft=NIL,0,nLeft) + MIN(600,nWidth) ;
         STYLE nStyle ;
     PIXEL
      endif

      if lModal
         ACTIVATE DIALOG oDlg CENTERED ;
            ON PAINT PalBmpDraw( hDC, 0, 0, oImage:hBitmap,, if(lImgAdjust,oDlg:nWidth()-if(lAnd( oDlg:nStyle, WS_BORDER ),6,0),NIL), if(lImgAdjust,oDlg:nHeight()-if(lAnd( oDlg:nStyle, WS_CAPTION ),28,0),NIL) ) ;
        VALID (oImage:End(),.T.)
      else
         if nTop=NIL .AND. nLeft=NIL
            ACTIVATE DIALOG oDlg CENTERED ;
            ON PAINT PalBmpDraw( hDC, 0, 0, oImage:hBitmap,, if(lImgAdjust,oDlg:nWidth()-if(lAnd( oDlg:nStyle, WS_BORDER ),6,0),NIL), if(lImgAdjust,oDlg:nHeight()-if(lAnd( oDlg:nStyle, WS_CAPTION ),28,0),NIL) ) ;
        VALID (oImage:End(),.T.) ;
        NOWAIT
     else
            ACTIVATE DIALOG oDlg ;
            ON PAINT PalBmpDraw( hDC, 0, 0, oImage:hBitmap,, if(lImgAdjust,oDlg:nWidth()-if(lAnd( oDlg:nStyle, WS_BORDER ),6,0),NIL), if(lImgAdjust,oDlg:nHeight()-if(lAnd( oDlg:nStyle, WS_CAPTION ),28,0),NIL) ) ;
        VALID (oImage:End(),.T.) ;
        NOWAIT
     endif

         if nTime <> NIL
            oTmr:=TTimer():New( nTime, {|| oDlg:End(), oTmr:End() }, oDlg )
            oTmr:Activate()
         endif

      endif

   endif

return oDlg


Algo similar a MsgLogo y MsgSplash().

Atentamente,

Rolando
Cochabamba, Bolivia
RSalazarU
 
Posts: 211
Joined: Wed Jul 16, 2008 12:59 pm
Location: Cochabamba-Bolivia

Re: Nueva funcion MsgImage()

Postby Antonio Linares » Mon Mar 30, 2015 12:41 pm

Rolando,

Gracias por compartirla :-)

A ver si algunos usuarios se animan a usarla y asi te comentan acerca de su funcionamiento
regards, saludos

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

Re: Nueva funcion MsgImage()

Postby nageswaragunupudi » Tue Mar 31, 2015 11:41 am

FWH already have good capabilities to handle images with very simple functions. Better you build on the existing capabilities than writing image-loading from scratch.

viewtopic.php?f=3&t=13602&p=174716#p174716
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10253
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Nueva funcion MsgImage()

Postby AIDA » Wed Apr 08, 2015 10:31 pm

Muy interesante :)


Saluditos :wink:
Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
User avatar
AIDA
 
Posts: 877
Joined: Fri Jan 12, 2007 8:35 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: gmart1, Google [Bot] and 10 guests