Page 1 of 1

Alignment of 1st column of Grid

Posted: Wed Jan 27, 2010 2:01 pm
by sudip
Hi All,

Is there any way to align (JUSTIFY) the 1st column of a grid to right-aligned?
PTax.jpg
PTax.jpg (27.05 KiB) Viewed 3316 times
Thanks in advance.

With best regards.

Sudip

Re: Alignment of 1st column of Grid

Posted: Wed Jan 27, 2010 2:41 pm
by gfilatov
sudip wrote:Hi All,

Is there any way to align (JUSTIFY) the 1st column of a grid to right-aligned?
Hello Sudip,

In the official HMG:
You can define the 1st column of a grid with a zero length and place the 'Salary' item in the second column.

In the HMG Extended:
We have a hack in the C-function INITLISTVIEWCOLUMNS (borrowed from ooHG) for aligning the 1st column of a grid :idea:

Re: Alignment of 1st column of Grid

Posted: Wed Jan 27, 2010 3:10 pm
by Rathinagiri
You can define the 1st column of a grid with a zero length and place the 'Salary' item in the second column.
Nice n simple solution. :)

Re: Alignment of 1st column of Grid

Posted: Wed Jan 27, 2010 7:13 pm
by sudip
Thanks a lot Grigory. It works! :D

With best regards.

Sudip

Re: Alignment of 1st column of Grid

Posted: Wed Jan 27, 2010 10:06 pm
by Roberto Lopez
gfilatov wrote: In the HMG Extended:
We have a hack in the C-function INITLISTVIEWCOLUMNS (borrowed from ooHG) for aligning the 1st column of a grid :idea:
There is known limitation of ListView Windows control about that.

Could be you so kind to post that hack here to review it?

TIA.

Re: Alignment of 1st column of Grid

Posted: Thu Jan 28, 2010 8:41 am
by gfilatov
Roberto Lopez wrote:
gfilatov wrote: In the HMG Extended:
We have a hack in the C-function INITLISTVIEWCOLUMNS (borrowed from ooHG) for aligning the 1st column of a grid :idea:
There is known limitation of ListView Windows control about that.

Could be you so kind to post that hack here to review it?
Hi Roberto,

Sure. Please take a look for code below: :arrow:

Code: Select all

/* code of the function INITLISTVIEWCOLUMNS is borrowed from ooHG */
HB_FUNC( INITLISTVIEWCOLUMNS )
{
   PHB_ITEM    wArray;
   PHB_ITEM    hArray;
   PHB_ITEM    jArray;

   HWND        hc;
   LV_COLUMN   COL;
   int         iLen;
   int         s;
   int         iColumn = 0;

   hc = ( HWND ) hb_parnl( 1 );

   iLen = hb_parinfa( 2, 0 ) - 1;
   hArray = hb_param( 2, HB_IT_ARRAY );
   wArray = hb_param( 3, HB_IT_ARRAY );
   jArray = hb_param( 4, HB_IT_ARRAY );

   COL.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;

   for( s = 0; s <= iLen; s++ )
   {
      COL.fmt = hb_arrayGetNI( jArray, s + 1 );
      COL.cx = hb_arrayGetNI( wArray, s + 1 );
      COL.pszText = (char *) hb_arrayGetCPtr( hArray, s + 1 );
      COL.iSubItem = iColumn;
      ListView_InsertColumn( hc, iColumn, &COL );
      if( iColumn == 0 && COL.fmt != LVCFMT_LEFT )
      {
         iColumn++;
         COL.iSubItem = iColumn;
         ListView_InsertColumn( hc, iColumn, &COL );
      }

      iColumn++;
   }

   if( iColumn != s )
   {
      ListView_DeleteColumn( hc, 0 );       // <-- this hack
   }
}

Re: Alignment of 1st column of Grid

Posted: Thu Jan 28, 2010 12:35 pm
by Roberto Lopez
gfilatov wrote: Hi Roberto,

Sure. Please take a look for code below: :arrow:
<...>
Many thanks.

I'll do it ASAP.