Mira Leandro que no funciona y ni siquiera tiene sentido. Es solo un truco de magia de Mestre Antônio Liñares. No me hace ningún bien, ya que uso todo el poder de FiveWin de la mejor manera. Aun así, muchas gracias.
// => \samples\GRABARIMG.PRG - 15/11/2021
#Include "FiveWin.ch"
#define CLR_MSPURPLE RGB( 0, 120, 215 )
#define CLR_MSRED RGB( 232, 17, 35 )
#define CLR_MSGRAY RGB( 229, 229, 229 )
#define TME_LEAVE 2
STATIC oWnd, hLib
FUNCTION Main()
LOCAL oBar, cTitle, cUrl, cSaveAs
LOCAL oWnd, nRowPos, nColPos, oBtnClose, oBtnMax, oBtnMin, lDrag := .F., ;
lRResize := .F., lBResize := .F.
SetBalloon( .T. )
SkinButtons()
// <!-- m --><a class="postlink" href="https://imgur.com/">https://imgur.com/</a><!-- m -->
cUrl := "https://i.imgur.com/UQxRdAp.png"
cSaveAs := "GrabaImg.png"
cTitle := "FiveWin Brasil: Grabar Imagen Desde URL"
DEFINE WINDOW oWnd TITLE cTitle
//DEFINE WINDOW oWnd STYLE WS_POPUP COLOR CLR_BLACK, CLR_MSPURPLE // MDI
//oWnd:SetSize( 500, 300 )
//oWnd:Center()
oWnd:Shadow()
oWnd:bPainted = { || oWnd:Say( 8, 30, "Caption Color", CLR_RED, CLR_MSPURPLE, oWnd:oFont, .T., .T. ) }
oWnd:bLClicked = { | nRow, nCol | If( nRow < 25, ( oWnd:Capture(), nRowPos := nRow, nColPos := nCol, lDrag := .T. ),),;
If( nRow > 25 .and. nCol > oWnd:nWidth - 25, ( oWnd:Capture(), nRowPos := nRow, nColPos := nCol, lRResize := .T. ),),;
If( nRow > 25 .and. nRow > oWnd:nHeight - 25, ( oWnd:Capture(), nRowPos := nRow, nColPos := nCol, lBResize := .T. ),) }
oWnd:bMMoved = { | nRow, nCol | TrackMouseEvent( oWnd:hWnd, TME_LEAVE ),;
If( lDrag .and. ! IsZoomed( oWnd:hWnd ) .and. IsOverWnd( oWnd:hWnd, nRow, nCol ),;
oWnd:Move( oWnd:nTop + nRow - nRowPos, oWnd:nLeft + nCol - nColPos,,, .T. ),),;
If( lRResize .and. ! IsZoomed( oWnd:hWnd ) .and. IsOverWnd( oWnd:hWnd, nRow, nCol ),;
( oWnd:SetSize( oWnd:nWidth + nCol - nColPos, oWnd:nHeight, .T. ), nColPos := nCol ),),;
If( lBResize .and. ! IsZoomed( oWnd:hWnd ) .and. IsOverWnd( oWnd:hWnd, nRow, nCol ),;
( oWnd:SetSize( oWnd:nWidth, oWnd:nHeight + nRow - nRowPos, .T. ), nRowPos := nRow ),) }
oWnd:bLButtonUp = { || ReleaseCapture(), lDrag := .F., lRResize := .F., lBResize := .F. }
oWnd:bMLeave = { || lDrag := .F. }
@ 1, oWnd:nWidth - 46 BTNBMP oBtnClose BITMAP "../bitmaps/16x16/closew.bmp" ;
FLAT NOBORDER NOROUND ACTION oWnd:End() SIZE 45, 29 ;
COLOR CLR_BLACK, CLR_MSPURPLE
@ 1, oWnd:nWidth - 92 BTNBMP oBtnMax BITMAP "../bitmaps/16x16/max.bmp" ;
FLAT NOBORDER NOROUND ACTION If( ! IsZoomed( oWnd:hWnd ), oWnd:Maximize(), oWnd:Restore() ) SIZE 45, 29 ;
COLOR CLR_BLACK, CLR_MSPURPLE
@ 1, oWnd:nWidth - 138 BTNBMP oBtnMin BITMAP "../bitmaps/16x16/min.bmp" ;
FLAT NOBORDER NOROUND ACTION If( ! IsIconic( oWnd:hWnd ), oWnd:Iconize(), oWnd:Restore() ) SIZE 45, 29 ;
COLOR CLR_BLACK, CLR_MSPURPLE
oBtnClose:bMMoved = { || oBtnClose:SetColor( CLR_BLACK, If( oBtnClose:lMOver, CLR_MSRED, oWnd:nClrPane ) ) }
oBtnMax:bMMoved = { || oBtnMax:SetColor( CLR_BLACK, If( oBtnMax:lMOver, CLR_MSGRAY, oWnd:nClrPane ) ) }
oBtnMin:bMMoved = { || oBtnMin:SetColor( CLR_BLACK, If( oBtnMin:lMOver, CLR_MSGRAY, oWnd:nClrPane ) ) }
oWnd:bResized = { || oBtnClose:Move( 1, oWnd:nWidth - 46 ), oBtnMax:Move( 1, oWnd:nWidth - 92 ),;
oBtnMin:Move( 1, oWnd:nWidth - 138 ) }
DEFINE BUTTONBAR oBar BUTTONSIZE 60, 50 _3DLOOK TOP OF oWnd 2007
DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\floppy.bmp" FLAT ;
ACTION( URLDownLoad( cUrl, cSaveAs ) ) TOOLTIP "Saves this Image"
DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT ;
ACTION oWnd:End() TOOLTIP "Exit this app" GROUP
SET MESSAGE OF oWnd TO cTitle NOINSET CLOCK DATE KEYBOARD 2007
// ON INIT( CLRTEST( CLR_WHITE, CLR_HRED ) ) ;
ACTIVATE WINDOW oWnd MAXIMIZED /* ;
ON PAINT( DiagonalGradientFill( hDC, ;
0, 0, oWnd:nHeight, oWnd:nWidth, ;
{ { 0.16, CLR_WHITE, CLR_CYAN }, ;
{ 0.16, CLR_CYAN, nRGB( 181, 61, 29 ) }, ;
{ 0.16, nRGB( 181, 61, 29 ), nRGB( 250,157,52 ) }, ;
{ 0.16, nRGB( 250,157,52 ), nRGB( 181, 61, 29 ) }, ;
{ 0.16, nRGB( 181, 61, 29 ), CLR_CYAN }, ;
{ 0.20, CLR_CYAN, CLR_WHITE } },.T. ), PINTA( hDC ) )
*/
RETURN NIL
FUNCTION URLDownLoad( cUrl, cSaveAs )
hLib := LOADLIBRARY( "urlmon.dll" )
CURSORWAIT()
IF FILE( cSaveAs )
ERASE cSaveAs
ENDIF
IF .NOT. URLDownloadToFile( 0, cUrl, cSaveAs, 0, 0 ) == 0
MsgInfo( "Image Not Found in: <!-- m --><a class="postlink" href="https://imgur.com/">https://imgur.com/</a><!-- m -->", "Attention!" )
RETURN( .F. )
ENDIF
FreeLibrary( hLib )
CURSORARROW()
ShellExecute(GetActiveWindow(),"open",'"'+cSaveAs+'"')
RETURN( .T. )
FUNCTION DiagonalGradientFill( hDC, nTop, nLeft, nBottom, nRight, aGradInfo, ;
lDirection )
LOCAL nClr := 1, nClrs := Len( aGradInfo )
LOCAL nSize, nStart, nEnd
DEFAULT lDirection := .T.
IF Empty( aGradInfo )
RETURN NIL
ENDIF
nSize = ( nBottom - nTop ) + ( nRight - nLeft )
nStart = 0
nEnd = 0
FOR nClr := 1 to nClrs
nStart = nEnd
nEnd += ( nSize * ( aGradInfo[ nClr ][ 1 ] ) )
DiagonalGradient( hDC, ;
{ nTop, nLeft, nBottom, nRight },;
aGradInfo[ nClr ][ 2 ], ;
aGradInfo[ nClr ][ 3 ], ;
lDirection, ;
nStart, ;
nEnd )
NEXT
RETURN NIL
FUNCTION Pinta( hDC )
LOCAL nColor
LOCAL nLeft := 80
LOCAL nRight := 220
LOCAL cTexto := "FIVEWIN BRASIL THE BEST"
LOCAL cTexto2 := "No funciona... "
LOCAL oFont
LOCAL hFont
LOCAL nLen := LEN( cTexto )
LOCAL cLetra, n
LOCAL nResHoriz, nResVert
nResHoriz := oWnd:nHorzRes() // retorna a resolucao horizontal
nResVert := oWnd:nVertRes() // retorna a resolucao vertical
// atencao: nResolution identifica em que resolucao foram inicialmente
// desenhadas as telas, e DEVE ter um dos seguintes valores:
//
// 1 = 640 X 480
// 2 = 800 X 600
// 3 = 1024 X 768
// 4 = 1152 X 864
// 5 = 1280 X 800
// 6 = 1280 X 1024
// 7 = 1600 X 1200
// 8 = 768 X 1024
// 9 = 1440 X 900
// 10 = 1280 X 768
// 11 = 1280 X 720
IF nResHoriz = 1366 .AND. nResVert = 768
nLeft := 260
nRight := 230
ELSEIF nResHoriz = 1360 .AND. nResVert = 768
nLeft := 210
nRight := 250
ELSEIF nResHoriz = 1280 .AND. nResVert = 1024
nLeft := 210
nRight := 350
ELSEIF nResHoriz = 1280 .AND. nResVert = 768
nLeft := 170 // 210 // my computer.
nRight := 280
ELSEIF nResHoriz = 1280 .AND. nResVert = 720
nLeft := 200
nRight := 200
ELSEIF nResHoriz = 1024 .AND. nResVert = 768
nLeft := 80
nRight := 220
ELSE
nLeft := 80
nRight := 220
ENDIF
DEFINE FONT oFont NAME "Segoe UI Symbol" SIZE 0, -80 BOLD
hFont := SelectObject( hDC, oFont:hFont )
FOR n := 1 TO nLen
cLetra := substr( cTexto, n, 1 )
nColor := SetTextColor( hDC, CLR_GREEN )
// TextOut( hDC, 10, nLeft, cLetra )
TextOut( hDC, nRight, nLeft, cLetra )
SetTextColor( hDC, nColor )
nLeft += GetTextWidth( hDC, cLetra, oFont )
NEXT
SelectObject( hDC, hFont )
RETURN NIL
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( CLRTEST )
{
int aElements[2] = { COLOR_CAPTIONTEXT, COLOR_ACTIVECAPTION };
DWORD aColors[2];
aColors[ 0 ] = hb_parnl( 1 );
aColors[ 1 ] = hb_parnl( 2 );
SetSysColors( 2, aElements, aColors );
}
#pragma ENDDUMP
DLL32 FUNCTION URLDownloadToFile( pCaller AS LONG, szURL AS STRING, szFileName ;
AS STRING, dwReserved AS LONG, lpfnCB AS LONG ) AS LONG PASCAL ;
FROM "URLDownloadToFileA" LIB hlib
// fin /end
Regards, saludos.