FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Get Disabled (Solved )
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Get Disabled (Solved )
Posted: Fri Sep 11, 2009 11:20 PM
Why this no work when Get is disabled ?

someone can help ?

Code (fw): Select all Collapse
#include "fivewin.ch"
function main()

 local  odlg, oget, cVar:=space(50),ogetb, cVarb:=space(50)

 define dialog odlg 

  @ 5, 10 get oGet  var cVar  of odlg pixel size 120, 10 noborder color CLR_WHITE
  @ 20, 10 get oGetb var cVarb of odlg pixel size 120, 10 noborder color CLR_WHITE 

  oGet:lTransparent = .T.
  oGetb:lTransparent = .T.

 activate dialog odlg centered on init( GradGet( Self ) )


return nil

function GradGet( _oDlg )
local oControl
local aColors :=   { { 0.4, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) },;
                     { 0.6, nRGB( 24,  61, 118 ), nRGB( 50, 95, 158 ) } } 
local hBmp, n
local oBrush


  for n = 1 to Len(_oDlg:aControls)
     oControl:= _oDlg:aControls[ n ]
     if "TGET" $ oControl:ClassName()
        hBmp = GradientBmp( oControl, oControl:nWidth, oControl:nHeight, aColors )
        oBrush = TBrush():New( , , , , hBmp )
        oControl:SetBrush( oBrush )
        DeleteObject( hBmp )
     endif

  next

return Nil


thanks
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 12:34 AM

SOmeone

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 01:17 AM
Hello lailton..

Sorry for late reply...
please try with

Code (fw): Select all Collapse
...
 oGet:bPainted = {| hDC, PS, oGet | filldis( hDC, oGet ) }
...

function filldis( hDC, oGet )
   FillRect( hDC, GetClientRect( oGet:hWnd ), oGet:oBrush:hBrush )
return nil
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 03:57 AM

Daniel thanks for your help

a ask

oGet:bPainted = {| hDC, PS, oGet | filldis( hDC, oGet ) }

hDc es lo mesmo que oGet:hDc ?
se no existe alguna forma de retornar a ele somiente con lo oGET ou com lo oDLG ?

gracias.

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 04:01 AM

