Tget /tsay disable/enable

Tget /tsay disable/enable

Postby Silvio.Falconi » Thu Nov 09, 2023 7: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

Image

I tried with

Code: Select all  Expand view  RUN

#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
Last edited by Silvio.Falconi on Thu Nov 09, 2023 8:39 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: Tget /tsay disable/enable

Postby Antonio Linares » Thu Nov 09, 2023 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Tget /tsay disable/enable

Postby Silvio.Falconi » Thu Nov 09, 2023 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: Tget /tsay disable/enable

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Tget /tsay disable/enable

Postby Silvio.Falconi » 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: Select all  Expand view  RUN
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: Tget /tsay disable/enable

Postby karinha » 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
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests