Error in painting a Transparent say

Error in painting a Transparent say

Postby Rick Lipkin » Tue May 26, 2009 8:19 pm

To All

Trying to paint a transparent say on a MdiChild\dialog with the following code and error .. any ideas ?

Rick Lipkin

Code: Select all  Expand view

#include "FiveWin.ch"

STATIC lOK

//----------------------------------
FUNC _Rptmenu( oWnd, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog )

LOCAL oWndChild, oDlg, oBtn1, oBTN2, oBTN3
LOCAL oIco

lOK := .F.

oBtnRpt:Hide()
oBtnPcas:Hide()
oBtnUtil:Hide()
oBtnCoor:Hide()
oBtnLog:Hide()

DEFINE ICON oICO RESOURCE "WALKING"

DEFINE WINDOW oWndChild MDICHILD         ;
       FROM 1,1 to 15, 46.8              ;
       MENU BuildMenu()                  ;
       NOMINIMIZE                        ;
       NOZOOM                            ;
       ICON oICO                         ;
       OF oWnd                           ;
       TITLE "Report Menu"

   oWndChild:bGotFocus  := { || oDlg:SetFocus() }

   DEFINE DIALOG oDlg RESOURCE "RPTMENU" OF oWndChild

   REDEFINE BUTTON oBtn1 ID 101 OF oDlg   ;
      ACTION ( _progrpt() )

     @ 0, 0 SAY "Test" OF oDlg COLOR "N/N"  // errors here
      oDlg:aControls[ 1 ]:lTransparent = .t.

   REDEFINE BUTTON oBtn2 ID 102 OF oDlg   ;
      ACTION ( _grpsumm() )

   REDEFINE BUTTON oBtn3 ID 105 OF oDlg  ;
      ACTION( dbCloseAll(), oWndChild:End(), oBtnRpt:Show(), ;
             oBtnPcas:Show(), oBtnUtil:Show(), oBtnCoor:Show(),;
             oBtnLog:Show() )

ACTIVATE DIALOG oDlg NOWAIT ;  // It has to be NonModal --> NOWAIT clause
   ON INIT ( oDlg:Move( 0, 0 ) ) ;
   ON PAINT (GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, xGrad1, .T. ))

ACTIVATE WINDOW oWndChild ;
   ON INIT oWndChild:SetSize( oDlg:nWidth, oDlg:nHeight, .T. ) ;
   VALID ( IF( !lOK, RptCLose( .T., oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog ), .T. ))

RETURN(NIL)

//-----------------------
static FUNC BuildMenu()

LOCAL oMENU

MENU oMENU

   MENUITEM "                "

ENDMENU

RETURN( oMENU )


//------------------------
Static FUNCTION RptClose(lCLEAN, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog )

IF lCLEAN = .T.
   lOK := .T.
   oBtnRpt:Show()
   oBtnPcas:Show()
   oBtnUtil:Show()
   oBtnCoor:Show()
   oBtnLog:Show()
   SysReFresh()
ENDIF

RETURN(lOK)

// END
 


Code: Select all  Expand view

pplication
===========
   Path and name: C:\FOX\PCASTEST\PCASW32.Exe (32 bits)
   Size: 2,415,616 bytes
   Time from start: 0 hours 0 mins 4 secs
   Error occurred at: 05/26/2009, 16:12:11
   Error description: Error FiveWin/1  Non defined Id: No:    112
   Args:

Stack Calls
===========
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:INITIATE(386)
   Called from: .\source\classes\SAY.PRG => TSAY:INITIATE(195)
   Called from:  => __OBJSENDMSG(0)
   Called from: .\source\function\HARBOUR.PRG => OSEND(235)
   Called from: .\source\function\HARBOUR.PRG => ASEND(186)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE(654)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT(912)
   Called from:  => CREATEDLG(0)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(302)
   Called from: RPTMENU.PRG => _RPTMENU(53)
   Called from: MAIN.PRG => (b)_BAR(437)
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(443)
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(629)
   Called from:  => TWINDOW:HANDLEEVENT(0)
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1453)
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1283)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
   Called from:  => WINRUN(0)
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(952)
   Called from: MAIN.PRG => MAIN(369)

 
User avatar
Rick Lipkin
 
Posts: 2615
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error in painting a Transparent say

Postby ukoenig » Tue May 26, 2009 8:32 pm

Hello Rick,

...
...
DEFINE DIALOG oDlg RESOURCE "RPTMENU" OF oWndChild

REDEFINE BUTTON oBtn1 ID 101 OF oDlg ;
ACTION ( _progrpt() )

// @ 0, 0 SAY "Test" OF oDlg COLOR "N/N" // errors here
// oDlg:aControls[ 1 ]:lTransparent = .t.

// define the say inside Your resource "RPTMENU" !!!
// -----------------------------------------------------------
REDEFINE SAY oSay1 VAR ??? ID ??? OF oDlg UPDATE
oSay1:lTransparent = .t.