What i think in make is: ( this insede of funcion background that is executed in painted of oDlg

if .not. oControl:lActive
filldis( oControl:hDC, oControl ) // i did it more no work :( think that o oControl:hDc is wrong... )
endif

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 05:15 AM

Daniel,

tua solucion funcionou pero lo Texto del GET no exibe es como no tive-se nada en lo campo,

tien como hacer un exemplo para nos ?

usando GET disabled, y color degrade del get disabled in vermelho y los get enabled azul

gracias.

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 12:36 PM
Hello Lailton...

you need change the TGET CLASS, i'll explain you how to do
LOCATE:
Code (fw): Select all Collapse
#define EM_SETCUEBANNER   0x1501


ADD AFTER
Code (fw): Select all Collapse
#define TRANSPARENT         0x01


LOCATE:
Code (fw): Select all Collapse
   DATA   cCueText


ADD AFTER
Code (fw): Select all Collapse
   DATA   nTxtStyle


LOCATE (METHOD NEW):
Code (fw): Select all Collapse
   ::cCueText  = cCueText


ADD AFTER
Code (fw): Select all Collapse
   ::nTxtStyle = nOR( ETO_CLIPPED, ETO_OPAQUE )


LOCATE (METHOD REFEDINE):
Code (fw): Select all Collapse
   ::cCueText  = cCueText


ADD AFTER
Code (fw): Select all Collapse
   ::nTxtStyle = nOR( ETO_CLIPPED, ETO_OPAQUE )


LOCATE METHOD PAINT:
REPLACE WITH:
Code (fw): Select all Collapse
METHOD Paint() CLASS TGet

   local aInfo := ::DispBegin()
   local hOldFont
   local nClrBtnTxt, nClrBtnPane
   local nOldMode

   nClrBtnTxt := ::nClrText
   nClrBtnPane := ::nClrPane
   

   if ::oBrush != nil
      FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
   else
      CallWindowProc( ::nOldProc, ::hWnd, WM_ERASEBKGND, ::hDC, 0 )
   endif

   if IsWindowEnabled( ::hWnd )
      CallWindowProc( ::nOldProc, ::hWnd, WM_PAINT, ::hDC, 0 )
   else
         
      if ::lDisColors
         SetTextColor( ::hDC, GetSysColor( COLOR_GRAYTEXT ) )
         SetBkColor( ::hDC, GetSysColor( COLOR_WINDOW ) )
         nClrBtnPane := GetSysColor( COLOR_WINDOW )
      else
        if ValType( ::nClrTextDis ) == "B"
            SetTextColor( ::hDC, Eval( ::nClrTextDis ) )
        elseif ValType( ::nClrTextDis ) == "N"
            if ::nClrTextDis >= 0 
                SetTextColor( ::hDC, ::nClrTextDis  )
                nClrBtnTxt := ::nClrTextDis
            else
           SetTextColor( ::hDC, ::nClrText )
          endif
        endif
        
        if ValType( ::nClrPaneDis ) == "B"
            SetBkColor( ::hDC, Eval( ::nClrPaneDis ) )
        elseif ValType( ::nClrPaneDis ) == "N"
            if ::nClrPaneDis >= 0 
                SetBkColor( ::hDC, ::nClrPaneDis  )
                nClrBtnPane := ::nClrPaneDis
            else
           SetBkColor( ::hDC, ::nClrPane )
            endif
        endif
      endif
      
      if ::oFont != nil
         hOldFont = SelectObject( ::hDC, ::oFont:hFont )
      endif

      nOldMode = SetBkMode( ::hDC, TRANSPARENT )
      
      do case
         case lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), ES_CENTER )
              SetTextAlign( ::hDC, TA_CENTER )
              if ::lSpinner
                 ExtTextOut( ::hDC, 1, ( ::nWidth() - 3 - GetSysMetrics( SM_CYHSCROLL ) ) / 2,;
                    { 0, 0, ::nHeight(), ::nWidth() }, GetWindowText( ::hWnd ), ::nTxtStyle )
              else
                 ExtTextOut( ::hDC, 1, ( ::nWidth() - 3 ) / 2,;  
                   { 0, 0, ::nHeight(), ::nWidth() }, GetWindowText( ::hWnd ), ::nTxtStyle )
              endif

                 case lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), ES_RIGHT )
              SetTextAlign( ::hDC, TA_RIGHT )
              if ::lSpinner
                 ExtTextOut( ::hDC, 1, ::nWidth() - 7 - GetSysMetrics( SM_CYHSCROLL ),; 
                    { 0, 0, ::nHeight(), ::nWidth() }, GetWindowText( ::hWnd ), ::nTxtStyle )
              else
                  if ValType( ::bAction ) == "B"                                                                
                      ExtTextOut( ::hDC, 1, ::nWidth() - 7 - ::nHeight,;                
                    { 0, 0, ::nHeight(), ::nWidth() }, GetWindowText( ::hWnd ), ::nTxtStyle ) 
                 else                                                                                                                       
                    ExtTextOut( ::hDC, 1, ::nWidth() - 7 ,; 
                    { 0, 0, ::nHeight(), ::nWidth() }, GetWindowText( ::hWnd ), ::nTxtStyle )
                  endif                                                                                                                     
              endif 

         otherwise
              SetTextAlign( ::hDC, TA_LEFT )
              ExtTextOut( ::hDC, 1, 2,;
                { 0, 0, ::nHeight(), ::nWidth() }, GetWindowText( ::hWnd ), ::nTxtStyle )
      endcase
      
      if ::oFont != nil
         SelectObject( ::hDC, hOldFont )
      endif
      
      SetBkMode( ::hDC, nOldMode )

   endif

   
   if ValType( ::bPainted ) == "B"
      Eval( ::bPainted, ::hDC, ::cPS, Self )
   endif

// button

  if ::oBtn != nil .and. ::lBtnTransparent
     ::oBtn:SetColor( nClrBtnTxt, nClrBtnPane )        
  endif


  ::DispEnd( aInfo )

