FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour bOr / nOr : how to "add" Constante under FiveWin
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
bOr / nOr : how to "add" Constante under FiveWin
Posted: Mon Oct 17, 2022 05:53 AM
hi,

to set different Constante under Xbase++ i use

Code (fw): Select all Collapse
  ::oLVCol:mask := nOr( LVCF_FMT,  LVCF_WIDTH , LVCF_TEXT , LVCF_SUBITEM )


i know i can "add" Constante this Way

Code (fw): Select all Collapse
  ::oLVCol:mask := LVCF_FMT + LVCF_WIDTH + LVCF_TEXT + LVCF_SUBITEM


but i like to know how under FiveWin :-)

p.s. can use use hbxpp Constribution under FivWin ?
greeting,

Jimmy
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: bOr / nOr : how to "add" Constante under FiveWin
Posted: Mon Oct 17, 2022 06:44 AM

Dear Jimmy,

FWH also provides a function nOr() you can use the same way. Also you can use Harbour's own function hb_bitOr()

> ::oLVCol:mask := LVCF_FMT + LVCF_WIDTH + LVCF_TEXT + LVCF_SUBITEM

You can't use it that way as OR is a different process from adding those values

> p.s. can use use hbxpp Constribution under FiveWin ?

I don't think so, but anyhow please try to link it and lets see what unresolved externals you get

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: bOr / nOr : how to "add" Constante under FiveWin
Posted: Mon Oct 17, 2022 11:00 AM

For flags we better use OR not +

OR vs +

1 OR 2 = 3
1 + 2 = 3 // OK

1 OR 1 = 1
1 + 1 = 2 // NOT OK

3 OR 6 = 7 ( binary 011 OR 110 = 111 )
3 + 6 = 9 // NOT OK

Ways to use "OR"

( a | b | c ...) // clang
nOr( a, b, ... ) // FWH function
NUMOR( a, b, .. ) // CT function
HB_BITOR( a, b ) // xHarbour 2 params only
HB_BITOR( a, b, c, ... ) // Harbour

Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: bOr / nOr : how to "add" Constante under FiveWin
Posted: Tue Oct 18, 2022 01:27 AM
hi,

i wonder ...
Code (fw): Select all Collapse
#define LVCF_FMT              0x01
#define LVCF_SUBITEM          0x08
#define LVCF_TEXT             0x04
#define LVCF_WIDTH            0x02

PROCEDURE TEST
LOCAL nTest1,nTest2

   nTest1 := nor(LVCF_FMT,LVCF_WIDTH,LVCF_TEXT,LVCF_SUBITEM)
   nTest2 := LVCF_FMT + LVCF_WIDTH + LVCF_TEXT + LVCF_SUBITEM

   msgInfo(STR(nTest1)+" vs. "+STR(nTest2),IF(nTest1==nTest2,"True","False"))
greeting,

Jimmy
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: bOr / nOr : how to "add" Constante under FiveWin
Posted: Tue Oct 18, 2022 08:07 AM
hi,

i want to "remove" Style
Code (fw): Select all Collapse
   nStyle := nAndNot(::nStyle,LVS_ICON     )

and add new Style
Code (fw): Select all Collapse
   nStyle := nOr(nStyle,nView)
   SetWindowLong(::hLv , GWL_STYLE , nStyle )

but i can´t find nAndNot() in c:\fwh\source\function\or.c
how to "remove" Style under FiveWin :-)
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: bOr / nOr : how to "add" Constante under FiveWin
Posted: Tue Oct 18, 2022 08:21 AM
Code (fw): Select all Collapse
nStyle := nAnd( ::nStyle, nNot( LVS_ICON ) )


Code (fw): Select all Collapse
nStyle := GetWindowLong( ::hWnd, GWL_STYLE )
SetWindowLong( ::hWnd, GWL_STYLE, nAnd( nStyle, nNot( nRemveStyle ) ) )


Another way:
Code (fw): Select all Collapse
nExistingStyle := GetWindowLong( ::hWnd, GWL_STYLE )
if lAnd( nExistingStyle, nRemoveStyle )
   nNewStyle := nXor( nExistingStyle, nRemoveStyle )
   SetWindowLong( hWnd, GWL_STYLE, nNewStyle )
endif


Please see
METHOD GetSetGWLStyle( lExtended, nStyle, lOnOff ) CLASS TWindow
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: bOr / nOr : how to "add" Constante under FiveWin
Posted: Tue Oct 18, 2022 08:47 AM
If you make a class as derived from TWindow class (or better TControl class)

We can use Parent method:

Code (fw): Select all Collapse
oOurWnd:WinStyle( nNewStyle, lOnOff )
// .t. to add new style
// .f. to remove style, if already exists

This does everything that is needed.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: bOr / nOr : how to "add" Constante under FiveWin
Posted: Tue Oct 18, 2022 09:05 AM
Am I write in my understanding the you are developing a new class TGRID using ListView. For it to work with FWH Windows and dialogs, we have to derive the class from TControl.
Code (fw): Select all Collapse
CLASS TGrid FROM TControl

TControl is derived from TWinndow.
So the new TGrid class already has all methods of TControl and TWindow.
You need not spend your time in writing code from scratch like using GetWindowLong(...) and SetWindowLong(..). All such things are already available in a very simple and userfriendly way.

A user of TGrid class can
Code (fw): Select all Collapse
oGrid  := TGrid():New( oWnd, <other params,...> )
oGrid:WinStyle( nStyle, .t. to add or .f. to remove)
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: bOr / nOr : how to &quot;add&quot; Constante under FiveWin
Posted: Tue Oct 18, 2022 10:15 AM
hi,

i´m still a Newbie under FiveWin and did not know that TControl have Method to change Style.

will it work with Listview as i have not found any Listview_Macro :-)
i now use this HB_FUNC() for TGrid()
Code (fw): Select all Collapse
HB_FUNC( LV_CHANGEEXTENDEDSTYLE )
{
   #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
   #endif
   DWORD Add     = (DWORD) hb_parnl  (2);
   DWORD Remove  = (DWORD) hb_parnl  (3);
   DWORD OldStyle, NewStyle, Style;

   OldStyle = ListView_GetExtendedListViewStyle (hWnd);
   NewStyle = (OldStyle | Add) & ( ~Remove );
   Style = ListView_SetExtendedListViewStyle ( hWnd, NewStyle );
   hb_retnl ((LONG) Style);
}
greeting,

Jimmy

Continue the discussion