REDEFINE BUTTON oBtn2 ID 102 OF oDlg ;
ACTION ( _grpsumm() )
....
....

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Error in painting a Transparent say

Postby Rick Lipkin » Tue May 26, 2009 9:26 pm

Uwe

If you have a gradientfill .. there is no way unless you use the PIXEL Transparent .. then your resource 'boilerplate' ( without id's ) is transparent .. however, I want the transparent .. but not the default black text .. it needs to stand out against the gradient.

Your suggestion worked fine without the gradientfill and just a ( plain ) w/r dialog... ( oSay1:LTransparent = .t.) for the Say with an ID in the resource .. however .. adding the gradientfill .. blocks out the boilerplate regardless.

Thanks
Rick
User avatar
Rick Lipkin
 
Posts: 2615
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error in painting a Transparent say

Postby ukoenig » Tue May 26, 2009 10:16 pm

Hello Rick,

because Your background is transparent, You need only the Text-color to change :

REDEFINE SAY oSay1 VAR cSAY1 ID 520 OF oFld:aDialogs[1] UPDATE
oSAY1:lTransparent := .T.
oSAY1:nClrText := 128 // ( red ) or any color-value You need
// You can use also :
oSAY1:SetColor( 128, 16777215 ) // Background is ignored, if lTransparent = .T.

// set Background-color of SAY if needed ( works only with no transparent )
// ----------------------------------------------------------------------------------------------
oSAY1:nClrBack := 16777215 // White
// Error-message, if lTransparent = .T.

Error description: Warning BASE/1005 Message not found: TSAY:_NCLRBACK
Args:
Stack Calls
===========
Called from: source\rtl\tobject.prg => TSAY:ERROR(172)
Called from: source\rtl\tobject.prg => TSAY:MSGNOTFOUND(205)
Called from: source\rtl\tobject.prg => TSAY:_NCLRBACK(0)

Class TSay :

METHOD ReDefine( nId, bText, oWnd, cPicture,;
nClrText, nClrBack, lUpdate, oFont, lTransparent, lAdjust ) CLASS TSay

DEFAULT oWnd := GetWndDefault(),;
nClrText := oWnd:nClrText,;
nClrBack := GetSysColor( COLOR_BTNFACE ),;

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Error in painting a Transparent say

Postby Rick Lipkin » Tue May 26, 2009 11:12 pm

Uwe

I will test your suggestions in the morning .. thank you !!

Rick
User avatar
Rick Lipkin
 
Posts: 2615
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error in painting a Transparent say

Postby Rick Lipkin » Wed May 27, 2009 2:58 pm

Uwe

No Luck on your suggestions .. I have tried to reduce this sample as much as I can .. cut and paste the two programs and Rptmenu.rc and compile .. open the reports and you will see the results .. I like the second line since it is transparent due to the PIXEL Transparent clause .. however, I just want to paint the text white and leave the background transparent.

It definitly has something to do with the gradient painting ??

Rick

Code: Select all  Expand view

// main.prg

#INCLUDE "FIVEWIN.CH"

STATIC  oWInd                 // main mdi window
STATIC  oBmap                 // mdi window .bmp
STATIC  lExitPgm := .F.
STATIC xMESSAGE

//----------------------------------

FUNC MAIN()

LOCAL cDEFA,nLEN,cFILE,cRIGHTS,SAYING,mSTART,aDIR,cRDD
LOCAL cREAD,cWRITE,cSUPER,cOLDDEFA,cADMIN
LOCAL nPOS,cLOGIN,dEXE
LOCAL nYEAR,nSCR1,nSCR2,aVER
LOCAL oICO, oRs, cSQL, oErr, cPROG
LOCAL lOK, oDLG, cINIFILE, cERR
LOCAL TEXT_EOF, BYTES_READ,cTEXT,nHANDLE
LOCAL oSAY, cSAY, cSAY1

PUBLIC xVOL := "C:", xREAD,xWRITE,xLOGIN,xSUPER,xADMIN
PUBLIC xPROVIDER, xSOURCE, xCATALOG, xUSERID, xPASSWORD, xPROGID
PUBLIC xTABLE, xHOLD_TABLE, xQUE_TABLE

PUBLIC xGRAD1, xGRAD2, xGRAD3, xGRAD4, xGRAD5, xGRAD6

//--------------

PARAMETERS xTEXT

REQUEST DBFCDX
rddsetdefault ( "DBFCDX" )

xREAD   := " "
xWRITE  := " "
xLOGIN  := " "
xSUPER  := " "
xPROGID := " "
xADMIN  := " "

xPROVIDER := "SQLOLEDB"
*xSOURCE   := "MSSQL01"
xSOURCE   := "LWMWEBDB01"
xCATALOG  := "PCAS"
xUSERID   := "pcasuser"
xPASSWORD := "pcas"


// Main gradients here

xGrad1  := {{ 0.80, 14671839, 4144959  },{ 0.1, 4144959, 14671839  }}  // grey top down
xGrad2  := {{ 0.80, 4144959, 14671839  },{ 0.1, 14671839, 4144959  }}  // grey bottom up
xGrad3  := {{ 0.80, 16777215, 7518392  },{ 0.1, 7518392,  16777215 }}  // yellow top down
xGrad4  := {{ 0.80, 7518392,  16777215 },{ 0.1, 16777215, 7518392  }}  // yellow bottom up

xGRAD5  := {{ 0.80, 12615680,  8388608 },{ 0.80,8388608,  12615680 }}  // blue light top down
xGRAD6  := {{ 0.80, 8388608, 12615680  },{ 0.80,12615680, 12615680 }}  // blue  light bottom up

nSCR1 := GetSysMetrics(0)
nSCR2 := GetSysMetrics(1)

//-- get timestamp on .exe //

cFILE := GetModuleFileName( GetInstance() )
aDIR  := DIRECTORY( cFILE )
dEXE  := aDIR[1] [3]

// where .exe started from is default directory //

mSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,mSTART-1)