return 1


PRG SAMPLE
http://www.sitasoft.com/fivewin/test/getfill.zip

Code (fw): Select all Collapse
#include "fivewin.ch"
function main()

 local  odlg, oget, cVar:="This a TGET Gradient Test",ogetb, cVarb:=space(50)


 define dialog odlg SIZE 600, 600

  @ 5, 10 get oGet var cVar  of odlg pixel size 120, 10  color CLR_WHITE when( ! empty( cVarb ) )
  @ 20, 10 get cVarb of odlg pixel size 120, 10 color CLR_WHITE
  @ 35, 10 get cVar  of odlg pixel size 120, 10 color CLR_WHITE
  @ 50, 10 get cVarb of odlg pixel size 120, 10 noborder color CLR_WHITE 
  @ 65, 10 get cVar  of odlg pixel size 120, 10 noborder color CLR_WHITE
  @ 80, 10 get cVarb of odlg pixel size 120, 10 noborder color CLR_WHITE 
  @ 95, 10 get cVar  of odlg pixel size 120, 10 noborder color CLR_WHITE
  @ 110, 10 get cVarb of odlg pixel size 120, 10 noborder color CLR_WHITE 
  @ 125,10 say "this a test" of odlg pixel

  oGet:lDisColors = .f.
  oGet:nClrTextDis = CLR_BLACK

 activate dialog odlg centered on init( GradGet( Self ) )


return nil

function GradGet( _oDlg )
local oControl
local aColors :=    { { 0.4, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) },;
                     { 0.6, nRGB( 24,  61, 118 ), nRGB( 50, 95, 158 ) } }
local hBmp, n
local oBrush


  for n = 1 to Len(_oDlg:aControls)
     oControl:= _oDlg:aControls[ n ]
     if oControl:ClassName() == "TGET"
        oControl:lTransparent = .T.
        oControl:nTxtStyle = 4
        hBmp = GradientBmp( oControl, oControl:nWidth, oControl:nHeight, aColors )
        oBrush = TBrush():New( )
        oBrush:hBrush = CreatePatternBrush( hBmp )
        oControl:SetBrush( oBrush )
        DeleteObject( hBmp )
     endif

  next

return Nil


function GradientBmp( oWnd, nWidth, nHeight, aColors )

   local hDC, hBmp, hBmpOld
   local aRect := GetClientRect( oWnd:hWnd )

   default nHeight := aRect[ 3 ] , nWidth := aRect[ 4 ]

   hDC     = CreateCompatibleDC( oWnd:GetDC() )
   hBmp    = CreateCompatibleBitMap( oWnd:hDC, nWidth, nHeight )
   hBmpOld = SelectObject( hDC, hBmp )
   GradientFill( hDC, 0, 0, nHeight, nWidth, aColors )
   SelectObject( hDC, hBmpOld )
   DeleteDC( hDC )
   DeleteObject( hBmpOld )
   oWnd:ReleaseDC()

return hBmp

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 02:01 PM

Hello...

This feature will be include in next build FWH

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 02:51 PM

I will try

thanks Daniel

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Sun Sep 13, 2009 03:30 PM
Daniel in fwh902 don´t have
Data cCueText, so i added lanter of all data
i change all that you say me more no solved.

when is disabled, FillRect do hidden value of GET

look it.


:-)
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Get Disabled
Posted: Mon Sep 14, 2009 03:05 AM

Lailton...

i'll prepare the TGET change for your FWH version

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Mon Sep 14, 2009 03:13 AM

Thanks so much Daniel i will wait.

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Get Disabled
Posted: Mon Sep 14, 2009 09:24 AM
Lailton...

i made same change in TGET ver 9.02 and work fine

you need create the data TxtStyle for TGET class and init in NEW and REDEFINE

can use the same Paint method posted here

ps: don't forget define TRANSPARENT
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Get Disabled
Posted: Mon Sep 14, 2009 12:11 PM

Daniel,

I replace all the method PAINT and now it WORK FINE !!!!!!!!!!!!!

thanks so much !

Continue the discussion