Antonio, Daniel, y demás integrantes del foro:
Necesito presentar una imagen escogida aleatoriamente, alguien me puede explicar un arreglo de cómo podría hacerlo?
De antemano agradecido por la enseñanza
Jairo Barbosa
#Include "FIVEWIN.CH"
STATIC oWnd,nBrush
//-----------------------------------------------------------------------------------------------------------------//
FUNCTION Main()
LOCAL oIco,oBru
nBrush:= Random(5) // 5 Imagenes para este ejemplo
DEFINE Icon oIco RESOURCE "01"
DEFINE Brush oBru FILE ".\FONDOS\FONDO"+ALLTRIM(STRZERO(nBrush,2))+ ".JPG"
DEFINE Window oWnd TITLE "La Cultura Maya de Chiapas México." ICON oIco BRUSH oBru
ACTIVATE Window oWnd MAXIMIZED ON RIGHT CLICK ShowPopup(nRow, nCol)
RETURN nil
//-----------------------------------------------------------------------------------------------------------------//
STATIC FUNCTION ShowPopup( nRow, nCol )
LOCAL oPop
MENU oPop POPUP
MENUITEM "Avanzar Imágen del Escritorio" RESOURCE "BMP1" ACTION CambiaFondo(">")
SEPARATOR
MENUITEM "Regresar Imágen del Escritorio" RESOURCE "BMP2" ACTION CambiaFondo("<")
SEPARATOR
MENUITEM "Imágen Aleatoria del Escritorio" RESOURCE "BMP3" ACTION CambiaFondo("*")
SEPARATOR
MENUITEM "Terminar Paseo por la Cultura Maya" RESOURCE "BMP4" ACTION oWnd:END()
ENDMENU
ACTIVATE POPUP oPop AT nRow, nCol OF oWnd
RETURN nil
//-----------------------------------------------------------------------------------------------------------------//
STATIC FUNCTION CambiaFondo(cTipo)
LOCAL oBru
IF cTipo == ">"
nBrush:= IF( nBrush > 04, 01, ++nBrush )
oWnd:oBrush:RELEASE()
oWnd:REFRESH()
ELSEIF cTipo == "<"
nBrush:= IF( nBrush < 02, 05, --nBrush )
oWnd:oBrush:RELEASE()
oWnd:REFRESH()
ELSEIF cTipo == "*"
nBrush:= Random(5)
oWnd:oBrush:RELEASE()
oWnd:REFRESH()
ENDIF
MSGInfo("Cambiando Imagen de Fondo por:"+CRLF+;
".\FONDOS\FONDO"+ALLTRIM(STRZERO(nBrush,2))+ ".JPG","Imagen de Escritorio")
DEFINE BRUSH oBrush FILE ".\FONDOS\FONDO"+ALLTRIM(STRZERO(nBrush,2))+ ".JPG"
SET BRUSH OF oWnd TO oBrush
SysRefresh()
oWnd:REFRESH()
SysRefresh()
RETURN nil
//-----------------------------------------------------------------------------------------------------------------//
STATIC FUNCTION Random(nLimite)
STATIC nGuarda:= 1
LOCAL I
LOCAL nResult
IF VALTYPE( nLimite ) # [N]
nLimite:= 100
ENDIF
I:= SECONDS()
WHILE nLimite > I
I:= I * 100 +SECONDS()
ENDDO
nGuarda:= (nGuarda +I) / (nResult:= nGuarda * I % nLimite +1)
nResult:= INT( nResult )
RETURN nResult
// FWH Class TOutLook2003
// Ejemplo elaborado y modificado por Jairo Barbosa
// Con las asesoráis de Carlos Gallego
// Carlitos gracias por tus consejos
#include "FiveWin.ch"
#include "Splitter.ch"
#include "Outlook.ch"
#include "image.ch"
STATIC lExit := .F.
//----------------------------------------------------------------------------//
FUNCTION Main()
LOCAL oWnd, oStatusBar, oSplit
LOCAL oFont, oExBar, oPanel1, oPanel2
LOCAL bClick := {|o| MSGInfo("En construccion")}
*------------------------------------------------------------------------------*
nResoAncho := GetSysMetrics(0)//800
nResoAlto := GetSysMetrics(1)//600
*------------------------------------------------------------------------------*
cRandom:= Random()
DEFINE WINDOW oWnd TITLE "FWH new Class TOutLook2003" PIXEL MDI ;
MENU BuildMenu() COLORS RGB(0,0,0),RGB(255,255,255)
@ 1,1 SAY oSay VAR cRandom OF oWnd:oWndClient SIZE 100,15;
PIXEL UPDATE TRANSPARENT
@ 1,1 image oBmp OF oWnd:oWndClient size nResoAncho, nResoAlto ;
FILE ".\" + ALLTRIM(STRZERO(cRandom,2))+".JPG" PIXEL NOBORDER adjust
DEFINE OUTLOOK2003 oOutLook2003 OF oWnd ;
PROMPTS "Kardex" BITMAPS "C:\FWH\bitmaps\mail.bmp"
oWnd:oLeft = nil // Because the splitter is going to control the resize
@ 5, 5 EXPLORERBAR oExBar OF oOutLook2003:aDialogs[ 1 ] ;
SIZE oOutLook2003:aDialogs[1]:nWidth, oOutLook2003:aDialogs[1]:nHeight
oPanel1 = oExBar:AddPanel( "One", "C:\FWH\bitmaps\32x32\people.bmp" )
oPanel1:lSpecial = .T.
oPanel1:AddLink( "Entradas", bClick,;
"C:\FWH\bitmaps\16x16\additem.bmp" );
oPanel1:AddLink( "Consulta de Saldos", bClick,;
"C:\FWH\bitmaps\16x16\copy.bmp" )
oPanel1:AddLink( "Tercer item", bClick, "C:\FWH\bitmaps\16x16\copy.bmp" )
oPanel2 = oExBar:AddPanel( "Dos", "C:\FWH\bitmaps\32x32\people.bmp" )
oPanel2:lSpecial = .T.
oPanel2:AddLink( "Hacer copia de seguridad", bClick,;
"C:\FWH\bitmaps\16x16\additem.bmp" )
oPanel2:AddLink( "Recuperar copia", bClick,"C:\FWH\bitmaps\16x16\copy.bmp")
oPanel2:AddLink( "Idexar Bases", bClick, "C:\FWH\bitmaps\16x16\copy.bmp" )
oPanel3 = oExBar:AddPanel( "Tres", "C:\FWH\bitmaps\32x32\people.bmp" )
oPanel3:lSpecial = .T.
oPanel3:AddLink( "Cambiar fondo", {||CambioFondo()},;
"C:\FWH\bitmaps\16x16\copy.bmp" )
DEFINE STATUSBAR oStatusBar PROMPT " FWH Class TOutLook2003" OF oWnd
SetParent( oOutLook2003:hWnd, oWnd:hWnd )
oWnd:oClient = nil
@ 1, 192 SPLITTER oSplit ;
VERTICAL _3DLOOK ;
PREVIOUS CONTROLS oOutLook2003 ;
HINDS CONTROLS oWnd:oWndClient ;
SIZE 4, oWnd:nHeight - 170 PIXEL ;
OF oWnd
SetParent( oSplit:hWnd, oWnd:hWnd )
ACTIVATE WINDOW oWnd maximized;
ON INIT ( cRandom := STRZERO(hb_RandomInt(1,14),4),;
oBmp:ReLoad( , "JPG"+cRandom+".JPG" ) , oBmp:Refresh(),;
oSay:VarPut( "JPG: JPG"+cRandom+".JPG" ) , oSay:Refresh() );
ON RESIZE ( oSplit:Adjust(),;
WndLeft( oWnd:oWndClient:hWnd, oSplit:nRight + 1 ),;
WndWidth( oWnd:oWndClient:hWnd,;
oWnd:nWidth - oOutLook2003:nWidth - 23)) VALID lExit := .T.
RETURN nil
*----------------------------------------------------------------------------//
STATIC FUNCTION CambioFondo()
(cRandom := STRZERO(hb_RandomInt(1,14),4) ,;
oBmp:ReLoad( , "JPG"+cRandom+".JPG" ) , oBmp:Refresh(), ;
oSay:VarPut( "JPG: JPG"+cRandom+".JPG" ) , oSay:Refresh())
RETURN nil
//--------------------------------------------------------------------------
FUNCTION BuildMenu()
LOCAL oMenu
MENU oMenu
MENUITEM "&One"
MENUITEM "&Two"
MENUITEM "&Three"
ENDMENU
RETURN oMenu
*-----------------------------------------------------------------------------*
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
BOOL SysRefresh( VOID );
HB_FUNC( NOGPF )
{
__try
{
hb_retl( SysRefresh() );
}
__except ( ( hb_retl( TRUE ), TRUE ) )
{}
}
#pragma ENDDUMP
*----------------------------Fin del codigo-----------------------------------*
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 58 guests