Um janela Dialog com uma chamada para Youtube

Moderador: Moderadores
Na prática é um recurso do Windows.
Ao criar uma janela e atribuir a classe atlaxwin, ela permite activex.
E ao colocar o nome de um arquivo, o Windows abre o que estiver associado à extensão do arquivo.
nOpcao := ::MsgOptions( "Selecione um botão para impressão", "Atenção", oIcon, "P:\GERAL\HARBOUR\PRINTER.bmp", {"&Tela", "&Impressora", "&Abandonar"}, 3, 60)
METHOD MsgOptions( cText, cTitle, oIcon, cImage, aOptions, nDefaultOption, nSeconds ) CLASS ClPrincipal
LOCAL nItem, nBtnWidth:=0, aBtn:=Array( Len( aOptions ) ), aImgInfo
LOCAL nBtnPosX:=10, nBtnPosY:=85
LOCAL oSay1, nWidth, nHeight, nStyle
MEMVAR cOption
cOption:="_"
DEFAULT cText TO "Selecione uma opção"
DEFAULT cTitle TO "Opções DisponÃveis"
DEFAULT oIcon TO "Opcao.ico"
DEFAULT cImage TO ""
DEFAULT nDefaultOption TO 1
DEFAULT nSeconds TO 0
WITH Object oBmp1 := HBitmap():AddFile( cImage,,, nWidth, nHeight )
nWidth := :nWidth
nHeigth := :nHeight
END
_Font_Options := HFont():Add( "Tahoma", 0, -13, 550 ) //HFont():Add( "Tahoma", 9 )
FOR EACH nItem IN aOptions
aOptions[nItem:__EnumIndex] := AllTrim( aOptions[nItem:__EnumIndex] )
nBtnWidth := Max( GetTextWidth(, aOptions[nItem:__EnumIndex], _Font_Options:handle), nBtnWidth )
NEXT
nBtnWidth += 5
nStyle := WS_POPUP + WS_VISIBLE + WS_CAPTION + DS_CENTER + WS_SYSMENU
oObjeto := ClPrincipal():New()
INIT DIALOG _Options ;
TITLE cTitle ;
AT 0, 0 ;
SIZE ( Len( aOptions ) * ( 10 + nBtnWidth ) ) + 10, 155 ;
ICON oIcon ;
FONT _Font_Options ;
CLIPPER ;
STYLE nStyle
IF hb_FileExists( cImage )
@ 10, 20 BITMAP Bitmap SHOW cImage STRETCH 0 SIZE nWidth, nHeight
@ 50, 30 SAY oLabel ;
CAPTION cText ;
FONT _Font_Options ;
SIZE _Options:nWidth - 55, 80 ;
COLOR hwg_RGB( 0, 0, 255 ) ;
STYLE ES_LEFT
ELSE
@ 10, 30 SAY oLabel ;
CAPTION cText ;
FONT _Font_Options ;
SIZE _Options:nWidth - 55, 30 ;
STYLE SS_LEFT
ENDIF
FOR EACH nItem IN aOptions
aBtn[nItem:__EnumIndex]:="_Btn_" + hb_NtoS( nItem:__EnumIndex )
cOption_ := aBtn[nItem:__EnumIndex]
@ nBtnPosX, _Options:nHeight - 35 BUTTONEX &cOption_. ;
CAPTION aOptions[nItem:__EnumIndex] ;
FONT _Font_Options ;
ON CLICK { || cOption := oObjeto:PegaOpcao( &cOption_.:Name, @cOption ), ;
hwg_EndDialog(_Options:handle) } ;
SIZE nBtnWidth, 25
nBtnPosX += nBtnWidth + 10
NEXT
_Options:nInitFocus := &( aBtn[nDefaultOption] )
IF nSeconds > 0
::Liga_Timer( _Options , .T., nSeconds * 1000, { || cOption := aOptions[nDefaultOption], hwg_EndDialog(_Options:handle) }, "oTimerOptions" )
ENDIF
ACTIVATE DIALOG _Options
RETURN aScan( aOptions, AllTrim( cOption ) )
METHOD PegaOpcao( cCaption, cOpcao ) CLASS ClPrincipal
cVar := cCaption + ":Caption"
cOpcao := &cVar.
RETURN cOpcao
METHOD Liga_Timer( oJanela, lLiga, nTime, bBlock, oTimer ) CLASS ClPrincipal
IF lLiga
SET TIMER &oTimer. of oJanela VALUE nTime ACTION bBlock
ELSE
oJanela:&oTimer.:End()
ENDIF
RETURN Nil
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
#include <olectl.h>
#include <time.h>
HB_FUNC( GETTEXTWIDTH ) // returns the width of a string in pixels
{
HDC hDC = ( HDC ) hb_parnl( 1 );
HWND hWnd = ( HWND ) NULL;
BOOL bDestroyDC = FALSE;
HFONT hFont = ( HFONT ) hb_parnl( 3 );
HFONT hOldFont = ( HFONT ) NULL;
SIZE sz;
if( ! hDC )
{
bDestroyDC = TRUE;
hWnd = GetActiveWindow();
hDC = GetDC( hWnd );
}
if( hFont )
hOldFont = ( HFONT ) SelectObject( hDC, hFont );
GetTextExtentPoint32( hDC, hb_parc( 2 ), hb_parclen( 2 ), &sz );
if( hFont )
SelectObject( hDC, hOldFont );
if( bDestroyDC )
ReleaseDC( hWnd, hDC );
hb_retnl( sz.cx );
}
#pragma ENDDUMP
Usuários vendo este fórum: Nenhum usuário registrado online e 7 visitantes