Forum > General

Error: Control " has no parent window

(1/2) > >>

jma_sp:
Hello,

I have a doubt, in Lazarus's program it shows me occasionally the mistake:

Control '' has no parent window.

Press OK to ignore and risk data corruption.
Press Cancel to kill the program.

There is some way of obtaining more precisely to which it refers? it happens on runtime.

molly:

--- Quote from: jma_sp on October 18, 2016, 05:09:37 pm ---There is some way of obtaining more precisely to which it refers? it happens on runtime.

--- End quote ---
Run your program through the debugger. There is no way of telling without seeing some actual code.

Most likely reason would be that you created components/forms dynamically but forgot to set the owner/parent. But that is pure speculation.

howardpc:

--- Quote from: jma_sp on October 18, 2016, 05:09:37 pm ---There is some way of obtaining more precisely to which it refers? it happens on runtime.

--- End quote ---

Make sure you give all your GUI controls (including those created dynamically) a unique Name.
Then you'll find such error messages far more informative.
BTW, one common cause of this sort of error arises through trying to access a control's Canvas before it has been assigned a Parent.

Remy Lebeau:

--- Quote from: howardpc on October 18, 2016, 05:16:02 pm ---BTW, one common cause of this sort of error arises through trying to access a control's Canvas before it has been assigned a Parent.

--- End quote ---

Or any HWND-based property, for that matter.  If a property requires the control to have a valid HWND, but it does not have a Parent, or its Parent does not have a Parent, or so on, then the HWND cannot be created, and the property fails.

jma_sp:
Thanks for the responses.
 :)
The program is simple enough, has few components these and the mistake happens of random form suddenly only often.
There are no dynamic components only components created directly in the form.

Formulario_Indice: TFormulario_Indice
    Panel: TGroupBox
    Arbol_Indice: TTreeView
    BitBtn_Salir: TBitBtn
    BitBtn_Salvar_A_Fichero: TBitBtn
    Etiqueta_Busqueda: TLabel
    Editor_Busqueda: TEdit
    BitBtn_Expandir_Ramas: TBitBtn
    BitBtn_Contraer_Ramas: TBitBtn
    BitBtn1: TBitBtn
    ListadoImagenes: TImageList
    Dialogo_Salvar_Fichero: TSaveDialog
    IconoBandeja: TTrayIcon
    MenuEmergente: TPopupMenu
         Maximizar: TMenuItem
         Salir: TMenuItem

I will try commenting on components to seeing if annulling someone of it eliminates the message.

Navigation

[0] Message Index

[#] Next page

Go to full version