aDIR := NIL

SET DEFA to ( cDEFA )
cOLDDEFA := cDEFA

cRDD := xPROVIDER+"
on "+xSOURCE+" 32 bit -b x86"

SET DELETED on
SET CENTURY on
SET 3DLOOK on

nYEAR := ( year( DATE() )-5 )
SET EPOCH to ( nYEAR )

// test for TEXT mode /NL      for no logo

IF EMPTY( xTEXT )
   xTEXT := "
"
ENDIF

xTEXT := ALLTRIM( UPPER(xTEXT))


xLOGIN := WNetGetUser()      // FiveWin winapi wrapper
xLOGIN := UPPER( xLOGIN )

//-------------------------

cDEFA := SET(7)              // set the local default path


xLOGIN  := xLOGIN+SPACE(8)
xLOGIN  := SUBSTR(xLOGIN,1,8)

xWRITE := 'Y'
xSUPER := "
Y"
xADMIN := "
Y"

cRIGHTS := _Rights()

//----- main menu -------//

xMESSAGE :=  "
User  "+xLOGIN+"    Rights  "+cRIGHTS+        ;
      "
    Default= "+cDEFA+"      Rdd= "+cRDD+            ;
      "
    Revision  "+DTOC(dEXE)+;
      "
 -r"+str(nSCR1,4)+" x "+STR(nSCR2,4)

DEFINE ICON oICO RESOURCE "
COUPLE"

DEFINE WINDOW oWind                                          ;
   FROM 0,2 to 28,78                                         ;
   TITLE "
