FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Nueva funcion MsgImage()
Posts: 211
Joined: Wed Jul 16, 2008 12:59 PM
Nueva funcion MsgImage()
Posted: Mon Mar 30, 2015 01: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.


Code (fw): Select all Collapse
//---------------------------------//
//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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Nueva funcion MsgImage()
Posted: 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Nueva funcion MsgImage()
Posted: 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=3t=13602p=174716#p174716

&&

Regards



G. N. Rao.

Hyderabad, India
Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: Nueva funcion MsgImage()
Posted: 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ǝ

Continue the discussion