View Full Version : im killing delphi...

20-01-2005, 09:47 PM
today i was ment to be working all day on a project of mine. well it started good then it went really bad, really fast.

basicly what im trying to do is create a component (inherited from TPanel) for opengl work (please download here (http://files.vadertrophy.com/filemon/jon/projects/opengl.zip))

when the component is created, i also setup the opengl rendering, please download the component and test app (made by TheLion in delphi 6) to see.

with that code, my delphi ( 7 ) either causes an infinate loop of access violations, terminates without error, or compiles and installs.

i CAN compile and run the test app (made by TheLion) without error. but when i try add a second TOpenGLPanel to the form i get a "Control '' has no parent" (or something like that).

delphi crashed so many times today, its now at the top of my most used application list in the start menu :D

i think i know what line is the problem, in uOpenGL.pas - Create - DC := GetDC(TWinControl(AOwner).Handle);

with that code, i normally crash delphi, but with this code DC := GetDC(Handle); i get the error when i add it to the form

if i use handle 0, no access violation, no error when adding to the form, but no opengl rendering :(

20-01-2005, 09:48 PM
oh, ive also reinstalled delphi. that didnt fix it

Robert Kosek
20-01-2005, 10:25 PM
Are you trying to draw within the panel only? Or the actual form?

From what I know:
DC := GetDC(TWinControl(AOwner).Handle);
Gives the DC of the form.
DC := GetDC(TWinControl(Self).Handle);
Should give the panel's DC.

If that doesn't work then I don't blame you! I'm going to kill dellphi soon anyway as well.

20-01-2005, 10:26 PM
Are you creating the component in code or by dropping it on a form?

If you creating the component in code, you must set the Parent property of the component. Note that this is different from the Owner that you pass to the Create() constructor. If I create a component in code, I always pass nil as the owner.

MyComponent := TMyComponent.Create(nil);
MyComponent.Parent := Panel2;

Now MyComponent will be drawn as a child of Panel2.

21-01-2005, 08:15 AM
im creating it by dropping it on a form.

im trying to get the panel's dc yes, but changing the code didnt work.

the error is "Control '' has no parent window" when i add it to the form

21-01-2005, 09:42 AM
If I use the line:

DC := GetDC(Handle);

in Delphi 6, I can drop the component onto the form without a problem and after running it there is a rotating triangle on my panel. Eriken also tried it with his Delphi 7 Personal version and he doesn't encounter any of the problems Tux encounters with the same code. He can also read my test app in Delphi without getting any errors... If tux tries to open the same project he gets a few errors and when he tries to run it he gets Access Violations etc.! :) hehe

strange stuff! ;) hehe

21-01-2005, 10:21 AM
Definatley sounds like Tux's Delphi installation has been corrupted somehow.

21-01-2005, 10:46 AM
damn :( a reinstall didnt fix it. no other components cause this error :o

21-01-2005, 12:37 PM
After looking at the component, I think the problem arises because you are trying to use and render to the DC at design time. It also crashes in my work's Delphi 6 IDE.
I would suggest having a look at how they have done it in GLScene to get an idea on how to proceed. I think it will involve wrapping certain calls with a...

if not( csDesigning in ComponentState ) then

21-01-2005, 02:36 PM
ill try it thanks :)

21-01-2005, 03:19 PM
Why reinvent the wheel? My GLEngine is a fully working opengl window component. At least if you don't want to use it, you can see some points from source. It uses window component more abstract than TPanel for efficiency reasons.


21-01-2005, 03:50 PM
the components only for basic rendering (to show car models) and because there will be more then 1 per application i wanted to put it in a component.

its nearly done, and your fix worked savage :D but the width and height arent working as expected. bassicly there both 0 until i change them on form creation

OpenGLPanel1.Width := OpenGLPanel1.Width +1;
OpenGLPanel1.Height := OpenGLPanel1.Height +1;

and that makes them the expected size, also ive tryed setting the width and height on component creation and it stays that size until i change it on form creation again :?