GRID_SORT sample

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
chrisjx2002
Posts: 190
Joined: Wed Jan 06, 2010 5:39 pm

GRID_SORT sample

Post by chrisjx2002 »

Hello,

When I compile the sample GRID_SORT with HMG 3.3.1, I get this error message :

Harbour 3.2.0dev (r1407111333)
Copyright (c) 1999-2014, http://harbour-project.org/" onclick="window.open(this.href);return false;
demo.prg: In function 'HB_FUN_LISTVIEW_GETCOLUMNORDERARRAY':
demo.prg:145:7: error: too many arguments to function 'hb_storni'
C:/hmg.3.3.1/harbour/include/hbapi.h:759:25: note: declared here
demo.prg: In function 'HB_FUN_LISTVIEW_SETCOLUMNORDERARRAY':
demo.prg:157:7: error: too many arguments to function 'hb_parni'
C:/hmg.3.3.1/harbour/include/hbapi.h:643:31: note: declared here
hbmk2[demo]: Error: Running C/C++ compiler. 1
gcc.exe -c -O3 -march=i586 -mtune=pentiumpro -fomit-frame-pointer -W -Wall -pipe -IC:/hmg.3.3.1/harbour/include -I../../../../../hmg.3.3.1/SAMPLES/Advanced/GRID_SORT -IC:/hmg.3.3.1/include C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/hbmk_e7jxe2.dir/demo.c C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/hbmk_e91lhn.c

There seems to be a problem in the C code.

As I am not very good in C, anyone has an idea on how to solve that?

Thanks in advance
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

GRID_SORT sample

Post by Pablo César »

Hi Cris,

Please note correct source code example as I was indicated for corrections here.

Code: Select all

/*
* HMG Grid Demo
* (c) 2005 Roberto Lopez
*
* ListView SORT ORDER COLUMN
* Author: BADIK <badik@mail.ru>
*/

#include "hmg.ch"

Memvar fColor

Function Main()
Local aRows [20] [3]

Private fColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , { 0,0,255 } , { 0,255,0 } ) }   

DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 640 ;
   HEIGHT 400 ;
   TITLE 'Mixed Data Type Grid Test' ;
   MAIN

   DEFINE MAIN MENU
      DEFINE POPUP 'File'
         MENUITEM 'Set New Columns Order'   ACTION SetOrder()
         MENUITEM 'Get Columns Order'      ACTION GetOrder()
         MENUITEM 'Refresh Grid'         ACTION Form_1.Grid_1.Refresh
         SEPARATOR
         MENUITEM 'Exit'            ACTION Form_1.Release
      END POPUP
   END MENU

   aRows [1]   := { 113.12,date(),1,1 , .t. }
   aRows [2]   := { 123.12,date(),2,2 , .f. }
   aRows [3]   := { 133.12,date(),3,3, .t. }
   aRows [4]   := { 143.12,date(),1,4, .f. }
   aRows [5]   := { 153.12,date(),2,5, .t. }
   aRows [6]   := { 163.12,date(),3,6, .f. }
   aRows [7]   := { 173.12,date(),1,7, .t. }
   aRows [8]   := { 183.12,date(),2,8, .f. }
   aRows [9]   := { 193.12,date(),3,9, .t. }
   aRows [10]   := { 113.12,date(),1,10, .f. }
   aRows [11]   := { 123.12,date(),2,11, .t. }
   aRows [12]   := { 133.12,date(),3,12, .f. }
   aRows [13]   := { 143.12,date(),1,13, .t. }
   aRows [14]   := { 153.12,date(),2,14, .f. }
   aRows [15]   := { 163.12,date(),3,15, .t. }
   aRows [16]   := { 173.12,date(),1,16, .f. }
   aRows [17]   := { 183.12,date(),2,17, .t. }
   aRows [18]   := { 193.12,date(),3,18, .f. }
   aRows [19]   := { 113.12,date(),1,19, .t. }
   aRows [20]   := { 123.12,date(),2,20, .f. }

   @ 10,10 GRID Grid_1 ;
      WIDTH 620 ;
      HEIGHT 330 ;
      HEADERS {'Column 1','Column 2','Column 3','Column 4','Column 5'} ;
      WIDTHS {140,140,140,140,140} ;
      ITEMS aRows ;
      EDIT ;
      COLUMNCONTROLS { ;
         {'TEXTBOX' , 'NUMERIC' , '$ 999,999.99'} , ;
         {'DATEPICKER' , 'DROPDOWN'} , ;
         {'COMBOBOX' , {'One' , 'Two' , 'Three'}} , ;
         { 'SPINNER' , 1 , 20 } , ;
         { 'CHECKBOX' , 'Yes' , 'No' } ;
         } ;
      COLUMNWHEN { ;
         { || This.CellValue > 120 } , ;
         { || This.CellValue = Date() } , ;
         Nil , ;
         Nil , ;
         Nil ;
         } ;
      DYNAMICFORECOLOR { fColor , fColor, fColor, fColor, fColor }

END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil

Function SetOrder()
Local aColumns := { 5, 4, 3, 2, 1 }

_SetColumnOrderArray( "Grid_1", "Form_1", aColumns )

Form_1.Grid_1.Refresh
Return Nil

Function GetOrder()
Local a := _GetColumnOrderArray( "Grid_1", "Form_1" )

// msgdebug(a)
aEval( a, {|x,i| MsgInfo ( "Column " + ltrim( str ( x ) ), ltrim( str ( i ) ) )} )
Return Nil

Function _GetColumnOrderArray( ControlName , ParentForm )
Local i, nColumn, aSort

i := GetControlIndex( ControlName , ParentForm )
nColumn := len(_HMG_SYSDATA [ 33 ] [i])
aSort := array(nColumn)
My_ListView_GetColumnOrderArray( _HMG_SYSDATA [ 3 ] [i], nColumn, @aSort )
Return aSort

Function _SetColumnOrderArray( ControlName , ParentForm, aSort )
Local i, nColumn

i := GetControlIndex( ControlName , ParentForm )
nColumn := len(_HMG_SYSDATA [ 33 ] [i])
ListView_SetColumnOrderArray( _HMG_SYSDATA [ 3 ] [i], nColumn, aSort )
Return Nil


#pragma BEGINDUMP

#define _WIN32_IE 0x0500

#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
#include "hbvm.h"

HB_FUNC ( MY_LISTVIEW_GETCOLUMNORDERARRAY )
{
   int nColumn = hb_parni(2);
   LPINT pnOrder = (LPINT) malloc(nColumn*sizeof(int));
   int i;

   ListView_GetColumnOrderArray( (HWND) hb_parnl(1), nColumn, pnOrder );

   for (i=0; i<nColumn; i++)
   {
      hb_storvni(pnOrder[i]+1, 3, i+1);
   }
}

#pragma ENDDUMP
Please Rathi may you arrange for updating this in SAMPLES ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: GRID_SORT sample

Post by srvet_claudio »

Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
chrisjx2002
Posts: 190
Joined: Wed Jan 06, 2010 5:39 pm

Re: GRID_SORT sample

Post by chrisjx2002 »

Thanks a lot for your very fast answer!

I forgot to take a look at the messages of the forum. :(
User avatar
Agil Abdullah
Posts: 204
Joined: Mon Aug 25, 2014 11:57 am
Location: Jakarta, Indonesia
Contact:

Re: GRID_SORT sample

Post by Agil Abdullah »

I am following this topic.

Many thanks for all of you.
Agil Abdullah Albatati (just call me Agil)
Programmer Never Surrender
Post Reply