Duplicate Id's generated automatically from tdialog

Duplicate Id's generated automatically from tdialog

Postby gkuhnert » Thu Oct 23, 2008 9:54 am

Hi,

with a custumor we are experiencing some problems with a duplicated Id No. The error message refers to the method defcontrol in class tdialog:

Code: Select all  Expand view
METHOD DefControl( oCtrl ) CLASS TDialog

   DEFAULT oCtrl:nId := oCtrl:GetNewId()

   if AScan( ::aControls, { | o | o:nId == oCtrl:nId } ) > 0
      #define DUPLICATED_CONTROLID  2
      Eval( ErrorBlock(), _FWGenError( DUPLICATED_CONTROLID, ;
                          "No: " + Str( oCtrl:nId, 6 ) ) )
   else
      AAdd( ::aControls, oCtrl )
      oCtrl:hWnd = 0
   endif

return nil


Is it possible, that on this place there is a Id generated, that already exists? And is there an other possibility, e.g. generating another id, if the same id is already detected, instead of giving an error message?


Application
===========
Path and name: X:\EHO2009\eho.exe (32 bits)
Size: 4,284,928 bytes
Time from start: 1 hours 19 mins 47 secs
Error occurred at: 08.10.2008, 09:22:11
Error description: Error FiveWin/2 Duplicated Id: No: 133

Stack Calls
===========
Called from: DIALOG.PRG => TDIALOG:DEFCONTROL(0)
Called from: BITMAP.PRG => TBITMAP:NEW(0)
Called from: IMAGE.PRG => TIMAGE:NEW(0)
Called from: AU_DRU2.prg => IMG(5546)
Called from: DRUCK.prg => DR_BITMAP(38)
Called from: AU_DRU2.prg => AU_UMBRUCH(4149)
Called from: AU_DRU2.prg => DRUCKFORM(1091)
Called from: AU_DRU2.prg => STARTDRUCKFORM(563)
Called from: AU_DRU2.prg => (b)AU_FORMULAR(418)
Called from: DIALOG.PRG => (b)TDIALOG:TDIALOG(0)
Called from: => TDIALOG:DISPLAY(0)
Called from: DIALOG.PRG => TDIALOG:HANDLEEVENT(0)
Called from: => DIALOGBOX(0)
Called from: DIALOG.PRG => TDIALOG:ACTIVATE(0)
Called from: ah_druck.prg => PRINTDLGSTART(37)
Called from: AU_DRU2.prg => AU_FORMULAR(421)
Called from: AU_DRU2.prg => AUFTRAGDRUCKEN(288)
Called from: au_edit.prg => VALEDITAUFTRAG(1918)
Called from: au_edit.prg => (b)EDITAUFTRAG(1514)
Called from: MDICHILD.PRG => TMDICHILD:END(0)
Called from: au_edit.prg => (b)EDITAUFTRAG(1519)
Called from: DIALOG.PRG => TDIALOG:CLOSE(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: DIALOG.PRG => TDIALOG:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => SYSREFRESH(0)
Called from: DIALOG.PRG => TDIALOG:END(0)
Called from: au_edit.prg => (b)EDITAUFTRAG(1436)
Called from: BUTTON.PRG => TBUTTON:CLICK(0)
Called from: CONTROL.PRG => TBUTTON:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => SENDMESSAGE(0)
Called from: DIALOG.PRG => TDIALOG:COMMAND(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: DIALOG.PRG => TDIALOG:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: WINDOW.PRG => TMDIFRAME:ACTIVATE(0)
Called from: EHO.prg => MAIN(666)
[/code]
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Postby Antonio Linares » Thu Oct 23, 2008 10:05 am

Gilbert,

Are you creating an IMAGE control from the ON INIT clause of a dialog ?

Please show the portion of your source code where you create the IMAGE control, thanks
regards, saludos

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

Postby gkuhnert » Thu Oct 23, 2008 10:43 am

Antonio,

it happens, when the print dialog is started like this:

Code: Select all  Expand view
      DEFINE DIALOG oPrintDlg TITLE cTitle RESOURCE "PREVIEW_PROC"
      REDEFINE BUTTON ID IDCANCEL OF oPrintDlg ACTION (lsBreak:=.t., oPrintDlg:End())
      REDEFINE SAY oSeite VAR nsSeite ID 101 OF oPrintDlg

      oPrintDlg:bPainted := {||IIF(nsSeite>0,oSeite:Refresh(),)}
      oPrintDlg:bStart := bStart

      ACTIVATE DIALOG oPrintDlg CENTER
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Postby gkuhnert » Fri Oct 24, 2008 11:17 am

I did some further research on this issue and found following interesting behaviour:

This is the code of the dialog while building the preview for printing:

Code: Select all  Expand view
PREVIEW_PROC DIALOG LOADONCALL MOVEABLE DISCARDABLE 173, 79, 194, 90
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Seitenvorschau"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "zur &Vorschau", 2, 69, 67, 56, 16
CONTROL "", -1, "STATIC", SS_BLACKFRAME | WS_CHILD | WS_VISIBLE, 10, 24, 174, 33
ICON "PRINT", -1, 17, 33, 16, 16
LTEXT "Erstelle Seite:", -1, 46, 36, 48, 10
LTEXT "1", 101, 96, 36, 80, 10
LTEXT "", 102, 10, 6, 174, 8
}


My preview contains an image which is called via oPrn:SayImage(). But on this dialog, the image is already included and I don't know why. But I guess, this is the reason, why the class tdialog generates a new ID.

It looks like this:
Image
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Postby Antonio Linares » Fri Oct 24, 2008 5:38 pm

Gilbert,

What code are you executing from bStart ?
regards, saludos

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

Postby gkuhnert » Mon Oct 27, 2008 10:02 am

Antonio,

this is the Code for bStart:
Code: Select all  Expand view
bStart := {|| StartDruckForm(nFormArt, aFormular, nBeginn, nEnde), PrintDlg():End()}


and the code for StartDruckForm
Code: Select all  Expand view
STATIC FUNCTION StartDruckForm(nFormArt, aFormular, nBeginn, nEnde)   // Formular Druck starten
LOCAL lReturn := .t.
   DO WHILE !(csAliasListe)->(EOF()) .and. (csAliasListe)->Rech_Nr <= nEnde
      // Gutschriften und Rechnungen unterscheiden (nur bei Rechnung/Gutschrift 1/2)
      if nFormArt==RECHNUNG1 .or. nFormArt==RECHNUNG2 .or. nFormArt==GUTSCHRIFT1 .or. nFormArt==GUTSCHRIFT2
         if (Kunden->Art == ART_GUTSCHRIFT .and. (nFormArt==RECHNUNG1 .or. nFormArt==RECHNUNG2)) .or. (Kunden->Art != ART_GUTSCHRIFT .and. (nFormArt==GUTSCHRIFT1 .or. nFormArt==GUTSCHRIFT2))
            (csAliasListe)->(dbSkip())
            LOOP
         endif
      endif
      Select(csAliasListe)

      lReturn := DruckForm((csAliasListe)->Rech_Nr, nFormArt, aFormular)
      if !lReturn
         EXIT
      endif
      (csAliasListe)->(dbSkip())
   ENDDO
return lReturn


And the function DruckForm called in here is about 2.000 lines, but doesn't contain any dialogs.
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Postby Antonio Linares » Mon Oct 27, 2008 11:27 am

Gilbert,

> And the function DruckForm called in here is about 2.000 lines, but doesn't contain any dialogs.

According to the error calls stack, an image control is created from:

Called from: IMAGE.PRG => TIMAGE:NEW(0)
Called from: AU_DRU2.prg => IMG(5546) // Here !
Called from: DRUCK.prg => DR_BITMAP(38)
Called from: AU_DRU2.prg => AU_UMBRUCH(4149)
Called from: AU_DRU2.prg => DRUCKFORM(1091) // Started here !

So it seems that DruckForm() calls other functions that finally try to create a TImage control. Please review AU_DRU2.prg line 5546, thanks
regards, saludos

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

Postby gkuhnert » Fri Oct 31, 2008 10:39 am

Antonio,

yes, the image control is being generated there, it is on purpose, because we want to print the image using sayimage. But while the preview is being built, we show a wait-dialog, which also shows the page number that momentarily is being generated. And on this dialog the image also is being showed, but there is no control or id for the image on this dialog, because it's not our intention to show the image on the dialog.

It's the PREVIEW_PROC DIALOG, the source code for it you can find in my 3rd post on this topic.
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands


Return to FiveWin for Harbour/xHarbour

Who is online

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