combobox color

Re: combobox color

Postby nageswaragunupudi » Mon Apr 29, 2024 6:22 am

Silvio.Falconi wrote:I have a combobox
@ 10, 120 COMBOBOX aget[1] VAR cCategoria Items ArrTranspose(aCategorie )[ 2] size 200,90 PIXEL OF oDlg
...
I wish change color and font of text only on these two items


Please test this sample and use your own font and colors for these items
Code: Select all  Expand view
#include "fivewin.ch"

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

function Main()

   local oWnd, oCbx, aItems[7], cItem, oFont

   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-16
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )

   AEval( aItems, { |c,i | aItems[ i ] := NTOCDOW( i ) } )
   cItem    := aItems[ 1 ]

   @ 80,40 COMBOBOX oCbx VAR cItem ITEMS aItems SIZE 150,300 PIXEL OF oWnd ;
      OWNERDRAW OwnerDrawItem( Self, nIdCtl, oItemStruct )

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont

return nil

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

function OwnerDrawItem( Self, nIdCtl, oItem )

   local oFont, nClrText, nClrBack
   local hDC      := oItem:hDC

   if oItem:itemID >= 0
      if oItem:itemID == 0 .or. oItem:itemID == ( Len( ::aItems ) - 1 )
         oFont    := ::oFont:Bold()
         nClrBack    := If( lAnd( oItem:itemState, 1 ), CLR_HGREEN, CLR_YELLOW )
         nClrText    := If( lAnd( oItem:itemState, 1 ), CLR_HRED, CLR_HRED )
      else
         nClrBack    := If( lAnd( oItem:itemState, 1 ), CLR_HGRAY, CLR_WHITE )
         nClrText    := If( lAnd( oItem:itemState, 1 ), CLR_BLACK, CLR_BLACK )
      endif

      FW_SayText( hDC, oItem:itemData, oItem:aRect,"L", IfNil( oFont, ::oFont ), ;
         nClrText, nARGB( 255, nClrBack ) )

      RELEASE FONT oFont
   endif

return 1


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10287
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: combobox color

Postby Jimmy » Mon Apr 29, 2024 7:16 am

hi,
thx for The Solution, it is much simple than my Solution
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1590
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: combobox color

Postby Otto » Mon Apr 29, 2024 10:17 am

Dear Mr. Rao,

This is a very good solution.

However, it seems inappropriate that we should be restricted from discussing solutions involving WebView and Mod Harbour, as Mr. Silvio suggests.

We urgently need effective solutions for the web, and it's essential to accelerate our learning curve.
Providing samples that address specific questions, such as how things can be accomplished using the WebView interface, would be beneficial.

Thanks to FIVETECH, we have the necessary tools; now we just need to utilize them.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6038
Joined: Fri Oct 07, 2005 7:07 pm

Re: combobox color

Postby Silvio.Falconi » Mon Apr 29, 2024 4:32 pm

nageswaragunupudi wrote:
Silvio.Falconi wrote:I have a combobox
@ 10, 120 COMBOBOX aget[1] VAR cCategoria Items ArrTranspose(aCategorie )[ 2] size 200,90 PIXEL OF oDlg
...
I wish change color and font of text only on these two items


Please test this sample and use your own font and colors for these items
Code: Select all  Expand view
#include "fivewin.ch"

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

function Main()

   local oWnd, oCbx, aItems[7], cItem, oFont

   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-16
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )

   AEval( aItems, { |c,i | aItems[ i ] := NTOCDOW( i ) } )
   cItem    := aItems[ 1 ]

   @ 80,40 COMBOBOX oCbx VAR cItem ITEMS aItems SIZE 150,300 PIXEL OF oWnd ;
      OWNERDRAW OwnerDrawItem( Self, nIdCtl, oItemStruct )

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont

return nil

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

function OwnerDrawItem( Self, nIdCtl, oItem )

   local oFont, nClrText, nClrBack
   local hDC      := oItem:hDC

   if oItem:itemID >= 0
      if oItem:itemID == 0 .or. oItem:itemID == ( Len( ::aItems ) - 1 )
         oFont    := ::oFont:Bold()
         nClrBack    := If( lAnd( oItem:itemState, 1 ), CLR_HGREEN, CLR_YELLOW )
         nClrText    := If( lAnd( oItem:itemState, 1 ), CLR_HRED, CLR_HRED )
      else
         nClrBack    := If( lAnd( oItem:itemState, 1 ), CLR_HGRAY, CLR_WHITE )
         nClrText    := If( lAnd( oItem:itemState, 1 ), CLR_BLACK, CLR_BLACK )
      endif

      FW_SayText( hDC, oItem:itemData, oItem:aRect,"L", IfNil( oFont, ::oFont ), ;
         nClrText, nARGB( 255, nClrBack ) )

      RELEASE FONT oFont
   endif

return 1


Image



thanks rao run ok
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: 6827
Joined: Thu Oct 18, 2012 7:17 pm

Re: combobox color

Postby Cgallegoa » Tue Apr 30, 2024 1:39 am

Hi,

The "oItem:itemData" attribute of COMBOBOX returns incorrect data with FWH 23.10. Works perfect with FWH-20.07. When reviewing the class I see many changes between the two versions. How and where do I correct it ?

FWH-23.10 - INCORRECT
Image

FWH-20.07 - OK
Image

Thanks and regards,
Saludos,

Carlos Gallego

*** FWH-23.10, xHarbour 1.2.3 Build 20190603, Borland C++7.30, PellesC ***
Cgallegoa
 
Posts: 423
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: combobox color

Postby karinha » Wed May 01, 2024 1:39 pm

Carlos, you need to update yourself.

Carlos, necesitas actualizarte.

Code: Select all  Expand view

 xHarbour 1.3.1 Intl. (SimpLex) (Build 20240404), , Borland C++7.70
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7307
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Re: combobox color

Postby Silvio.Falconi » Wed May 01, 2024 8:10 pm

Otto wrote:Dear Jimmy,
nevertheless, I think that the future for the frontend will be HTML (WEBVIEW2)

Best regards,
Otto



Image


Code: Select all  Expand view



    #include "FiveWin.ch"

    function Main()

       local oWebView := TWebView():New()

       oWebView:SetHtml( Html() )
       oWebView:SetTitle( "WebView2 - combobox sample" )

       oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
       oWebView:Bind( "SendToFWH" )
       oWebView:bOnBind = { | cJson, cCalls | Login( cJson, cCalls, oWebView ) }
       sleep( 300 )
       oWebView:Run()
       oWebView:Destroy()

    return nil

    function Login( cJson, cCalls, oWebView )

       local hData

       hb_jsonDecode( cJson, @hData )

       if hData[ 1 ][ "username" ] != "Antonio" .or. hData[ 1 ][ "password" ] != "1234"
          oWebView:Return( cCalls, 0, "{ 'result': 'incorrect values' }" )
       else
          oWebView:Return( cCalls, 0, "{ 'result': 'correct!' }" )
      endif

    return nil  

    function Html()

       local cHtml

       TEXT INTO cHtml
     
     <!DOCTYPE html>
        <!DOCTYPE html>
        <!DOCTYPE html>
            <html lang="en">
            <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>Mehrwertsteuer-Auswahl</title>
            <style>
              .special-color {
                color: red;
              }
              .taxable-10-percent {
                background-color: orange;
                color: white;
                font-weight: bold;
                font-size: larger;
              }
            </style>
            </head>
            <body>
           
            <form action="/submit-form-url" method="post">
              <label for="vatRate">Aliquota Iva:</label>
              <select name="vatRate" id="vatRate">
                <option value="none" class="special-color">nessuna</option>
                <option value="exempt_art_10">Esente art. 10</option>
                <option value="exempt_art_15">Esente art. 15</option>
                <option value="outside_scope_vat">Fuori campo IVA</option>
                <option value="taxable_4_percent">Imponibile 4%</option>
                <option value="taxable_10_percent" class="taxable-10-percent">Imponibile 10%</option>
                <option value="taxable_22_percent">Imponibile 22%</option>
                <option value="not_taxable_art_7">Non imponibile art. 7</option>
                <option value="not_taxable_art_8">Non imponibile art. 8</option>
                <option value="excluded_art_15">Esclusa art. 15</option>
                <option value="add" class="special-color">aggiungi</option>
              </select>
           
              <input type="submit" value="Hinzufügen">
            </form>
           
            </body>
            </html>
   

       ENDTEXT

    return cHtml
   

 


I prefer that what I use in my images or examples are not used for your entertainment
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: 6827
Joined: Thu Oct 18, 2012 7:17 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 17 guests