Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default API in Excel

Can anybody give an example or link of using GDI in Excel?
Is it possible to plot a function on a form surface for example without
Excel charts, just using LineTo, SetPixel etc.?

Thank you in advance.

Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default API in Excel

I have found a solution using VB6 examples and news archive:
Dim hDC As Long
Dim DummyPt As PointAPI
hDC = GetDC(0)
Call SetPixelV(hDC, 100, 100, vbRed)
Call MoveToEx(hDC, 5, 15, DummyPt)
Call LineTo(hDC, 25, 15)
ReleaseDC 0, hDC
But instead a form it is plotting on Excel window itself (or on VBA editor).

Can anybody help? What parameter should I pass to GetDC() instead of 0?

Thank you in advance.

Mike.

"Mike510" сообщил/сообщила в новостях следующее:
...
Can anybody give an example or link of using GDI in Excel?
Is it possible to plot a function on a form surface for example without
Excel charts, just using LineTo, SetPixel etc.?

Thank you in advance.

Mike




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default API in Excel

Hi Mike510,

I have found a solution using VB6 examples and news archive:
Dim hDC As Long
Dim DummyPt As PointAPI
hDC = GetDC(0)
Call SetPixelV(hDC, 100, 100, vbRed)
Call MoveToEx(hDC, 5, 15, DummyPt)
Call LineTo(hDC, 25, 15)
ReleaseDC 0, hDC
But instead a form it is plotting on Excel window itself (or on VBA editor).

Can anybody help? What parameter should I pass to GetDC() instead of 0?


The parameter to GetDC (and ReleaseDC) should be the window handle of the
form, found using the FindWindow(vbNullString,Me.Caption) API call.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default API in Excel

Thank you very much for your help, Mr. Bullen.
Before I have read your post, I tried GetActiveWindow(). It worked too.
Should I delete hDC after releasing it or it is not necessary?


"Stephen Bullen" wrote in message
...
Hi Mike510,

I have found a solution using VB6 examples and news archive:
Dim hDC As Long
Dim DummyPt As PointAPI
hDC = GetDC(0)
Call SetPixelV(hDC, 100, 100, vbRed)
Call MoveToEx(hDC, 5, 15, DummyPt)
Call LineTo(hDC, 25, 15)
ReleaseDC 0, hDC
But instead a form it is plotting on Excel window itself (or on VBA

editor).

Can anybody help? What parameter should I pass to GetDC() instead of 0?


The parameter to GetDC (and ReleaseDC) should be the window handle of the
form, found using the FindWindow(vbNullString,Me.Caption) API call.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default API in Excel

Hi Mike510,

Should I delete hDC after releasing it or it is not necessary?


No, once released, that's OK.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ╘2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"