PCAS Time and Data entry Program"                  ;
   MENU BuildMenu()                                          ;
   ICON oICO                                                 ;
   MDI

  DEFINE BITMAP oBMAP FILENAME (cOLDDEFA+"
\PCAS.BMP") of oWind

SET MESSAGE OF oWind                                          ;
   to xMESSAGE CLOCK

   // key handler to trap key strokes  ESC to quit  //
   // oWind:bKeyDown := {|nKey| IF(nKEY = 27, oWIND:END(), ) }

ACTIVATE WINDOW oWind                                         ;
   MAXIMIZED ;
   ON PAINT ( _BackGround( hDC, oBmap, nSCR1, nSCR2, oWind, xTEXT ) );
   ON INIT ( _Bar( oWind,cOLDDEFA,dEXE,cRDD,nSCR1, nSCR2 ) ) ;
   VALID ( IF( !lExitPgm, ExitPgm( .T. ) , .F. ) )

RETURN( NIL )

//--------------------------
Static Func _BackGround( hDC, oBmap, nSCR1, nSCR2, oWind, xTEXT )

IF xTEXT = "
/NL"
ELSE
   PalBmpDraw( hDC, 0,0, oBMAP:hBitmap, oBMAP:hPalette, nSCR1, nSCR2 )
ENDIF

RETURN(NIL)

//--------------------------
Static Func _Bar( oWnd,cOLDDEFA,dEXE,cRDD,nSCR1, nSCR2 )

LOCAL  oDLG, oBtnPcas, oBtnRpt, oBtnUtil, oBtnCoor, oBtnLog, oBtnHlp, oBtnQuit
LOCAL  cSAY1, cSAY2, cSAY3, cSAY4, cSAY5, cSAY6, cSAY7
LOCAL nWIDTH, nHEIGHT, nTOP, cDEFA

cDEFA := SET(7)

nWidth  := GetSysMetrics(0)
nHeight := GetSysMetrics(1)
nTop    := GetSysMetrics(30)

cSAY1 := "
PCAS"+chr(10)
cSAY1 += "
Data Entry"+chr(10)

cSAY2 := "
REPORT"+chr(10)
cSAY2 += "
Menu"+chr(10)

cSAY3 := "
UTILITY"+chr(10)
cSAY3 += "
Menu"+chr(10)

cSAY4 := "
Co-"+CHR(10)
cSAY4 += "
Ordinator"+chr(10)

cSAY5 := "
Login"+CHR(10)
cSAY5 += "
Diff User"+chr(10)

cSAY6 := "
Intranet"+CHR(10)
cSAY6 += "
Help"+chr(10)

cSAY7 := "
QUIT"


DEFINE DIALOG oDLG ;
       FROM 0,0 to 100,100 of oWnd ;
       STYLE nOR( WS_OVERLAPPED | WS_VISIBLE ) PIXEL TRANSPARENT

@ 20, 0 BTNBMP oBtnPcas RESOURCE "
PCASADD" ;
  SIZE 32,32  ;
  PROMPT cSAY1 CENTER of oDLG // ;
 * ACTION ( _calendar( DATE(),oWND, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog  ))

  oBtnPcas:SetColor( "
W+/W" )
  oBtnPcas:ReFresh()
  SysReFresh()

  oBtnPcas:lTransparent = .T.
  oBtnPcas:cTooltip := "
PCAS Data Entry"


@ 60, 0 BTNBMP oBtnRpt RESOURCE "
REPORT" ;
  SIZE 32,32    ;
  PROMPT cSAY2 CENTER of oDLG ;
  ACTION ( _Rptmenu( oWND, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog ))

  oBtnRpt:SetColor( "
W+/W" )
  oBtnRpt:ReFresh()
  SysReFresh()

  oBtnRpt:lTransparent = .T.
  oBtnRpt:cTooltip := "
REPORT Menu"


@ 100, 0 BTNBMP oBtnUtil RESOURCE "
UTILITY" ;
  SIZE 32,32  ;
  PROMPT cSAY3 CENTER of oDLG // ;
*  ACTION ( _Utilmenu( oWND, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog ))

  oBtnUtil:SetColor( "
W+/W" )
  oBtnUtil:ReFresh()
  SysReFresh()

  oBtnUtil:lTransparent = .T.
  oBtnUtil:cTooltip := "
UTILITY Menu"

@ 140, 0 BTNBMP oBtnCoor ;
  SIZE 32,32 ;
  PROMPT cSAY4 CENTER of oDLG RESOURCE "
ORGANIZE" // ;
*  ACTION ( _CoorMenu( oWND, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog ))

  oBtnCoor:SetColor( "
W+/W" )
  oBtnCoor:ReFresh()
  SysReFresh()

  oBtnCoor:lTransparent = .T.
  oBtnCoor:cTooltip := "
COORDINATOR Menu"

@ 180, 0 BTNBMP oBtnLog RESOURCE "
LOGIN"  ;
  SIZE 32,32 ;
  PROMPT cSAY5 CENTER of oDLG // ;
*  ACTION( _Log_in(),                        ;
*          cRIGHTS := _Rights(),             ;
*          xMESSAGE :=  ("
User  "+xLOGIN+"    Rights  "+cRIGHTS+ ;
*                        "
    Default= "+cDEFA+"      Rdd= "+cRDD+  ;
*                        "
    Revision  "+DTOC(dEXE)+               ;
*                        "
 -r"+str(nSCR1,4)+" x "+STR(nSCR2,4) ),;
*                        oWnd:oMsgBar := TMsgBar():New(oWnd,xMESSAGE,.F.,.T.,.F.,.F.,,,,),;
*                        oWnd:ReFresh(),;
*                        MsgInfo( "
Current User is now   "+xLOGIN ),;
*                        SysReFresh() ) ;

  oBtnLog:SetColor( "
W+/W" )
  oBtnLog:ReFresh()
  SysReFresh()

  oBtnLog:lTransparent = .T.
  oBtnLog:cTooltip := "
Login as a different User"

@ 220, 0 BTNBMP oBtnHlp RESOURCE "
INFO" ;
  SIZE 32,32 ;
  PROMPT cSAY6 CENTER of oDLG // ;
*  ACTION ( _Webhelp( cOLDDEFA, dEXE ))

  oBtnHlp:SetColor( "
W+/W" )
  oBtnHlp:ReFresh()
  SysReFresh()

  oBtnHlp:lTransparent = .T.
  oBtnHlp:cTooltip := "
Help on the Intranet"

@ 260, 0 BTNBMP oBtnQuit RESOURCE "
CLOSE" ;
  SIZE 32,32   ;
  PROMPT cSAY7 CENTER of oDLG  ;
  ACTION (  oWND:END() )

  oBtnQuit:SetColor( "
W+/W" )
  oBtnQuit:ReFresh()
  SysReFresh()

  oBtnQuit:lTransparent = .T.
  oBtnQuit:cTooltip := "
Close PCAS"

ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
         ON INIT oDlg:Move( 20, nWidth - 65, 70, nHeight - 75, .f. ) ;
         ON PAINT ( GRADBAR( hDC, oDlg ), GradientBrush( oDlg, xGrad1, .F. ) )

RETURN( NIL )

// ------- Fills the Buttons with Gradient-Background ----------
// ------ otherwise the Buttons are displayed with a white Color --

Static FUNCTION GradientBrush( oDlg, aColors , lDir)

local hDC, hBmp, hBmpOld , nWidth , nHeight

DEFAULT lDir := .T.
if Empty( oDlg:oBrush:hBitmap )
      nHeight := if(lDir,oDlg:nHeight,1)
      nWidth  := if(lDir,1,oDlg:nWidth)
      hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, nHeight, nWidth, aColors,lDir )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
endif

RETURN NIL

// ---------- Fills the Bar with Gradient ---------------------

STATIC FUNCTION GRADBAR( hDC, oDlg )

local aGrad

// main gradient
GradientFill( hDC,  0, 0, oDlg:nHeight + 10, oDlg:nWidth, xGrad1, .F. )

// Must be painted on top of the main-Gradient !!!
*GradientFill( hDC,  0, 0, oDlg:nHeight, 10, xGradstrip, .F. )

RETURN NIL

//---------------------------
Static Func _Rights()

LOCAL cREAD,cWRITE,cSUPER,cADMIN,cRIGHTS

STORE "
" to cREAD,cWRITE,cSUPER,cADMIN

cREAD := "
R"

IF xWRITE = 'Y'
   cWRITE := "
W"
ENDIF
IF xSUPER = "
Y"
   cSUPER := "
S"
ENDIF
IF xADMIN = "
Y"
   cADMIN := "
A"
ENDIF

IF cWRITE = "
" .and. cSUPER = " " .and. cADMIN = " "
   cRIGHTS := "
(READ)"
ELSE
   cRIGHTS := "
("+cREAD+cWRITE+cSUPER+cADMIN+")"
ENDIF

RETURN( cRIGHTS )

//--------------------------//
Static FUNC BuildMenu( cOLDDEFA, dEXE, cRDD,nSCR1,nSCR2,oWnd )

LOCAL oMenu, cRIGHTS, cDEFA

cDEFA := SET(7)

MENU oMenu

     MENUITEM "
                   "

ENDMENU

RETURN( oMenu )

//-----------------------
Static FUNCTION ExitPgm( lCLEAN )

IF lCLEAN = .T.
   lExitPgm := .T.
   SET RESOURCES to
   CLOSE DATABASES
ENDIF

RETURN( lExitPgm )

// end main.prg


Code: Select all  Expand view

// Rptmenu.prg

#include "FiveWin.ch"

STATIC lOK

//----------------------------------
FUNC _Rptmenu( oWnd, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog )

LOCAL oWndChild, oDlg, oBtn1, oBTN2, oBTN3
LOCAL oIco, oSay1, cSAY1

lOK := .F.

oBtnRpt:Hide()
oBtnPcas:Hide()
oBtnUtil:Hide()
oBtnCoor:Hide()
oBtnLog:Hide()

cSAY1 := "Program and Activity Report"


DEFINE ICON oICO RESOURCE "WALKING"

DEFINE WINDOW oWndChild MDICHILD         ;
       FROM 1,1 to 20,50                 ;
       MENU BuildMenu()                  ;
       NOMINIMIZE                        ;
       NOZOOM                            ;
       ICON oICO                         ;
       OF oWnd                           ;
       TITLE "Report Menu"

   oWndChild:bGotFocus  := { || oDlg:SetFocus() }

   DEFINE DIALOG oDlg RESOURCE "RPTMENU" OF oWndChild  ;
   PIXEL TRANSPARENT

   REDEFINE BUTTON oBtn1 ID 101 OF oDlg //  ;
   *   ACTION ( _progrpt() )

   REDEFINE SAY oSAY1 var cSAY1 ID 110 of oDLG update
   oSay1:lTransparent = .t.
   oSay1:nClrText := 128

   REDEFINE BUTTON oBtn2 ID 102 OF oDlg //  ;
   *   ACTION ( _grpsumm() )

   REDEFINE BUTTON oBtn3 ID 105 OF oDlg  ;
      ACTION( dbCloseAll(), oWndChild:End(), oBtnRpt:Show(), ;
             oBtnPcas:Show(), oBtnUtil:Show(), oBtnCoor:Show(),;
             oBtnLog:Show() )

ACTIVATE DIALOG oDlg NOWAIT ;  // It has to be NonModal --> NOWAIT clause
   ON INIT ( oDlg:Move( 0, 0 ) ) ;
   ON PAINT (GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, xGrad5, .T. ))

ACTIVATE WINDOW oWndChild ;
   ON INIT oWndChild:SetSize( oDlg:nWidth, oDlg:nHeight, .T. ) ;
   VALID ( IF( !lOK, RptCLose( .T., oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog ), .T. ))

RETURN(NIL)

//-----------------------
static FUNC BuildMenu()

LOCAL oMENU

MENU oMENU

   MENUITEM "                "

ENDMENU

RETURN( oMENU )


//------------------------
Static FUNCTION RptClose(lCLEAN, oBtnPcas, oBtnRpt,oBtnUtil, oBtnCoor, oBtnLog )

IF lCLEAN = .T.
   lOK := .T.
   oBtnRpt:Show()
   oBtnPcas:Show()
   oBtnUtil:Show()
   oBtnCoor:Show()
   oBtnLog:Show()
   SysReFresh()
ENDIF

RETURN(lOK)

// END
 


Code: Select all  Expand view

RPTMENU DIALOG 27, 23, 184, 227
STYLE WS_CHILD
FONT 10, "MS Sans Serif"
{
 PUSHBUTTON "&Quit", 105, 7, 70, 29, 18
 PUSHBUTTON "1 >>", 101, 7, 26, 29, 18
 PUSHBUTTON "2 >>", 102, 7, 48, 29, 18
 LTEXT "Employee Group Loc\\Prog\\Act\\Report", -1, 44, 51, 123, 12, NOT WS_GROUP
 LTEXT "Return to Main Menu", -1, 44, 73, 123, 12, WS_BORDER | WS_GROUP
 CONTROL "Program and Activity Report", 110, "EDIT", NOT WS_TABSTOP | NOT WS_BORDER, 44, 29, 122, 12
}
 
User avatar
Rick Lipkin
 
Posts: 2615
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error in painting a Transparent say

Postby ukoenig » Wed May 27, 2009 3:19 pm

Hello Rick,

because of the same problem, I changed in the darker background-part the fontcolor to white.

Image

It works fine. I also work with resources.
I will have a look at Your code. There must be something wrong.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Error in painting a Transparent say

Postby ukoenig » Wed May 27, 2009 6:53 pm

Hello Rick,

I had a look at Your code. Just to change some lines, doesn't make much sense.
I think it is better, to make a basic working-structure with some descriptions.
It helps more, because it can be used for other applications.
It can be done this evening.
I know what You want to do and there is no problem to keep the logic.
Do You conform with me ?

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Error in painting a Transparent say

Postby Rick Lipkin » Wed May 27, 2009 7:36 pm

Uwe

Please don't spend a lot of time with this .. we are just talking asthetics .. I am re-working the entire UI and you have got me so far along in the gradient process.

I can live with the winchild dialogs as they are ..

Thank you for all your help and guidence.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2615
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error in painting a Transparent say

Postby ukoenig » Thu May 28, 2009 10:20 am

Hello Rick,

I have done still some tests for myself.

The Result :
The 1. Button opens a Dialog ( after that, the button is hidden )
The 1. Button from the Dialog opens Dialog 2.
< Nowait is not used in Dialog 2. Must be closed, to return to the Main-dialog >

Image

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Error in painting a Transparent say

Postby Rick Lipkin » Thu May 28, 2009 2:19 pm

Uwe

I am interested in your first Dialog from your Gradient Bar and how you made your text ( not button ) transparent ?? that is what I want to do.

Rick
User avatar
Rick Lipkin
 
Posts: 2615
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error in painting a Transparent say

Postby ukoenig » Thu May 28, 2009 3:02 pm

Hello Rick,

To show just some text, You don't need VAR

REDEFINE SAY oSay1 PROMPT "Text 1 Resource 1" ID 110 OF oDlg10 FONT oSayFont
oSay1:lTransparent = .t.
oSay1:nClrText := 128

as small as possible :

Image

PRG-File
Code: Select all  Expand view

#include "FiveWin.ch"
#include "Image.ch"

STATIC oWnd, hDC
STATIC oBarFont, oButtFont, oSayFont, oDlgFont, oSelFont

FUNCTION MAIN()
LOCAL oWnd, oBar, oImage

c_path := CURDRIVE() + ":\" + GETCURDIR() + "\"

SetBalloon( .T. ) // Balloon shape required for tooltips

BAR_COLOR := { { 0.1, 5670785, 16777215 },{ 0.1, 16777215, 5156778 } }

oButtFont := TFont():New("
Arial", ,-14,.F.,.F. , , , ,.F. )
oBarFont := TFont():New("
Arial", ,-14,.F.,.F. , , , ,.F. )
oDlgFont := TFont():New("
Arial", ,-14,.F.,.F. , , , ,.F. )
oSayFont := TFont():New("
Arial", ,-18,.F.,.T. , , , ,.F. )

DEFINE WINDOW oWnd TITLE "
Button-Test"  ;
MDI  MENU TMenu():New()


SET MESSAGE OF oWnd TO "
Button-Test" ;
CENTERED CLOCK KEYBOARD 2007

@ 0, 0 IMAGE oImage SIZE 150, 150 OF oWnd ADJUST
oImage:Progress( .f. )
oImage:LoadBmp( c_path + "
FANTASY.JPG" )

ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT ( oWnd:SetFont(oButtFont), B_BAR( oWnd ) ) ;
ON PAINT ( DRAWBITMAP( hdc, oImage:hbitmap, 0, 0,;
                    oWnd:nWidth(), oWnd:nHeight()) )

oBarFont:End()
oDlgFont:End()
oSayFont:End()

RETURN NIL

// ------------------------------

FUNCTION B_BAR( oWnd )
LOCAL oDlg1, nWidth := GetSysMetrics(0), nHeight := GetSysMetrics(1)
LOCAL nTop := GetSysMetrics(30)
LOCAL oBtn50, oBtn51

nStyle = nOR( WS_OVERLAPPED | WS_VISIBLE )

DEFINE DIALOG oDlg1 FROM 0, 0  TO 100, 100 OF oWnd STYLE nSTYLE PIXEL TRANSPARENT

// 1 = Aktiv
// 2 = Pressed
// 3 = Disabled
// 4 = Mouse-Capt.

@ 0, 8 BTNBMP oBtn50 OF oDlg1 ;
SIZE 45 , 40  PROMPT "
Test 1" ;
FONT oBarFont ;
TOP ;
NOBORDER ;
FILENAME c_path + "
View_A.bmp", ;
                  c_path + "
View_P.bmp",  ;
                  c_path + "
View_D.bmp",  ;
                  c_path + "
View_M.bmp" ;
ACTION ( oBtn50:Hide(), DLG_RES1(oDlg1, oBtn50) )
oBtn50:lTransparent = .T.
oBtn50:cTooltip := "
Test 1"
oBtn50:lBorder := .F.


@ 40, 8 BTNBMP oBtn51 OF oDlg1 ;
SIZE 45 , 40  PROMPT "
Quit" ;
FONT oBarFont ;
TOP ;
NOBORDER ;
FILENAME c_path + "
quit_A.bmp", ;
                  c_path + "
quit_P.bmp", ;
                  c_path + "
quit_D.bmp", ;
                  c_path + "
quit_M.bmp" ;
ACTION oWnd:End()
oBtn51:lTransparent := .T.
oBtn51:cTooltip := "
Quit"
oBtn51:lBorder := .F.

ACTIVATE DIALOG oDlg1 CENTERED NOWAIT ;
ON INIT oDlg1:Move( 20, nWidth - 105, 105, nHeight - 75, .f. ) ;
ON PAINT ( GRADBAR( hDC, oDlg1 ), ;
                    GradientBrush( oDlg1, BAR_COLOR, .F. ) )

RETURN( NIL )

// -----------------------------------------------

STATIC FUNCTION GRADBAR( hDC, oDlg1 )

local aGrad1 := { { 0.1, 128, 16777215 },{ 0.1, 16777215, 128 } }

GradientFill( hDC,  0, 0, oDlg1:nHeight, oDlg1:nWidth, BAR_COLOR, .F. )
GradientFill( hDC,  0, 0, oDlg1:nHeight, 10, aGrad1, .F. )

RETURN NIL

// -------------------------------

FUNCTION GradientBrush( oDlg, aColors , lDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight

DEFAULT lDir := .T.

if Empty( oDlg:oBrush:hBitmap )
      nHeight := if(lDir,oDlg:nHeight,1)
      nWidth  := if(lDir,1,oDlg:nWidth)
      hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, nHeight, nWidth, aColors,lDir )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
endif

RETURN NIL

//------------------- RESOURCE - TEST 1 -----------------------------------------

FUNCTION DLG_RES1( oDlg1, oBtn50 )
local oDlg2, oBtn1
local oSay1, oSay2, oSay3

DEFINE DIALOG oDlg2 RESOURCE "
DIALOG1" of oDlg1 FONT oDlgFont ;
TITLE "
Buttons from Resource Transparent" TRANSPARENT


REDEFINE SAY oSay1  PROMPT "
Text 1   Resource 1" ID 110 OF oDlg2 FONT oSayFont
oSay1:lTransparent = .t.  
oSay1:nClrText := 128

REDEFINE SAY oSay2  PROMPT "
Text 2   Resource 1" ID 120 OF oDlg2 FONT oSayFont
oSay2:lTransparent = .t.  
oSay2:nClrText := 8388608

REDEFINE SAY oSay3  PROMPT "
Text 3   Resource 1" ID 130 OF oDlg2 FONT oSayFont
oSay3:lTransparent = .t.  
oSay3:nClrText := 16777215

REDEFINE BTNBMP oBtn1 ID 80 OF oDlg2 2007 ;
FILENAME c_path + "
quit_A.bmp", ;
                  c_path + "
quit_P.bmp", ;
                  c_path + "
quit_D.bmp", ;
                  c_path + "
quit_M.bmp" ;
ACTION ( oDlg2:End(), oBtn50:Show() ) ;
PROMPT "
Close" ;
FONT oButtFont ;
LEFT
oBtn1:lTransparent = .t.  
oBtn1:cTooltip := "
Close"

ACTIVATE DIALOG oDlg2 CENTERED  NOWAIT ;
ON INIT ( oDlg2:Move( 100, 470, oDlg2:nHeight, oDlg2:nWidth, .f. ), DisableX(oDlg2, .T.) ) ;
ON PAINT ( D_GRADIENT( hDC, oDlg2, .T. ), ;
                    GradientBrush( oDlg2, BAR_COLOR, .T. ) )

RETURN NIL

//-------------------  RESOURCE - TEST 1a -----------------------------------------

FUNCTION DLG_RES10( oDlg2 )
Local oDlg10, oBtn1

DEFINE DIALOG oDlg10 RESOURCE "
DIALOG2" of oDlg2 FONT oDlgFont ;
TITLE "
Buttons from Resource Transparent" TRANSPARENT

REDEFINE SAY oSay1  PROMPT "
Transparent Text 1" ID 110 OF oDlg10 FONT oSayFont
oSay1:lTransparent = .t.  
oSay1:nClrText := 128

REDEFINE SAY oSay2  PROMPT "
Transparent Text 2" ID 120 OF oDlg10 FONT oSayFont
oSay2:lTransparent = .t.  
oSay2:nClrText := 8388608

REDEFINE SAY oSay3  PROMPT "
Transparent Text 3" ID 130 OF oDlg10 FONT oSayFont
oSay3:lTransparent = .t.  
oSay3:nClrText := 16777215

REDEFINE BTNBMP oBtn1 ID 80 OF oDlg10 2007 ;
FILENAME c_path + "
quit_A.bmp", ;
                  c_path + "
quit_P.bmp", ;
                  c_path + "
quit_D.bmp", ;
                  c_path + "
quit_M.bmp" ;
ACTION ( oDlg10:End() ) ;
PROMPT "
Close" ;
FONT oButtFont ;
LEFT
oBtn1:lTransparent = .t.  
oBtn1:cTooltip := "
Close"

ACTIVATE DIALOG oDlg10 CENTERED ;
ON INIT ( oDlg10:Move( 100, 470, oDlg10:nHeight, oDlg10:nWidth, .f. ), DisableX(oDlg10, .T.) ) ;
ON PAINT ( D_GRADIENT( hDC, oDlg10, .F. ), ;
                    GradientBrush( oDlg10, BAR_COLOR, .F. ) )

RETURN( NIL )

// ------------- COLOR ----------------------------------

STATIC FUNCTION D_COLOR( oDlg )
local oCBrush

DEFINE BRUSH oCBrush  COLOR D_COLOR1
SET BRUSH OF oDlg TO oCBrush
RELEASE BRUSH oCBrush

RETURN NIL

// -------------- DIALOG - GRADIENT --------------------

STATIC FUNCTION D_GRADIENT( hDC, oDlg, lDirect )

IF lDirect = .T.
    GradientFill( hDC,  0, 0, oDlg:nHeight, oDlg:nWidth, BAR_COLOR, .T. )
ELSE
    GradientFill( hDC,  0, 0, oDlg:nHeight, oDlg:nWidth, BAR_COLOR, .F. )
ENDIF

RETURN NIL

// ---------------------  EXIT - BUTTON -----------------

FUNCTION DisableX(oWin, lDisable)

LOCAL hMenu  := 0
LOCAL nCount := 0

IF lDisable
    hMenu  = GetSystemMenu(oWin:hWnd, .F.)
    nCount = GetMItemCount(hMenu)
    IF oWin:ClassName() = "
TDIALOG"
        RemoveMenu(hMenu, 1, nOR( 1024, 2) )
    ELSE
        RemoveMenu(hMenu, nCount - 1, nOR( 1024, 2) )
        RemoveMenu(hMenu, nCount - 2, nOR( 1024, 2) )
    ENDIF    
    DrawMenuBar( oWin:hWnd )
ELSE
    GetSystemMenu( oWin:hWnd, .T. )
    DrawMenuBar( oWin:hWnd )
ENDIF

RETURN nil


Resource :
Code: Select all  Expand view

#define DIALOG_5    5
#define DIALOG_4    4
#define DIALOG_3    3
#define DIALOG_2    2
#define DIALOG_1    1
#define WS_VISIBLE  268435456
#define WS_TABSTOP  65536
#define WS_BORDER   8388608
#define ES_RIGHT    2
#define WS_GROUP    131072

#ifdef __FLAT__
  1 24 "WindowsXP.Manifest"
#endif

DIALOG1 DIALOG 41, 81, 244, 194
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "DIALOG_1"
FONT 8, "MS Sans Serif"
{
 CONTROL "", 80, "TBtnBmp", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 77, 122, 87, 48
 LTEXT "Text", 110, 60, 21, 123, 14
 LTEXT "Text", 120, 60, 47, 123, 14
 LTEXT "Text", 130, 61, 72, 123, 14
}

ico ICON Favorite.ico
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests