Page 2 of 3

Re: Combobox con marca visual de obligatoriedad

Posted: Sat Apr 26, 2025 1:50 am
by albeiroval
Buen POST, se puede poner un ejemplo con TGET ?

Re: Combobox con marca visual de obligatoriedad

Posted: Sat Apr 26, 2025 11:27 am
by cnavarro
albeiroval wrote: Sat Apr 26, 2025 1:50 am Buen POST, se puede poner un ejemplo con TGET ?
Eso parece mas sencillo, prueba y me comentas

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

    local oDlg, oCmb, cSelected := "                            "

    DEFINE DIALOG oDlg TITLE "ComboBox Example" SIZE 300, 200 PIXEL

    @ 20, 20 GET oCmb VAR cSelected SIZE 110, 16 PIXEL 
   oCmb:bPainted := { || Display( oCmb ) }

    @ 3, 8 BUTTON "OK" SIZE 50, 20 ACTION oDlg:End()

    ACTIVATE DIALOG oDlg CENTERED

    RETURN NIL


static function Display( o )    

   local hDC      := o:oWnd:GetDC()
   local aRect    := GetClientRect( o:hWnd )
   local oBtn

   if Empty( o:Varget() )
   RoundBox( hDC, aRect[ 2 ] + o:nLeft - 6, o:nTop + aRect[ 1 ] - 6, o:nLeft + aRect[ 4 ] + 12, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                         CLR_RED, 4 )
   else
   RoundBox( hDC, aRect[ 2 ] + o:nLeft - 6, o:nTop + aRect[ 1 ] - 6, o:nLeft + aRect[ 4 ] + 12, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                         CLR_GREEN, 4 )
   endif
  o:oWnd:ReleaseDC()

return nil    



Re: Combobox con marca visual de obligatoriedad

Posted: Sat Apr 26, 2025 5:10 pm
by karinha
Excelente master Navarro!

https://imgur.com/v3cXzp8

Image

Regards, saludos.

Re: Combobox con marca visual de obligatoriedad

Posted: Sun Apr 27, 2025 12:57 am
by cnavarro
Joao, quizás así pueda ser más práctico

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

    local oDlg, oCmb, cSelected := "                            "

    DEFINE DIALOG oDlg TITLE "TGet Example" SIZE 300, 200 PIXEL

    @ 20, 20 GET oCmb VAR cSelected SIZE 110, 16 PIXEL 
   oCmb:bPainted := { || Display( oCmb ) }

    @ 3, 8 BUTTON "OK" SIZE 50, 20 ACTION oDlg:End()

    ACTIVATE DIALOG oDlg CENTERED

    RETURN NIL


static function Display( o )    

   local hDC      := o:oWnd:GetDC()
   local aRect    := GetClientRect( o:hWnd )
   local oBtn


   RoundBox( hDC, aRect[ 2 ] + o:nLeft - 6, o:nTop + aRect[ 1 ] - 6, o:nLeft + aRect[ 4 ] + 12, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
             if( Empty( o:Varget() ), CLR_RED, o:oWnd:nClrPane ), ;
             if( Empty( o:Varget() ), 4, 4 ) )    // Esto ultimo es por si queremos poner otro color y cambiar el grueso de la linea
  o:oWnd:ReleaseDC()

return nil    


Re: Combobox con marca visual de obligatoriedad

Posted: Sun Apr 27, 2025 4:13 pm
by karinha
Master Navarro, con GET, funciona PERFECTO! Con COMBOBOX, NO FUNCIONA!

https://imgur.com/sWV9foI

Image

Regards, saludos.

Re: Combobox con marca visual de obligatoriedad

Posted: Sun Apr 27, 2025 4:15 pm
by karinha
Código:

Code: Select all | Expand

// C:\GETBORDE\TESTGET3.PRG - 26/04/2025 - By Kapiaba the best.
// MODIFICADO EM: 27/04/2025 - Por: Joao Santos - Sao Paulo/Brazil.

#include "fivewin.ch"

FUNCTION Main()

   LOCAL oWnd, oMenu, oFont, oSkinB

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

   oSkinB = TSkinButton():New()

   oSkinB:nClrBorder0_N := RGB( 249, 194, 179 )
   oSkinB:nClrBorder1_N := RGB( 181, 61, 29 )
   oSkinB:aClrNormal    := { { .50, nRGB( 210, 235, 216 ), nRGB(   0,  73, 138 ) } }

   SkinButtons( oSkinB )

   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -14 BOLD

   MENU oMenu 2007

      MenuItem "From Resource" ACTION FromrES( oWnd )

      MENUITEM "&Salida" ACTION( oWnd:End() )

   ENDMENU

   DEFINE WINDOW oWnd TITLE "Test Button Get Transparent" MENU oMenu PIXEL

   oWnd:SetFont( oFont )

   ACTIVATE WINDOW oWnd MAXIMIZED

   oFont:End()

RETURN NIL

FUNCTION FromRes( oWnd )

   LOCAL oDlg, oGet1, oGet2, oGet3, oGet4, cVar1, cVar2, cVar3, cVar4, oFont
   LOCAL oBtnDisp, lActive := .F., cLinares, oGet, oFont2, oBtnVisu, oSay
   LOCAL oSaida, oFnt, oCbx, cItem := "", aGrad

   cVar1 := 0
   cVar2 := 0
   cVar3 := 0
   cVar4 := 0
   cLinares := SPACE(50)

   cLinares := oEmToAnsi( "USER: ANTONIO LI¥ARES CA¥AS" )

   aGrad := { { .50, nRGB( 210, 235, 216 ), nRGB( 255, 255, 255 ) } }

   DEFINE FONT oFnt   NAME "Ms Sans Serif" SIZE 00, -12 BOLD
   DEFINE FONT oFont  NAME "Ms Sans Serif" SIZE 00, -14 BOLD
   DEFINE FONT oFont2 NAME "Ms Sans Serif" SIZE 00, -18 BOLD

   DEFINE DIALOG oDlg RESOURCE "fromres" OF oWnd GRADIENT aGrad FONT oFont

   oDlg:lHelpIcon := .F.

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   REDEFINE SAY ID 401 OF oDlg COLORS METRO_AMBER,  CLR_WHITE UPDATE FONT oFont TRANSPARENT
   REDEFINE SAY ID 402 OF oDlg COLORS METRO_PINK,   CLR_WHITE UPDATE FONT oFont TRANSPARENT
   REDEFINE SAY ID 403 OF oDlg COLORS METRO_COBALT, CLR_WHITE UPDATE FONT oFont TRANSPARENT
   REDEFINE SAY ID 430 OF oDlg COLORS CLR_BLACK,    CLR_WHITE UPDATE FONT oFnt  TRANSPARENT

   REDEFINE GET oGet1 VAR cVar1 id 100 bitmap "on" UPDATE ;
      ACTION( msginfo( "With Transparent" ) ) of oDlg

   oGet1:lBtnTransparent := .T.       // transparent button get oGet1

   REDEFINE GET oGet2 VAR cVar2 id 101 bitmap "on"UPDATE  ;
      ACTION( msginfo( "Without Transparent" ) ) of oDlg

   oGet2:lBtnTransparent := .T.       // transparent button get oGet1

   REDEFINE GET oGet3 VAR cVar3 id 102 bitmap "chkyes" UPDATE ;
      ACTION( msginfo( "With Adjust-Transparent" ) )   ;
      COLOR CLR_BLACK, CLR_CYAN of oDlg

   oGet3:disable()
   oGet3:lBtnTransparent := .T.       // transparent button get oGet3
   oGet3:lAdjustBtn      := .T.       // Button Get Adjust Witdh oGet3
   oGet3:lDisColors      := .F.       // Deactive disable color
   oGet3:nClrTextDis     := CLR_WHITE // Color text disable status
   oGet3:nClrPaneDis     := CLR_BLUE  // Color Pane disable status

   REDEFINE GET oGet4 VAR cVar4 id 103 bitmap "chkyes" UPDATE ;
      ACTION( if( lActive, oGet3:disable(), oGet3:enable() ), ;
                  lActive := !lActive, oDlg:Update() ) of oDlg

   oGet4:lAdjustBtn := .T.

   REDEFINE GET oGet VAR cLinares ID 4001 OF oDlg PICTURE "@!" UPDATE        ;
      COLORS METRO_ORANGE, CLR_WHITE FONT oFont2

   REDEFINE BITMAP oBtnVisu ID 122 RESOURCE "FIVEWIN" TRANSPARENT OF oDlg

   REDEFINE BUTTONBMP oSaida ID 301 OF oDlg RESOURCE "EXIT" TEXTRIGHT        ;
      ACTION ( oDlg:End() ) CANCEL

   oSaida:cTooltip := { "Click no Botão Para Sair",                          ;
                        "Saida - Exit - Cancelar ", 1, CLR_WHITE, CLR_CYAN }

   oGet:bPainted := { || Display( oGet ) }

   REDEFINE BITMAP oBtnDisp ID 121 RESOURCE "HOME"    TRANSPARENT OF oDlg

   REDEFINE COMBOBOX oCbx VAR cItem ITEMS { "Testing", "this", "ComboBox" } ;
      HEIGHTGET 24 ID 210 OF oDlg COLOR "W*/R+"                             ;
      VALID ( MsgBeep(), .t. )

   oCbx:bPainted := { || Display2( oCbx ) }

   ACTIVATE DIALOG oDlg CENTERED

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   oFont:End()
   oFont2:End()
   oFnt:End()

RETURN NIL

STATIC FUNCTION Display( o )  // CON GET FUNCIONA PERFECTO!

   LOCAL hDC      := o:oWnd:GetDC()
   LOCAL aRect    := GetClientRect( o:hWnd )
   LOCAL oBtn

   IF Empty( o:Varget() )

      RoundBox( hDC, aRect[ 2 ] + o:nLeft - 6, o:nTop + aRect[ 1 ] - 6, o:nLeft + aRect[ 4 ] + 6, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                            CLR_RED, 4 )
   ELSE

      RoundBox( hDC, aRect[ 2 ] + o:nLeft - 22, o:nTop + aRect[ 1 ] - 4, o:nLeft + aRect[ 4 ] + 6, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                            CLR_GREEN, 4 )

   ENDIF

   o:oWnd:ReleaseDC()

RETURN NIL

STATIC FUNCTION Display2( o ) // CON COMBOBOX, NO FUNCIONA!

   local hDC      := o:oWnd:GetDC()
   local aRect    := GetClientRect( o:hWnd )
   local oBtn

   if Empty( o:Varget() )

      RoundBox( hDC, aRect[ 2 ] + o:nLeft - 6, o:nTop + aRect[ 1 ] - 6, o:nLeft + aRect[ 4 ] + 12, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                            CLR_RED, 4 )
   else

      RoundBox( hDC, aRect[ 2 ] + o:nLeft - 16, o:nTop + aRect[ 1 ] - 6, o:nLeft + aRect[ 4 ] + 12, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                            CLR_GREEN, 4 )

   endif

   o:oWnd:ReleaseDC()

RETURN NIL

// FIN / END - kapiabafwh@gmail.com
Regards, saludos.

Re: Combobox con marca visual de obligatoriedad

Posted: Sun Apr 27, 2025 4:18 pm
by Armando
Saludos a todo el foro:

Siguiendo este post, me surge la idea, (seguramente ya existe la solución), se puede cambiar el color del marco cuando
tenga el foco?, cómo?, para todos los controles.

Esto es para que el usuario vea donde esta el foco.

Saludos

Re: Combobox con marca visual de obligatoriedad

Posted: Sun Apr 27, 2025 4:25 pm
by karinha
Download completo: *.PRG, *.RC y *.RES,

https://mega.nz/file/EFkmhJxS#KaPLU6fWt ... q900wjVAFU

Regards, saludos.

Re: Combobox con marca visual de obligatoriedad

Posted: Sun Apr 27, 2025 11:01 pm
by cnavarro
karinha wrote: Sun Apr 27, 2025 4:13 pm Master Navarro, con GET, funciona PERFECTO! Con COMBOBOX, NO FUNCIONA!

https://imgur.com/sWV9foI

Image

Regards, saludos.

Joao, evidentemente no funciona con combobox, el control TCombobox no tiene el method Paint, por lo que no puedes usar el bPainted, tienes que usar la técnica que utilizo en:
viewtopic.php?p=279177#p279177

Re: Combobox con marca visual de obligatoriedad

Posted: Sun Apr 27, 2025 11:04 pm
by cnavarro
Armando wrote: Sun Apr 27, 2025 4:18 pm Saludos a todo el foro:

Siguiendo este post, me surge la idea, (seguramente ya existe la solución), se puede cambiar el color del marco cuando
tenga el foco?, cómo?, para todos los controles.

Esto es para que el usuario vea donde esta el foco.

Saludos
Solo existe para los GETS

Code: Select all | Expand

     // Ponerlo al principio de tu app
      SetGetColorFocus( 16776960 )    // Color: CLR_CYAN, Rgb( 200, 200, 200 ) o el que consideres

Re: Combobox con marca visual de obligatoriedad

Posted: Mon Apr 28, 2025 1:49 pm
by karinha
Excelente master Navarro!! Resuelto!

https://imgur.com/ODg5GEM

Image

Muchas gracias.

Regards, saludos.

Re: Combobox con marca visual de obligatoriedad

Posted: Mon Apr 28, 2025 1:57 pm
by karinha
Código:

Code: Select all | Expand

// C:\GETBORDE\TESTGET3.PRG - 26/04/2025 - By Kapiaba the best of the World.
// MODIFICADO EM: 28/04/2025 - Por: Joao Santos - Sao Paulo/Brazil.

#Include "FiveWin.ch"

#define METRO_VERDE13 nRGB(  34, 177,  76 )
#define CLR_VSBAR     nRGB( 207, 214, 228 )
#define CLR_VSMAR     nRGB(   0,  73, 138 )

FUNCTION Main()

   LOCAL oWnd, oMenu, oFont, oSkinB, oIco

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

   oSkinB = TSkinButton():New()

   oSkinB:nClrBorder0_N := RGB( 249, 194, 179 )
   oSkinB:nClrBorder1_N := RGB( 181, 61, 29 )
   oSkinB:aClrNormal    := { { .50, nRGB( 210, 235, 216 ), nRGB(   0,  73, 138 ) } }

   SkinButtons( oSkinB )

   DEFINE ICON oIco   RESOURCE "ICONE05"  // EN: TESTGET3.RES
   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -14 BOLD

   MENU oMenu 2007

      MenuItem "From Resource" ACTION FromrES( oWnd )

      MENUITEM "&Salida" ACTION( oWnd:End() )

   ENDMENU

   DEFINE WINDOW oWnd TITLE "Test Button Get Transparent" MENU oMenu PIXEL   ;
      ICON oIco MDI

   oWnd:SetFont( oFont )

   ACTIVATE WINDOW oWnd MAXIMIZED

   oFont:End()

RETURN NIL

FUNCTION FromRes( oWnd )

   LOCAL oDlg, oGet1, oGet2, oGet3, oGet4, cVar1, cVar2, cVar3, cVar4, oFont
   LOCAL oBtnDisp, lActive := .F., cLinares, oGet, oFont2, oBtnVisu, oSay
   LOCAL oSaida, oFnt, oCbx, cItem := "", aGrad, oBtnFive, oIco

   cVar1 := 0
   cVar2 := 0
   cVar3 := 0
   cVar4 := 0
   cLinares := SPACE(50)

   cLinares := OemToAnsi( "USER: ANTONIO LI¥ARES CA¥AS" )

   aGrad := { { .50, nRGB( 210, 235, 216 ), nRGB( 255, 255, 255 ) } }

   DEFINE ICON oIco   RESOURCE "ICONE05"  // EN: TESTGET3.RES
   DEFINE FONT oFnt   NAME "Ms Sans Serif" SIZE 00, -12 BOLD
   DEFINE FONT oFont  NAME "Ms Sans Serif" SIZE 00, -14 BOLD
   DEFINE FONT oFont2 NAME "Ms Sans Serif" SIZE 00, -18 BOLD

   DEFINE DIALOG oDlg RESOURCE "fromres" OF oWnd GRADIENT aGrad ICON oIco    ;
      FONT oFont

   oDlg:lHelpIcon := .F.

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   REDEFINE SAY ID 401 OF oDlg COLORS METRO_AMBER,   CLR_WHITE UPDATE FONT oFont TRANSPARENT
   REDEFINE SAY ID 402 OF oDlg COLORS METRO_PINK,    CLR_WHITE UPDATE FONT oFnt  TRANSPARENT
   REDEFINE SAY ID 403 OF oDlg COLORS METRO_COBALT,  CLR_WHITE UPDATE FONT oFont TRANSPARENT
   REDEFINE SAY ID 404 OF oDlg COLORS METRO_VERDE13, CLR_WHITE UPDATE FONT oFont TRANSPARENT
   REDEFINE SAY ID 430 OF oDlg COLORS CLR_VSMAR,     CLR_WHITE UPDATE FONT oFnt  TRANSPARENT

   REDEFINE GET oGet1 VAR cVar1 id 100 bitmap "on" UPDATE ;
      ACTION( MsgInfo( "With Transparent" ) ) of oDlg

   oGet1:lBtnTransparent := .T.       // transparent button get oGet1

   REDEFINE GET oGet2 VAR cVar2 id 101 bitmap "on"UPDATE  ;
      ACTION( MsgInfo( "Without Transparent" ) ) of oDlg

   oGet2:lBtnTransparent := .T.       // transparent button get oGet1

   REDEFINE GET oGet3 VAR cVar3 id 102 bitmap "chkyes" UPDATE ;
      ACTION( MsgInfo( "With Adjust-Transparent" ) )   ;
      COLOR CLR_BLACK, CLR_CYAN of oDlg

   oGet3:disable()
   oGet3:lBtnTransparent := .T.       // transparent button get oGet3
   oGet3:lAdjustBtn      := .T.       // Button Get Adjust Witdh oGet3
   oGet3:lDisColors      := .F.       // Deactive disable color
   oGet3:nClrTextDis     := CLR_WHITE // Color text disable status
   oGet3:nClrPaneDis     := CLR_BLUE  // Color Pane disable status

   REDEFINE GET oGet4 VAR cVar4 id 103 bitmap "chkyes" UPDATE ;
      ACTION( if( lActive, oGet3:disable(), oGet3:enable() ), ;
                  lActive := !lActive, oDlg:Update() ) of oDlg

   oGet4:lAdjustBtn := .T.

   REDEFINE GET oGet VAR cLinares ID 4001 OF oDlg PICTURE "@!" UPDATE        ;
      COLORS METRO_ORANGE, CLR_WHITE FONT oFont2

   oGet:bPainted := { || Display( oGet ) }

   REDEFINE BITMAP oBtnDisp ID 121 RESOURCE "HOME"     TRANSPARENT OF oDlg
   REDEFINE BITMAP oBtnVisu ID 122 RESOURCE "FIVEWIN"  TRANSPARENT OF oDlg
   REDEFINE BITMAP oBtnFive ID 123 RESOURCE "FIVETECH" TRANSPARENT OF oDlg

   REDEFINE BUTTONBMP oSaida ID 301 OF oDlg RESOURCE "EXIT" TEXTRIGHT        ;
      ACTION ( oDlg:End() ) CANCEL

   oSaida:cTooltip := { "Click no Botão Para Sair",                          ;
                        "Saida - Exit - Cancelar ", 1, CLR_WHITE, CLR_CYAN }

   REDEFINE COMBOBOX oCbx VAR cItem ITEMS { "Testing", "this", "ComboBox" } ;
      HEIGHTGET 24 ID 210 OF oDlg COLOR "W*/R+"                             ;
      VALID ( MsgBeep(), .t. )

   __clsAddMsg( oCbx:ClassH, "Display", @Display2(), HB_OO_MSG_METHOD,, 1 )

   ACTIVATE DIALOG oDlg CENTERED

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   oFont:End()
   oFont2:End()
   oFnt:End()

RETURN NIL

STATIC FUNCTION Display( o )  // CON GET FUNCIONA PERFECTO!

   LOCAL hDC      := o:oWnd:GetDC()
   LOCAL aRect    := GetClientRect( o:hWnd )
   LOCAL oBtn

   IF Empty( o:Varget() )

      RoundBox( hDC, aRect[ 2 ] + o:nLeft - 6, o:nTop + aRect[ 1 ] - 6, o:nLeft + aRect[ 4 ] + 6, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                            CLR_RED, 4 )
   ELSE

      RoundBox( hDC, aRect[ 2 ] + o:nLeft - 22, o:nTop + aRect[ 1 ] - 4, o:nLeft + aRect[ 4 ] + 6, o:nTop + aRect[ 3 ] + 12, 0, 0, ;
                            CLR_GREEN, 4 )

   ENDIF

   o:oWnd:ReleaseDC()

RETURN NIL

STATIC FUNCTION Display2( o ) // CON COMBOBOX, FUNCIONA PERFECTO!

   LOCAL Self := QSelf()
   LOCAL hDC      := ::GetDC()
   LOCAL aRect    := GetClientRect( ::hWnd )

   IF Empty( ::Varget() )

      RoundBox( hDC, aRect[ 2 ] - 6, aRect[ 1 ] - 6, aRect[ 4 ] + 6, aRect[ 3 ] + 6, 0, 0, ;
          METRO_ORANGE, 4 )

   ELSE

      RoundBox( hDC, aRect[ 2 ] - 6, aRect[ 1 ] - 6, aRect[ 4 ] + 6, aRect[ 3 ] + 6, 0, 0, ;
          METRO_ORANGE, 4 )

   ENDIF

   ::ReleaseDC()

RETURN NIL

// FIN / END - kapiabafwh@gmail.com
Regards, saludos.

Re: Combobox con marca visual de obligatoriedad

Posted: Mon Apr 28, 2025 2:04 pm
by karinha
Download completo: *.EXE, *.RES, *.RC, *.PRGS, etc.

https://mega.nz/file/5IUlxYpL#m5Kfhm2GL ... -Ytgd3ubaU

Regards, saludos.

Re: Combobox con marca visual de obligatoriedad

Posted: Mon Apr 28, 2025 4:36 pm
by sysctrl2
es un gran foro !!!

Re: Combobox con marca visual de obligatoriedad

Posted: Mon Apr 28, 2025 4:46 pm
by sysctrl2
El rectángulo de color solo debería de aparecer en el GET activo :shock:
se puede ? :lol: