Solved

Using Canvas.Handle for OpenGL

Posted on 1998-10-31
8
309 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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 150 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
Making delphi communicate with a c# service 16 103
Delphi Yen format 3 35
enhance the following code 3 32
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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