FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour combobox color
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: combobox color
Posted: Mon Apr 29, 2024 06: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 (fw): Select all Collapse
#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
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: combobox color
Posted: Mon Apr 29, 2024 07:16 AM

hi,

thx for The Solution, it is much simple than my Solution

greeting,

Jimmy
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: combobox color
Posted: 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

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: combobox color
Posted: Mon Apr 29, 2024 04:32 PM
nageswaragunupudi 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 (fw): Select all Collapse
#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

thanks rao run ok
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: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: combobox color
Posted: Tue Apr 30, 2024 01: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


FWH-20.07 - OK


Thanks and regards,

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: combobox color
Posted: Wed May 01, 2024 01:39 PM
Carlos, you need to update yourself.

Carlos, necesitas actualizarte.
Code (fw): Select all Collapse
 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: combobox color
Posted: Wed May 01, 2024 08:10 PM
Otto wrote:Dear Jimmy,
nevertheless, I think that the future for the frontend will be HTML (WEBVIEW2)

Best regards,
Otto





Code (fw): Select all Collapse
    #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 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

Continue the discussion