Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Colored Bars in a Combo
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01016257
Message ID:
01016380
Views:
11
Problem solved. Consider this program:
************************************************************************************
* PROGRAM: ColorPop
* PURPOSE: Demonstrate using a DEFINE POP command to create a colored combobox
* AUTHOR:  Kevin Marois
* DATE:    05/20/05
*
************************************************************************************


CLEAR

IF PEMSTATUS(_Screen, "cboTest", 5)
  _Screen.RemoveObject("cboTest")
ENDIF

WITH _Screen

  .AddObject("cboTest", "ColorPop")

  WITH .cboTest
	
    .AddItemEx("Arial", "RGB(255,0,0)", "Arial", "B")
    .AddItemEx("Batang", "RGB(128,0,255)", "Batang", "I")
    .AddItemEx("Tahoma", "RGB(0,0,255)", "Tahoma", "U")
    .AddItemEx("Courier New", "RGB(0,128,0)", "Courier New", "-")
    .AddItemEx("System", "RGB(0,120,0)")
    .AddItemEx("System")
			
    .Left = 50
    .Top = 50
    .Visible = .T.

  ENDWITH
	
ENDWITH


DEFINE CLASS ColorPop AS ComboBox
	
  DIMENSION aColorInfo[1]

  PROCEDURE Init()
	
    WITH This
	
      DEFINE POPUP PopColors
		
      .RowSourceType = 9
      .RowSource = "PopColors"
			
    ENDWITH
	
  ENDPROC
	
  PROCEDURE AddItemEx(cItem AS String, cColor AS String, ;
                        sFontName AS String, sStyle AS String)

    LOCAL nNextBar AS Integer
	
    WITH This
			
      IF EMPTY(sFontName)
        sFontName = ""
      ELSE
        sFontName = "FONT '" + sFontName + "'"
      ENDIF
	
      IF EMPTY(sStyle)
        sStyle = ""
      ELSE
        sStyle = "STYLE '" + sStyle + "'"
      ENDIF


      IF EMPTY(cColor)
        cColor = "RGB(0,0,0)"
      ELSE
	cColor = cColor
      ENDIF
			
      DIMENSION .aBarInfo[nNextBar, 3]
      .aBarInfo[nNextBar, 1] = cColor
      .aBarInfo[nNextBar, 2] = sFontName
      .aBarInfo[nNextBar, 3] = sStyle

      cColor = "," + cColor

      DEFINE BAR nNextBar OF "PopColors" PROMPT cItem COLOR &cColor &sFontName &sStyle 

     .AddItem(cItem)
		
    ENDWITH
	
  ENDPROC


  PROCEDURE InteractiveChange()
		
    WITH This
		
     .ForeColor      = EVALUATE(.aBarInfo[.ListIndex, 1])
     .FontName       = .aBarInfo[.ListIndex, 2]
     .FontBold 	     = "B" $ .aBarInfo[.ListIndex, 3]
     .FontItalic     = "I" $ .aBarInfo[.ListIndex, 3]
     .FontUnderline  = "U" $ .aBarInfo[.ListIndex, 3]
     .FontStrikeThru = "-" $ .aBarInfo[.ListIndex, 3] 
			
		
    ENDWITH
	
  ENDPROC

ENDDEFINE
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform