Dear Sambomb,
I am herewith pasting a sample code which you can test it yourself.
You can copy paste and run exe at your end.
You should Try Enter Key, Mouse Left Click and Mouse Left Button Double Click on the 2nd Column ie Status
Please note the problem when using Mouse Double Click
TestXbrw.Prg
- Code: Select all Expand view
#Include "FiveWin.ch"
#Include "xBrowse.ch"
*------------------------------------*
Function Main()
*------------------------------------*
Local oDlg,oBrwMenu,oBtnCancel
Local aMenu:={}, aClrCol:={}
aAdd(aMenu,{ 1,"Masters ",.F.,.T. })
aAdd(aMenu,{ 2," Account Groups ",.F.,.F. })
aAdd(aMenu,{ 3," Account Heads ",.F.,.F. })
aAdd(aMenu,{ 4," Exit ",.F.,.F. })
aAdd(aMenu,{ 5,"Transactions ",.F.,.T. })
aAdd(aMenu,{ 6," Voucher Entry ",.F.,.F. })
aAdd(aMenu,{ 7," Sales Postings ",.F.,.T. })
aAdd(aMenu,{ 8," From GDMS ",.F.,.T. })
aAdd(aMenu,{ 9," Test sub menu 1",.F.,.F. })
aAdd(aMenu,{10," From PDMS ",.F.,.F. })
aAdd(aMenu,{11," Test Menu ",.F.,.F. })
aAdd(aMenu,{12,"Reports ",.F.,.T. })
aAdd(aMenu,{13," Trial Balance ",.F.,.F. })
aAdd(aMenu,{14," Profit & Loss Statement ",.F.,.F. })
aAdd(aMenu,{15," Balance Sheet ",.F.,.F. })
aAdd(aMenu,{16," Statement of Account ",.F.,.F. })
aAdd(aMenu,{17," Debtor ",.F.,.F. })
aAdd(aMenu,{18,"Tools ",.F.,.T. })
aAdd(aMenu,{19," Select Financial Year ",.F.,.F. })
aAdd(aMenu,{20," Calculator ",.F.,.F. })
aAdd(aMenu,{21,"Users ",.F.,.T. })
aAdd(aMenu,{22," Create User ",.F.,.F. })
aAdd(aMenu,{23," Set user Permissions ",.F.,.F. })
aClrCol:={ { 0, nRGB(192,221,255) }, { 0, nRGB(221,245,255) } } // Xbrowse Alternative Column colours
DEFINE DIALOG oDlg FROM 70,20 to 630,690 TITLE "Test" PIXEL
@ 0,100 XBROWSE oBrwMenu ;
COLUMNS 2, 3 ;
HEADERS "Menu", "Status" ;
OF oDlg ;
ARRAY aMenu // should not use AUTOCOLS now
oBrwMenu:lHScroll:=.F. // Horizontal Scroll Bar not required
oBrwMenu:lFooter:=.T.
// Sub Menu in different colour and Menu's in different Coclour
oBrwMenu:bClrStd := { || iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4],aClrCol[1],aClrCol[2]) }
oBrwMenu:lUpdate := .t.
oBrwMenu:nColSel := 2
oBrwMenu:bGotFocus:={ || oBrwMenu:nColSel:= 2 }
oBrwMenu:aCols[1]:nWidth:=350
// Easiest way to dispplay a BMP based on the Logical Value
*oBrwMenu:aCols[2]:SetCheck( { "CheckOn", "CheckOff" } )
// Alternative way to display BMP, if multiple conditions and more than 2 bitmaps are there
oBrwMenu:aCols[2]:AddResource("CheckOn")
oBrwMenu:aCols[2]:AddResource("CheckOff")
// Checkbox should be displayed only if the menu type is not a Submenu
oBrwMenu:aCols[2]:bBmpData :={ || iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4],0,iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][3],1,2)) }
oBrwMenu:aCols[2]:nWidth:=50
oBrwMenu:aCols[2]:bStrData:={ || NIL }
oBrwMenu:aCols[2]:nDataStrAlign := AL_CENTER
// No edit for SubMenu
oBrwMenu:aCols[2]:bEditWhen := { || iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4],.F.,.T.) }
// Edit Type is set to GET, other options are List,Button Etc.
oBrwMenu:aCols[2]:nEditType := EDIT_GET
oBrwMenu:aCols[2]:bEditvalue := { || space(0) }
*oBrwMenu:aCols[2]:bEditvalue := { || if(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][3],"Disable ?","Enable ?") }
oBrwMenu:aCols[2]:bOnPostEdit:= { | oCol, xValue, nLastKey | MenuAccessOnEdit( oCol, xValue, nLastKey) }
// Enable user to click on the checkbox on column 2 only
oBrwMenu:bLClicked := { | nRow, nCol | iif(oBrwMenu:nColSel == 2,MenuAccessOnEdit(oBrwMenu:aCols[2],,),NIL) }
// Mouse Double Click event for the Whole column in this xBrowse
oBrwMenu:bLDblClick:={|nRow, nCol| if(nCol == 2, .F., ),MsgInfo("Test"),oBrwMenu:Refresh(),.T.}
// Mouse Double Click event for Column 2 of this xBrowse
*oBrwMenu:aCols[2]:bLDClickData := { |nRow,nCol| if(oBrwMenu:nColSel == 2, PostMessage( oBrwMenu:hWnd, WM_KEYDOWN, 27 ),) }
*oBrwMenu:aCols[2]:bLDClickData := {|nRow, nCol| if(nCol == 2, .F., ),MsgInfo("Test"),oBrwMenu:Refresh()}
// 2nd Column should be the selected column to do the PostMessage with an ESC key, or else ESC key closes the dialog itself
// Also make sure that Postmessage should work only on 2 conditions ie
// It should be a menu item and not Sumbenu Item
*oBrwMenu:bKeyDown= {|nKey| if(oBrwMenu:nColSel == 2,if ( nKey == VK_RETURN, PostMessage( oBrwMenu:hWnd, WM_KEYDOWN, 27 ), ),) }
oBrwMenu:bKeyDown= {|nKey| if(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4], , ; // Is submenu the do nothing, bwhen will take care
( oBrwMenu:nColSel:=2 ,; // else ie Menu items
if ( nKey == VK_RETURN, PostMessage( oBrwMenu:hWnd, WM_KEYDOWN, 27 ), ) ;
) ) }
oBrwMenu:CreateFromCode()
@14.3,05 BUTTONBMP oBtnCancel PROMPT "Cancel" OF oDlg TEXTRIGHT BITMAP "Cancel24x24" ;
SIZE 50,15 ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oBrwMenu:nLeft:=220,oBrwMenu:nHeight:=oDlg:nHeight-35,oBrwMenu:nWidth:=450,;
oBrwMenu:SetFocus() )
Return
*---------------------------------------------*
Function MenuAccessOnEdit( oCol, xValue, nLastKey )
*---------------------------------------------*
Local oBrw := oCol:oBrw
if oBrw:aArrayData[oBrw:nArrayAt][3] // .T.
oBrw:aArrayData[oBrw:nArrayAt][3]:=.F.
else
oBrw:aArrayData[oBrw:nArrayAt][3]:=.T.
Endif
oBrw:Refresh()
Return NIL
TestXbr.Rc- Code: Select all Expand view
CheckOn BITMAP C:\FWH\Bitmaps\CheckOn.Bmp
CheckOff BITMAP C:\FWH\Bitmaps\CheckOff.Bmp
You may substitute the your FWH installation path in the .RC
Meanwhile I shall test the code which u have given in the your last post.
Regards
Anser