FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Tget /tsay disable/enable
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Tget /tsay disable/enable
Posted: Thu Nov 09, 2023 07:58 AM
Is it possible to transform a Tsay or Tget control when it is disabled and create a rectangle with the dimensions of the control and fill it with a custom color or brush?

sample



I tried with
Code (fw): Select all Collapse
#include "fivewin.ch"

Function sample()
   local oDlg,oFont
   local nHt      := Int( ScreenHeight() * 0.2 )
   local nWd      := Int( ScreenWidth() * 0.2 )
   local oChk
   local oGet,cGet:= space(100)
   local oSay
   local ncolor1 := RGB(245,245,235)
   local ncolor2 := RGB(250,250,245)
   local lNormal

DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
 DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
       RESIZABLE   TiTle "test" COLOR CLR_BLACK, RGB( 245,245,235)  ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX, WS_THICKFRAME )


@ 10,10 CheckBox oChk Var lNormal  Prompt "check" SIZE 100,20 of oDlg ;
       on change ( If(lNormal,(MakeBox(oGet,oDlg),  oGet:enable()),;
                              (MakeBox(oGet,oDlg) , oGet:disable())),;
                               oGet:refresh() )

   @ 62, 10 SAY oSay PROMPT  "Test Get" SIZE 100,25  PIXEL OF oDlg  TRANSPARENT  FONT oFont
   @ 80, 10 GET oGet VAR cGet SIZE 100,24 PIXEL OF oDlg 

ACTIVATE DIALOG oDlg CENTERED  
return nil

Function MakeBox(oControl,oDlgEdit)
   local oBox
   local aRect       := GetClientRect(oControl:hWnd )
   local hDC := oControl:GetDC()

    local  nOldMode := SetBkMode( hDC, 1 )
    local hBru := TBrush():New( "BDIAGONAL",RGB(195,195,185) )
    local  hOldBrush := SelectObject( hDC, hBru )

      FillRect( hDC,{aRect[1] , aRect[2] ,aRect[4] , aRect[3]  }, hBru )

     SelectObject( hDC, hOldBrush )
     SetBkMode( hDC, nOldMode )
     DeleteObject( hBru )
     oControl:ReleaseDC()
   RETURN NIL
but not work
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Tget /tsay disable/enable
Posted: Thu Nov 09, 2023 08:37 AM

Dear Silvio,

Must the rectangle be painted above the control as per your sample ?

Where are you calling your code from ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Tget /tsay disable/enable
Posted: Thu Nov 09, 2023 08:41 AM
Antonio Linares wrote:Dear Silvio,

Must the rectangle be painted above the control as per your sample ?

Where are you calling your code from ?
yes the rectangle must be painted over the control
in the image example I use a btnbmp and it run on only on btnbmp

for the test I added the code above
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Tget /tsay disable/enable
Posted: Thu Nov 09, 2023 10:04 AM

If you want to paint on the dialog then you must use the hDC of the dialog, don't use the hDC of the control

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Tget /tsay disable/enable
Posted: Thu Nov 09, 2023 10:53 AM
Antonio Linares wrote:If you want to paint on the dialog then you must use the hDC of the dialog, don't use the hDC of the control
Code (fw): Select all Collapse
Function MakeBox(oControl,oDlgEdit)
   local oBox
   local aRect := GetClientRect(oControl:hWnd )
   local hDC :=oDlgEdit:GetDC()

    local  nOldMode := SetBkMode( hDC, 1 )
    local hBru := TBrush():New( "BDIAGONAL",RGB(195,195,185) )
    local  hOldBrush := SelectObject( hDC, hBru )

    FillRect( hDC,{aRect[1] , aRect[2] ,aRect[4] , aRect[3]  }, hBru )

     SelectObject( hDC, hOldBrush )
     SetBkMode( hDC, nOldMode )
     DeleteObject( hBru )
     oDlgEdit:ReleaseDC()
   RETURN NIL
but not work
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Tget /tsay disable/enable
Posted: Thu Nov 09, 2023 11:54 AM

Dera Silvio, mira \samples\KARINHA.PRG si ayuda.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion