Welcome, Guest
Username: Password: Remember me
Qui si parla italiano
  • Page:
  • 1

TOPIC:

Nuova grafica 20 Oct 2021 16:24 #20003

  • softdevo@tiscali.it's Avatar
  • Topic Author


  • Posts: 177
  • Io sto completamente ridisegnando la grafica delle mie applicazioni Windows Form.
    In allegato un esempio.
    Le finestre sono CLASS DevoWindow INHERIT Form.
    Le finestre sono senza bordo e la TextBar è sostituita da una Label chiamata Caption.
    Come posso scrivere questo codice senza che si generi errore?

    PROPERTY Text AS STRING
    GET
    RETURN SELF:Caption:Text
    END GET
    SET
    SELF:Caption:Text := VALUE
    END SET
    END PROPERTY

    Grazie
    Attachments:

    Please Log in or Create an account to join the conversation.

    Nuova grafica 20 Oct 2021 16:32 #20005

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Ciao Danilo,
    vuoi dire che la Label che si chiama "Caption" nella classe DevoWindow non esiste?
    Saluti
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Nuova grafica 20 Oct 2021 16:34 #20006

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Ciao Danilo,
    questo codice da me compila:
    class DevoWindow inherit Form
    	protect Caption as Label
    
    property Text as string
    get
    return self:Caption:Text
    end get
    set
    self:Caption:Text := VALUE
    end set
    end property
    
    end class

    In teoria puoi accorciare e scrivere la property in una riga (secondo me anche più elegante):
    property Text as string get self:Caption:Text set self:Caption:Text := VALUE

    Saluti

    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Nuova grafica 20 Oct 2021 16:47 #20008

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 177
  • Si Wolfgang grazie, anche a me compila, ma poi, agganciato ad una qualsiasi applicazione in esecuzione da questo errore:
    In questo caso la finestra WLoginEnglish eredita dalla DevoWindow.
    Se tolgo la property tutto torna a funzionare.

    System.NullReferenceException
    Riferimento a un oggetto non impostato su un'istanza di oggetto.

    Callstack :
    WLoginEnglish.System.Void WLoginEnglish..ctor()() : C:\XIDE\Projects\Dll_and_SystemFiles\Applications\SQLManagerNet\Prg\WLoginEx.prg : 8
    static System.Void SQLManagerNet.Exe.Functions.Start(System.String[] pString)() : C:\XIDE\Projects\Dll_and_SystemFiles\Applications\SQLManagerNet\Prg\Main.prg : 31

    Please Log in or Create an account to join the conversation.

    Nuova grafica 20 Oct 2021 17:01 #20010

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Ciao Danilo,
    probabilemente la tua property viene chiamata prima che il label "Caption" è stato creato.
    In questo caso scriverei questo codice:
    property Text as string
    get
     if self:Caption == null
      return ""
     else
      return self:Caption:Text
      endif
    end get
    set
     if self:Caption != null
      self:Caption:Text := VALUE
     endif
    end set
    end property
    Dovrebbe esistere una possibilità ancora più corta, ma devo controllare.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Nuova grafica 20 Oct 2021 17:21 #20012

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 177
  • NO niente anche così non cambia, sembra che richiamare una istanza della form, Self:Text appunto, essendo la finestra senza bordi crei il problema. Si dovrebbe secondo me poter scrivere un qualcosa del tipo : Override Property Text as string

    Danilo

    Please Log in or Create an account to join the conversation.

    Nuova grafica 20 Oct 2021 17:27 #20013

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Ciao Danilo,
    ok, capito,
    In effetti la classe System.Windows.Forms.Form ha già un property che si chiama "Text":
    docs.microsoft.com/en-us/dotnet/api/syst...dows.forms.form.text
    In questo caso in effetti devi aggiungere la keyword "ovveride" davanti per dire che vuoi sovvrascrivere la property della classe parente.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 08:41 #20018

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 177
  • Ciao Wolfgang, mettendo OVERRIDE l'errore non viene generato e l'applicazione parte, ma l'assegnazione non funziona,
    credo che dovrò scrivere SELF:Caption:Text := "bla bla bla" per forza.

    Danilo

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 09:14 #20019

    • Chris
    • Chris's Avatar


  • Posts: 3974
  • Hi Danilo,

    What is SELF:Caption? Is it an object? Are you sure this is initialized? The error message seems to say that this is NULL.
    Maybe you can produce a small sample and post it here to have a look?

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 11:04 #20024

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • Ciao Danilo,
    potresti darci un piccolo esempio che dimostra il problema?
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 13:49 #20031

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 177
  • Preparo un demo e lo invio. Grazie a tutti
    I prepare a demo and submit it. Thank you all

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 14:15 #20032

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 177
  • Here is a small application. Look at the DevoWindow.prg prg line 233. I hope I have attached everything.
    Thanks
    Danilo

    Ecco qui una piccola applicazione. Guardate il prg DevoWindow.prg linea 233. Io spero di aver allegato tutto.
    Grazie
    Danilo

    File Attachment:

    File Name: Demo.zip
    File Size:13 KB
    Attachments:

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 15:00 #20038

    • Chris
    • Chris's Avatar


  • Posts: 3974
  • Hi Danilo,

    In the SET of the PROPERTY, you have

    SELF:Caption:Text := SELF:Text

    shouldn't that be

    SELF:Caption:Text := VALUE

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 17:52 #20051

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 177
  • Grrrrrrr, Thank you.

    Danilo

    Please Log in or Create an account to join the conversation.

    Nuova grafica 21 Oct 2021 17:58 #20052

    • Chris
    • Chris's Avatar


  • Posts: 3974
  • :)
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1
    Moderators: wriedmann