Problems with TListBox?

Problems with TListBox?

Postby reinaldocrespo » Fri Aug 03, 2012 11:26 pm

Hi.

Perhaps I just don't understand how to use tlistbox class. Here is a reduced self contained sample to reproduce a problem I had previously reported. After building the app, try clicking on any of the items on the tlistbox on the right. When you do, the tlistbox control stops working.

Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION Main()
   LOCAL bAdd, bRemove, nNew := 1, nAct := 1
   LOCAL oDlg, oFld, oLbxNewGroup, oLbxAllGroup
   LOCAL aNewGrps := {}
   LOCAL aAllGrps := { "Group 1", "Group 2", "Group 3", "Group 4", "Group 5" }

   DEFINE DIALOG oDlg RESOURCE "Queries_Dlg" TITLE "System Queries" ;
      TRANSPARENT COLOR CLR_BLACK, RGB(240,240,240)

   REDEFINE FOLDER oFld ID 2 OF oDlg DIALOGS "Query_UserGroups" PROMPT "User Groups"

   REDEFINE BUTTONBMP ID 202 OF oDlg BITMAP "exit16" TEXTRIGHT ACTION oDlg:END()


   bRemove := {|| LEN( aNewGrps ) > 0 .AND. ;
                 ( AADD( aAllGrps, aNewGrps[ oLbxNewGroup:GetPos() ] ),;
                 ADEL( aNewGrps, oLbxNewGroup:GetPos(), .T. ),;
                 oLbxAllGroup:setItems( aAllGrps ),;
                 oLbxNewGroup:setItems( aNewGrps ),;
                 oFld:aDialogs[ 1 ]:update(), .T. ) }

   bAdd   := {|| LEN( aAllGrps ) > 0 .AND. ;
                 ( AADD( aNewGrps, aAllGrps[ oLbxAllGroup:GetPos() ] ),;
                 ADEL( aAllGrps, oLbxAllGroup:GetPos(), .T. ),;
                 oLbxAllGroup:setItems( aAllGrps ),;
                 oLbxNewGroup:setItems( aNewGrps ),;
                 oFld:aDialogs[ 1 ]:update(), .T. ) }
   
   REDEFINE LISTBOX oLbxNewGroup VAR nNew ID 1 OF oFld:aDialogs[ 1 ] ITEMS aNewGrps  ;
          UPDATE ON DBLCLICK EVAL( bRemove )

   REDEFINE LISTBOX oLbxAllGroup VAR nAct ID 2 OF oFld:aDialogs[ 1 ] ITEMS aAllGrps ;
          UPDATE ON DBLCLICK EVAL( bAdd )

   oLbxAllGroup:bKeyDown := {|nkey| IF( nKey = 13 .OR. nKey = 32, EVAL( bRemove ), )  }
   oLbxNewGroup:bKeyDown := {|nkey| IF( nKey = 13 .OR. nKey = 32, EVAL( bAdd ), )  }

   REDEFINE BUTTONBMP ID 302 OF oFld:aDialogs[ 1 ] ACTION EVAL( bRemove ) ;
              TOOLTIP "Remove Access from Group"

   REDEFINE BUTTONBMP ID 301 OF oFld:aDialogs[ 1 ] ACTION EVAL( bAdd ) ;
              TOOLTIP "Add Access to Group"

   ACTIVATE DIALOG oDlg ON INIT oDlg:Center( WndMain() )

RETURN NIL


Resource file:
Code: Select all  Expand view
QUERIES_DLG DIALOG 0, -20, 361, 158
STYLE DS_3DLOOK |DS_SETFONT |DS_MODALFRAME |WS_POPUP |WS_VISIBLE |WS_SYSMENU |WS_CAPTION
CAPTION "Referring Physicians"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "    E&xit",202,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,297,137,50,14
  CONTROL "",2,"SysTabControl32",WS_CHILD |WS_VISIBLE ,4,6,354,124
END

QUERY_USERGROUPS DIALOG 20, 69, 350, 100
STYLE DS_SETFONT |WS_CHILD |WS_VISIBLE |WS_BORDER
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "",301,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,164,46,15,14
  CONTROL "",302,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,164,62,15,14
  CONTROL "Available Groups",5,"STATIC",SS_CENTER |WS_CHILD |WS_GROUP |WS_VISIBLE ,187,8,144,8
  CONTROL "Allow Access To Users Who",6,"STATIC",SS_CENTER |WS_CHILD |WS_GROUP |WS_VISIBLE ,12,8,144,8
  CONTROL "Belong To These Groups",7,"STATIC",SS_CENTER |WS_CHILD |WS_GROUP |WS_VISIBLE ,12,16,144,8
  CONTROL "",2,"LISTBOX",LBS_SORT |LBS_NOTIFY |WS_CHILD |WS_BORDER |WS_VSCROLL |WS_VISIBLE ,185,26,148,69
  CONTROL "",1,"LISTBOX",LBS_SORT |LBS_NOTIFY |WS_CHILD |WS_BORDER |WS_VSCROLL |WS_VISIBLE ,9,26,148,69
END
 


Can someone help? I'm using fwh 11.12, xharbour.org 1.2.1_6741, bcc 5.82

Thank you,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Problems with TListBox?

Postby Enrico Maria Giordano » Sat Aug 04, 2012 6:58 am

1 and 2 are reserved ids numbers. Please use greater ids.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Problems with TListBox?

Postby reinaldocrespo » Sat Aug 04, 2012 2:39 pm

Enrico;

You are correct. That does solve the problem. Thank you very much.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 111 guests