Alignment of 1st column of Grid

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Alignment of 1st column of Grid

Post 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 3317 times
Thanks in advance.

With best regards.

Sudip
With best regards,
Sudip
User avatar
gfilatov
Posts: 1099
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Alignment of 1st column of Grid

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Alignment of 1st column of Grid

Post 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. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Alignment of 1st column of Grid

Post by sudip »

Thanks a lot Grigory. It works! :D

With best regards.

Sudip
With best regards,
Sudip
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Alignment of 1st column of Grid

Post 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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
gfilatov
Posts: 1099
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Alignment of 1st column of Grid

Post 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
   }
}
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Alignment of 1st column of Grid

Post by Roberto Lopez »

gfilatov wrote: Hi Roberto,

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

I'll do it ASAP.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply