Archived

This topic is now archived and is closed to further replies.

Goku705

DirectDraw with VCL

Recommended Posts

I''m working in Borland C++ Builder 5 with VCL and I would like to create a program that uses DirectDraw for it''s drawing operations. However, instead of having the app be fullscreen or windowed such that it fills the whole form, I would like to have DirectDraw reside within a control, like a TImage or something and have other controls on other parts of the form. The problem is that I can''t find a control that it would be reasonable to put DirectDraw into while also having access to its HWND through the Handle property (since you need one to initialise DirectDraw). So does anyone know which control I should use for this? Or any similar sort of workaround? -Goku SANE Productions Homepage

Share this post


Link to post
Share on other sites
Any control that descends from twincontrol will have a window handle. Note: the WindowHandle property is protected, but if you are descending from this control you have complete access to it. Otherwise, just Just create a twindow descendent, and typecast your tpanel to that type, and then you can access the protected data member.

You could try a TPanel.

THack = class(twincontrol);

THack(panel1).WindowHandle;

-andy

Share this post


Link to post
Share on other sites
For simplicity, I suggest just drawing right on the form. This allows you to pass the TForm::Handle to DirectDrawCreate(Ex). Since you''ll probably initialize DDraw from within a form member function, you''ll have access to the Handle property.

Happy coding

Share this post


Link to post
Share on other sites
Well, yes, you could do that. Indeed that is what I did. To see some code on how to, you can download the libs at my site.
But there are some problems: Blting the two buffers (back and front) are a little headachy - front is always the fullscreen. You need to typecast to TWinControl, then get the Handle off that. When you blt, again typecast, and get the ClientRect of the Control for the position.
Have fun!

------------------------------
BCB DX Library - RAD C++ Game development for BCB

Share this post


Link to post
Share on other sites
Well, thanks to everyone for the suggestions. I'd been playing around with it and decided that a TPanel would work best in this case. If I'd used the form itself, I'd have had to fiddle around to find the exact spot I'd like to blit to; something that probably wouldn't have been easy since the form also has a menu and other controls on it. Using a TPanel, I only had to set up my RECT to use the values in BoardPanel->ClientOrigin (and of course add in the width/height too) and it would blit to exactly where I wanted.

Thank you again.

(EDIT)Amusingly enough, I just noticed that my partner for my current project had posted a reply to me! I bet he didn't even notice it was me!

-Goku
SANE Productions Homepage

Edited by - Goku705 on August 13, 2001 10:38:53 PM

Share this post


Link to post
Share on other sites