#include "fivewin.ch"
STATIC oDlg, oWnd
FUNCTION MAIN
LOCAL oMenu
LOCAL x := 1024
LOCAL y := 780
LOCAL xi := INT( x * 0.10 / 2 )
LOCAL yi := INT( y * 0.10 / 2 )
x := INT( x * 0.90 ) + xi
y := INT( y * 0.90 ) + yi
MENU oMenu
MenuItem "Show" ACTION (Resize(), oDlg:Show() )
MenuItem "Hide" ACTION odlg:hide()
ENDMENU
DEFINE WINDOW oWnd MDI FROM yi, xi TO y, x PIXEL Title "Testing Dlg On Wnd" MENU oMenu
ACTIVATE WINDOW oWnd ON INIT BuildDlg( "Sample Text", oWnd )
RETURN NIL
//-------------------------------------------------------
FUNCTION BuildDlg( cText, oOwner )
DEFINE DIALOG oDlg ;
RESOURCE "SampleDlg" ;
TRANSPARENT ;
COLOR CLR_WHITE , RGB(240,240,240)
REDEFINE SAY PROMPT cText ID 1 OF oDlg TRANSPARENT COLOR RGB(240,240,255),RGB(240,240,255)
REDEFINE BUTTONBMP ID 2 OF oDlg BITMAP "exit16" PROMPT "Ok" TEXTRIGHT ACTION oDlg:END()
oDlg:bPainted := { || GradBrush( oDlg, ;
{ { 1.0, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) } }, .T. ) }/**/
/*oDlg:bPainted := { || DlgGradient( oDlg, ;
{ { 1.0, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) } } ) } /**/
oDlg:bResized := Eval( oDlg:bPainted )
oDlg:lHelpIcon := .F.
ACTIVATE DIALOG oDlg NOWAIT VALID ( oDlg:hide(), .F. ) ;
ON INIT ( oDlg:Center( oWnd ), oDlg:Hide(), oDlg:Paint() );
ON MOVE ( oDlg:Paint() )
oDlg:hide()
oWnd:bResized := {|| Resize() }
oWnd:bMoved := { || Resize() }
RETURN NIL
//-------------------------------------------------------
STATIC FUNCTION GradBrush( oDlg, aColors, lPos )
local hDC, hBmp, hBmpOld, oBrush
if Empty( oDlg:oBrush:hBitmap )
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aColors, lPos )
DeleteObject( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlg:ReleaseDC()
endif
RETURN NIL
//-------------------------------------------------------
STATIC FUNCTION Resize()
LOCAL aClient := GetClientRect ( oWnd:hWnd )
oDlg:SetSize( aClient[4] - 1, aClient[3]- 2, .T. )
oDlg:Center( oWnd )
Eval( oDlg:bPainted )
RETURN NIL
//-------------------------------------------------------