Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using Canvas.Handle for OpenGL

Posted on 1998-10-31
8
Medium Priority
?
329 Views
Last Modified: 2010-04-03
Hello everybody!
Here is my little problem:
I want to use OpenGL API calls to draw some graphic into my form but for creating correct RC context i need to call several WinAPI functions such as ChoosePixelFormat, GetPixelFormat, SetPixelFormat etc. All of them need HDC of my window so i set MyForm.Canvas.Handle as HDC. But they do not work. GetLastError returns error#126.
Here is the question:
How can I use Canvas.Handle correctly and make it work as i would wish?
Thank you in advance!
0
Comment
Question by:Dune081198
  • 4
  • 3
8 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1345148
Why not simply try some existing OpenGL components on Internet?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1345149
0
 

Author Comment

by:Dune081198
ID: 1345150
it's good idea to use existing OpenGL components but it not solve the Canvas problem. :)
I'd like to make this funcs working.Thanks Zif for your link
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1345151
Dune, what happens if you pass a handle of the TPaintBox. What if you just pass the handle of the window? form1.handle.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1345152
Dune, pardon me for not answering your question directly.

I've found a sample program for using OpenGL. Now, I could just look at the source and give you the answer, but I guess it's better that I just give you the link to the example on using OpenGL. In there you'll find much more information, then if I just answer it.

http://torry.rimini.com/samples/samples/primscr.zip

PS. The link I gave you before has great links to other OpenGL thingies.

Regards, Zif.
0
 

Author Comment

by:Dune081198
ID: 1345153
sorry ZifNab. it not works neither OnCreate event nor OnPaint :(
as i could find the error 126 means  "Can't find this DC" or close
it seams the reason must be in form creation or somthing about this.
i think it's not very good idea to use window handle as device context

0
 

Author Comment

by:Dune081198
ID: 1345154
Oh! Sorry Zif! i did not notice your added coment. this example is excelent! just request your awnser to correct my mistake.
thanks a lot.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 600 total points
ID: 1345155
Hi Dune,

Glad it helped you.

I've found a sample program for using OpenGL. Now, I could just look at the source and give you the answer, but I guess it's better that I just give you the link to the example on using OpenGL. In there you'll find much more information, then if I just answer it.

http://torry.rimini.com/samples/samples/primscr.zip 

Regards, Zif.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question