Bug Redefine ComboBox + oDB:FIELD - URGENT

Bug Redefine ComboBox + oDB:FIELD - URGENT

Postby ericmagaldi » Sun Feb 25, 2007 1:12 am

Sorry my English :)

Antonio Linares,

//Bug Redefine ComboBox + oDB:FIELD with ('F' or 'J') in ITEM {'J - Pessoa Jurídica', 'F - Pessoa Física'} ?!

Code: Select all  Expand view
use CLIENTE
// have one Class proper (TDBTable), but exemplify with TDataBase
DataBase oDBCli

? oDBCli:CLI_TIPPES // equal 'F' or 'J' - not is activate correctly element ComboBox (On Init Dlg).

//-----------------------------------------------------------
//Bug, if first Control receive Focus:

...
Redefine COMBOBOX oCbxTipPes ;
         VAR oDBCli:CLI_TIPPES ;
         ITEMS {'J - Pessoa Jurídica', 'F - Pessoa Física'} ;
         ID 4002  ;
         OF oFld:aDialogs[1]

Activate Dialog oDlg ;
         Center ;
         On Init PosCbx(oCbxTipPes,oDBCli:CLI_TIPPES)

// Use only this mode
//-----------------------------------------------------------
// Correct, if variable common:
...
cTipPes:=oDBCli:CLI_TIPPES

Redefine COMBOBOX oCbxTipPes ;
         VAR cTipPes ;
         ITEMS {'J - Pessoa Jurídica', 'F - Pessoa Física'} ;
         ID 4002  ;
         OF oFld:aDialogs[1]

Activate Dialog oDlg ;
         Center ;
         On Init PosCbx(oCbxTipPes,cTipPes)
//-----------------------------------------------------------
// Correct all mode:
...
@02,10 COMBOBOX oCbxTipPes ;
         VAR oDBCli:CLI_TIPPES ;
         ITEMS {'J - Pessoa Jurídica', 'F - Pessoa Física'} ;
         ID 4002  ;
         OF oFld:aDialogs[1]

Activate Dialog oDlg ;
         Center ;
         On Init PosCbx(oCbxTipPes,cTipPes)
//-----------------------------------------------------------
// Set position in oCbx:aItem
//-----------------------------------------------------------
function PosCbx( oCbx, cValue )
local nPos

if oCbx # nil .and. ! EMPTY(cValue)
   if (nPos:=ASCAN(oCbx:aItems, {|x| UPPER(cValue) == UPPER(PADR(x,LEN(cValue)))} )) > 0
      ? 'PosCbx() Find "' + cValue + '" in element ' + ALLTRIM(STR(nPos))
      oCbx:Select(nPos)
   endif
endif
return nil
//-----------------------------------------------------------
//-----------------------------------------------------------

// RESOURCE SCRIPT generated by "Pelles C for Windows, version 4.50".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_PORTUGUESE,SUBLANG_PORTUGUESE_BRAZILIAN

CDT_CLIENTE DIALOGEX DISCARDABLE 6, 18, 398, 194
STYLE WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "MS Sans Serif", 0, 0, 1
BEGIN
CONTROL "", 4001, "SysTabControl32", 0x00000000, 0, 20, 396, 144
CONTROL "Cancelar", 4003, "Button", WS_TABSTOP, 344, 172, 45, 15
END

CDT_CLIENTE_GERAL DIALOGEX DISCARDABLE 6, 18, 396, 134
STYLE WS_CHILD|DS_3DLOOK|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "MS Sans Serif", 0, 0, 1
BEGIN
CONTROL "", 4001, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 24, 12, 40, 12
CONTROL "", 4002, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP, 200, 12, 144, 40
CONTROL "", 4003, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 24, 48, 140, 12
END

CDT_CLIENTE_ENDERECO DIALOGEX DISCARDABLE 6, 18, 396, 134
STYLE WS_CHILD|DS_3DLOOK|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "MS Sans Serif", 0, 0, 1
BEGIN
END

CDT_CLIENTE_FISCAL DIALOGEX DISCARDABLE 6, 18, 396, 134
STYLE WS_CHILD|DS_3DLOOK|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "MS Sans Serif", 0, 0, 1
BEGIN
CONTROL "", 4001, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP, 112, 28, 168, 44
END
//-----------------------------------------------------------
Last edited by ericmagaldi on Mon Feb 26, 2007 9:42 pm, edited 1 time in total.
virtually,
Éric
xHarbour.org + Borland C + FiveWin (2.8/6.12) + Pelles C + HBMake + ADSCDX
São Paulo - Brasil
http://xBaseSuporte.freeforums.org
User avatar
ericmagaldi
 
Posts: 37
Joined: Tue Feb 20, 2007 9:26 am
Location: São Paulo - Brazil

Postby Rochinha » Sun Feb 25, 2007 5:42 pm

See the sample below
Code: Select all  Expand view
#include "fivewin.ch"

function main()

   local oDlg, cCombo := "3"
   local aItems := { "1 - Um", "2 - Dois", "3 - Tres", "4 - Quatro" }

   cCombo := mascan( aItems, cCombo )

   DEFINE DIALOG oDlg FROM 2, 2 TO 18, 60 TITLE "Test" ;
          STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, 4 )

          @ 2, 2 COMBOBOX cCombo ;
                 ITEMS aItems SIZE 200, 100 ;
                 ON DRAWITEM (cCombo := mascan( aItems, cCombo ), oCombo:Refresh())

   ACTIVATE DIALOG oDlg CENTERED

return nil

function mascan( aItems, cString )
   nLArray  := len( aItems )
   nLString := len( cString )
   for i = 1 to nLArray
       if substr(aItems[i],1,nLString) = cString
          return aItems[i]
       endif
   next
   return ""


Improve it!
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby ericmagaldi » Sun Feb 25, 2007 10:30 pm

Set Translate Off... :)

Oi Rochinha..

O exemplo abaixo funciona somente na forma @...ComBoBox.
No modo Redefine nada é executado no ON DRAWITEM.

Na forma @...ComboBox que postei, também funciona.

O estranho, conforme especifiquei, se for uma variável comum (LOCAL cTipPes:='F'), irá funcionar, mas se usar variável de instância para o CBX, dá problema.

Tô achando que é Bug mesmo.
virtually,
Éric
xHarbour.org + Borland C + FiveWin (2.8/6.12) + Pelles C + HBMake + ADSCDX
São Paulo - Brasil
http://xBaseSuporte.freeforums.org
User avatar
ericmagaldi
 
Posts: 37
Joined: Tue Feb 20, 2007 9:26 am
Location: São Paulo - Brazil

Postby Rochinha » Tue Feb 27, 2007 1:18 pm

Eric

Como eu sempre carrego minhas variaveis antes use desta forma:
Code: Select all  Expand view
// Use only this mode
//-----------------------------------------------------------
// Correct, if variable common:
...
cTipPes := MAscan( {'J - Pessoa Jurídica', 'F - Pessoa Física'}, oDBCli:CLI_TIPPES )

Redefine COMBOBOX oCbxTipPes ;
         VAR cTipPes ;
         ITEMS {'J - Pessoa Jurídica', 'F - Pessoa Física'} ;
         ID 4002  ;
         OF oFld:aDialogs[1]

Activate Dialog oDlg ;
         Center ;
         On Init PosCbx(oCbxTipPes,cTipPes)
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby ericmagaldi » Tue Feb 27, 2007 10:40 pm

Correto, tenho certeza que desta forma funcionará, entre outras formas que citei.

Mas pretendo usar da forma que mencionei (afinal existem os Methods) pois tento trabalhar na forma mais direta e otimizada possível. E se comprovado o Bug, o mesmo deve ser corrigido, correto ?!

Até o momento não tive nenhum contato do FiveWin.br ou Linares, inclusive enviei exemplos para ambos...
virtually,
Éric
xHarbour.org + Borland C + FiveWin (2.8/6.12) + Pelles C + HBMake + ADSCDX
São Paulo - Brasil
http://xBaseSuporte.freeforums.org
User avatar
ericmagaldi
 
Posts: 37
Joined: Tue Feb 20, 2007 9:26 am
Location: São Paulo - Brazil

Postby Antonio Linares » Wed Feb 28, 2007 8:30 am

Éric,

It is not a bug. Please set:

oDBCli:lTenChars := .F. // Avoid Clipper restriction compatibility

as CLI_TIPPES is 10 chars length
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby ericmagaldi » Wed Feb 28, 2007 8:40 am

Antonio Linares wrote:Éric,

It is not a bug. Please set:

oDBCli:lTenChars := .F. // Avoid Clipper restriction compatibility

as CLI_TIPPES is 10 chars length


Não resolveu!!!
e a minha classe não terá "lTenChars"
CLI_TIPPES é de 1 byte, mas se transformará conforme o elemento do vetor!!!

Qualquer umas das formas abaixo, funciona corretamente:

Variável comum (LOCAL cTipPes:='F')
ReDefine ComboBox cTipPes... // Assim funciona

ou
@10,10 ComboBox oDBCli:CLI_TIPPES ... // Assim funciona

ou
Quando não receber o primeiro foco // Assim funciona

Ainda continuo com o problema !!!!!
Você testou o exemplo que te enviei por email ????
Last edited by ericmagaldi on Wed Feb 28, 2007 8:47 am, edited 1 time in total.
virtually,
Éric
xHarbour.org + Borland C + FiveWin (2.8/6.12) + Pelles C + HBMake + ADSCDX
São Paulo - Brasil
http://xBaseSuporte.freeforums.org
User avatar
ericmagaldi
 
Posts: 37
Joined: Tue Feb 20, 2007 9:26 am
Location: São Paulo - Brazil

Postby Antonio Linares » Wed Feb 28, 2007 8:47 am

Éric,

This is defined in class TDataBase:

DATA lTenChars AS LOGICAL INIT .t.

When Clipper assigns an object DATA, it places an underscore before the name:

oDBCli:CLI_TIPPES := .F. => oDBCli:_CLI_TIPPES( .F. )

but _CLI_TIPPES length is 11, so Class TDataBase checks if lTenChars is .F. and it not, then its value is NOT assigned
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Feb 28, 2007 8:55 am

Éric,

Tu ejemplo usa folders, y posiblemente ahí esté la diferencia
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby ericmagaldi » Wed Feb 28, 2007 8:56 am

Antonio,

não concordo com a necessidade de usar lTenChars, não faz sentido pra mim.
E eu não uso TDataBase, pois tenho uma própria ( TDBTable() )

Comentei 3 síntaxes que funciona corretamente, assim:
ReDefine oDBCli:CLI_TIPPES, em somente um caso, não quer funcionar...
ou seja, ao executar PosCBX(...), no On Init, para acertar o elemento, já chega errado dentro da PosCBX(...)

A questão é, quando é variavel de instância, internamente do ComboBox, este mudando o valor inicial do oDBCli:CLI_TIPPES, antes mesmo de ser avaliado no On INIT do DLG....

por favor, observe os exemplos que enviei por email...
Last edited by ericmagaldi on Wed Feb 28, 2007 9:21 am, edited 1 time in total.
virtually,
Éric
xHarbour.org + Borland C + FiveWin (2.8/6.12) + Pelles C + HBMake + ADSCDX
São Paulo - Brasil
http://xBaseSuporte.freeforums.org
User avatar
ericmagaldi
 
Posts: 37
Joined: Tue Feb 20, 2007 9:26 am
Location: São Paulo - Brazil

Postby Antonio Linares » Wed Feb 28, 2007 9:16 am

Éric,

Cierto, en tu ejemplo no usas la Clase TDataBase.

El problema de tu código ocurre porque el combobox al tomar el foco VARIA el valor de oDBCli:FIELD:CLI_TIPPES ANTES de que lo asignes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Feb 28, 2007 9:26 am

Éric,

Hazlo de esta forma:
Code: Select all  Expand view
Redefine COMBOBOX oCbxTipo ;
         VAR oDBCli:FIELD:CLI_TIPPES ;
         ITEMS {'J - Pessoa Jurídica', 'F - Pessoa Física'} ;
         ID 4002  ;
         OF oFld:aDialogs[1] ;
         WHEN ( IniciaCBX( oCbxTipo,oDBCli:FIELD:CLI_TIPPES ), .T. )

...

Redefine COMBOBOX oCbxRegime ;
         VAR oDBCli:FIELD:CLI_REGIME;
         ITEMS {'0 - Não informado', '3 - Simples', '1 - Lucro Presumido', '2 - Lucro Real'} ;
         ID 4001  ;
         OF oFld:aDialogs[3] ;
         WHEN ( IniciaCBX(oCbxRegime,oDBCli:FIELD:CLI_REGIME ), .T. )

Activate Dialog oDlg ;
         Center
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby ericmagaldi » Wed Feb 28, 2007 9:32 am

Sim, funciona..


mas não é uma forma correta, certo ?!

Não usei esta técnica, porque sei que o When sempre é avaliado, a cada mudança de foco.
Como é algo relacionado no inicio, portanto deveria funcionar no "On Init", pois desta forma acredito que esta dentro das especificações da ordem de chamadas dos eventos no FW, e não estou tentando fazer nada fora do comum.

Acredito que é Bug do ComboBox / ReDefine, concorda ????
Last edited by ericmagaldi on Wed Feb 28, 2007 9:50 am, edited 3 times in total.
virtually,
Éric
xHarbour.org + Borland C + FiveWin (2.8/6.12) + Pelles C + HBMake + ADSCDX
São Paulo - Brasil
http://xBaseSuporte.freeforums.org
User avatar
ericmagaldi
 
Posts: 37
Joined: Tue Feb 20, 2007 9:26 am
Location: São Paulo - Brazil

Postby Antonio Linares » Wed Feb 28, 2007 9:33 am

Éric,

> Acredito que é Bug do ComboBox / ReDefine, concorda ????

No. Parece un problema de focus
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby ericmagaldi » Wed Feb 28, 2007 9:39 am

hehe... era isso que eu queria dizer, um "Bug"

e acha que em breve teremos uma correção sobre isso ?

:D
virtually,
Éric
xHarbour.org + Borland C + FiveWin (2.8/6.12) + Pelles C + HBMake + ADSCDX
São Paulo - Brasil
http://xBaseSuporte.freeforums.org
User avatar
ericmagaldi
 
Posts: 37
Joined: Tue Feb 20, 2007 9:26 am
Location: São Paulo - Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 70 guests