Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
 Tags
Subject: Simplify column style creation in cnt
Thread ID: 416471 Message ID: 416471 # Views: 54 # Ratings: 0
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Tuesday, December 30, 2014 2:47:29 AM         
   


Foxites:

I am creating a container at run-time that has multiple columns in it.

Each column is a commandbutton — and each commandbutton column
is styled differently.  

So my current idea is to create a data object for each column to store
the property settings (30 or 40 each).

But as you can see from the sample object creation method below, the
creation of column properties gets too complicated with lots of
repetition in the code.

So what should be my strategy?  Is it best to store all the properties
in a table or array?  How can I simplify things so that I don't have to
repeat (and hard code) the properties several times?

Thanks, Dan B.

*
* Create multiple columns in a container - each column needs to 
*                                          be styled differently 
*
*          the container    the objects holding each column's properties 
LPARAMETERS oContainer,     o1, o2, o3, o4, o5, o6... oN

WITH oContainer

SELECT * FROM country INTO Junk

nTop = 0
j = 1

SCAN 

  k= TRANSFORM(j)

  FOR p = 1 TO N
    q = TRANSFORM(m.p)
    = EVAL( [.Newobject('_]+m.q+[cmd_]+m.k+[','CommandButton')] )
    oControl = EVALUATE( '._'+m.q+'cmd_'+m.k )
    
    WITH oControl
    DO case
    CASE p = 1  && Column 1

      .Left    = o1.cmdMarginLeft      &&  <-- hard coded properties
      .Top     = o1.cmdMarginTop + m.nTop
      .Width   = o1.cmdWidth    
      .Caption = Junk.country
    
    CASE p = 2  && Column 2

      .Left    = o2.cmdMarginLeft      &&  <-- hard coded properties
      .Top     = o2.cmdMarginTop + m.nTop
      .Width   = o2.cmdWidth 
      .Caption = Junk.region     

    CASE p = N  && Column N
      ...
    
    ENDWITH && oControl
    
  ENDFOR   
  
  nTop = m.nTop + 20

ENDSCAN     


ENTIRE THREAD

Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 2:47:29 AM
RE: Simplify column style creation in cnt Posted by Jun Tangunan @ 12/30/2014 4:58:43 AM
RE: Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 12:46:00 PM
RE: Simplify column style creation in cnt Posted by Mike Yearwood @ 12/30/2014 6:51:21 PM
RE: Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 7:15:44 PM
RE: Simplify column style creation in cnt Posted by Mike Yearwood @ 12/30/2014 9:21:00 PM
RE: Simplify column style creation in cnt Posted by Jun Tangunan @ 12/30/2014 9:51:17 PM
RE: Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 10:59:55 PM