GdiplusX system.drawing APIs

Published on by Yousfi Benameur


 this code extracts all APIs gdiplusX system.drawing complet declarations.
its consists on 401 functions very usefull when working in imaging environment.
Apis come principally from gdi32.dll,gdiplus.dll..
the result is shown as txt file (reduced) and as a web IE page.
can search for any word with CTRL+F .can print the 401 APIs (to a PDF document  for ex.).
The code first asks you to point mandatory to system.drawing.prg (shipped with the gdiplusX project)
Can extend this code to other source of gdiplusX project (maybe there is more 600 APIs in total).
   
 Can also export as a cursor or table...
 In the second part i give 4 APIs examples of using directly and without gdiplusX.Drawing of course are not persistent.


Click on code to select [then copy] -click outside to deselect


*1*
 *this code extract all APIs gdiplusX system.drawing declarations.
*its consists on 401 functions very usefull when working in imaging environment.
*Apis come pricipally from gdi32.dll,gdiplus.dll..
*the result is shown as txt file and as a web decored page.
*can search for any word with CTRL+F .can print the 401 APIs (to a doument PDf if the case).
*The code first asks you to point to system.drawing.prg
*Can extend this code to other source of gdiplusX project (maybe there is 604 APIs in total).

Set Safe Off
Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))

lcStr=Filetostr( Locfile("system.drawing.prg","prg","Where is Drawing.drawing.prg ?") )
Local m.cc
m.cc=Occurs("DECLARE",m.lcStr)

Set Memowidth To 8192
Messagebox("System.drawing---DECLARE Occurences="+Trans(m.cc)+" In : "+Trans(Memlines(lcStr)) +" lines of code.",0+32+4096 ,'Occurences found',3000)
Local m.x,m.y
TEXT to m.y textmerge noshow
<style>
table, th, td {
border: 1px solid lime;}
</style>
<script>
function yprint(){
document.getElementById("ydiv").style.visibility="hidden";
window.print();
document.getElementById("ydiv").style.visibility="visible";
}

</script>
<div id="ydiv">
<label style="font-weight: bold;color:red;">Find in This Page...CTRL+F</label>
<input type="button" value="X" style="cursor:pointer;color:red;background-color:lime;float:right;" onclick="window.close()">
<input type="button" value='Print' style='cursor:pointer;background-color:lime;color:red;float:right;' onclick="yprint();">  
</div>
<center><h2 style="color:white;background-color:navy;width:650px">401 APIs declarations in gdiplusX system.drawing</h2></center><br><br>
<table id="ytable" style="padding:20px;">
ENDTEXT

m.x=""

liCntr = 1
Do While .T.
lcString = Strextract(m.lcStr,"DECLARE",Chr(13) ,liCntr ,4)
If Empty(lcString)
Exit
Else
m.x=m.x+Trans(liCntr)+" * "+lcString+Chr(13)+Chr(10)
If Len(Allt(m.lcString))>0
If Mod(liCntr,2)=0
m.y=m.y+"<tr><td style='font-family: Times New Roman, Times, serif;background-color:rgb(255,251,179)'>"+Trans(liCntr)+" * "+lcString+"</td></tr>"
Else
m.y=m.y+"<tr><td style='font-family: Arial, Helvetica, sans-serif;background-color:rgb(184,241,201)'>"+Trans(liCntr)+" * "+lcString+"</td></tr>"
Endi
Endi
Endi

Wait Window (Trans(liCntr)) Nowait
liCntr=liCntr+1
Enddo

m.y=m.y+"</table>"
Local m.lcdest
m.lcdest=Addbs(Sys(2023))+"test.html"
Strtofile(m.y,m.lcdest)

Strtofile(m.x,m.yrep+"asupprimer.txt")
Run/N2 notepad asupprimer.txt

Declare Integer BringWindowToTop In user32 Integer
Declare Integer SetWindowText In user32 Integer,String

Local apie
apie=Newobject("internetexplorer.application")
With apie
.Navigate(m.lcdest)
.fullscreen=1
SetWindowText(.HWnd, "windows APIs used in system.drawing of gdiplusX")
BringWindowToTop(.HWnd)
.Document.body.bgcolor="black"
.Visible=.T.

Endwith


GdiplusX system.drawing APIs
GdiplusX system.drawing APIs
GdiplusX system.drawing APIs

Click on code to select [then copy] -click outside to deselect


*2* example1

*The Ellipse function draws an ellipse on desktop.
*The center of the ellipse is the center of the specified bounding rectangle.
*The ellipse is outlined by using the current pen and is filled by using the current brush
*can draw on vfp syrface, desktop surface or on any window given by its handle.
Clea Dlls
Clea All
Declare Integer Sleep In kernel32 Integer
Declare Integer Ellipse In gdi32  Integer  hdc ,;
    integer X1 , Integer Y1 , Integer X2 , Integer Y2
Declare Integer GetActiveWindow In user32
Declare Integer GetDC In user32 Integer

Local oshell,HWnd,hdc
oshell=Newobject("shell.application")
oshell.toggleDesktop()  &&reduce all desktop windows
Sleep(2000)

m.hwnd=GetActiveWindow()   &&_screen.hwnd    &&getactivewindow()  &&_vfp.hwnd
m.hdc=GetDC(m.hwnd)


Inkey(2)
=Ellipse(m.hdc,100,100,800,500)


                      


Click on code to select [then copy] -click outside to deselect


*3* example 2
 *The Rectangle function draws a rectangle.
*The rectangle is outlined by using the current pen and filled by using the current brush.

Declare integer Rectangle in gdi32  integer hdc ,integer  X1 ,integer Y1 ,integer  X2 ,integer Y2
DECLARE INTEGER GetActiveWindow IN user32
 hwnd=0  &&desktop   &&_screen.hwnd    &&getactivewindow()
 declare integer GetDC in user32 integer
local hdc,oshell
 hdc=getDC(m.hwnd)
 oshell=newObject("shell.application")
 oshell.toggleDesktop()
 
 inkey(1)
 =Rectangle(m.hdc,100,100,800,500)   


Click on code to select [then copy] -click outside to deselect


*4*example 3
 *The RoundRect function draws a rectangle with rounded corners. 
*The rectangle is outlined by using the current pen and filled by using the current brush.

local hdc,oshell
Declare integer RoundRect in gdi32 integer hdc ,integer X1 ,integer Y1 ,;
integer X2 , integer Y2 ,integer X3 , integer Y3

 DECLARE INTEGER GetActiveWindow IN user32
 hwnd=0   &&_screen.hwnd    &&getactivewindow()
 declare integer GetDC in user32 integer

 hdc=getDC(m.hwnd)
 oshell=newObject("shell.application")
 oshell.toggleDesktop()
 
 inkey(1)
 =RoundRect(m.hdc,100,100,800,500,40,30)

 
 *********************
* Parameter Information
*· hdc
*Identifies the device context.

*· nLeftRect
*Specifies the x-coordinate of the upper-left corner of the rectangle.
*· nTopRect
*Specifies the y-coordinate of the upper-left corner of the rectangle.
*· nRightRect
*Specifies the x-coordinate of the lower-right corner of the rectangle.
* nBottomRect
*Specifies the y-coordinate of the lower-right corner of the rectangle.
*· nWidth
*Specifies the width of the ellipse used to draw the rounded corners.
*· nHeight
*Specifies the height of the ellipse used to draw the rounded corners. 


Click on code to select [then copy] -click outside to deselect


*4*example4
*draw a rectangle contour on desktop
local oshell,hBackground,hdcx0,y0,posx,posy
oshell=newObject("shell.application")
oshell.toggleDesktop
inkey(1)

DECLARE INTEGER CreateSolidBrush IN gdi32;
    LONG crColor
Declare Integer GetWindowDC      In win32api Integer
declare Integer FrameRect in win32api Integer,String @,Integer
Declare Integer DrawFocusRect    In win32api Integer, String @
Declare Integer ReleaseDC        In win32api Integer, Integer

hBackground = CreateSolidBrush( 255)   
hDC = GetWindowDC(0 )  
x0=100
y0=100
Posx=800
Posy=600
Rect=BinToC(x0,'4RS')+BinToC(y0, '4RS')+BinToC(Posx, '4RS')+BinToC(Posy, '4RS')   
FrameRect(hDC, Rect, hBackground )
= ReleaseDC(0, m.hDC )
return
          


 
*Important:*the code above is tested on visual foxpro 9 sp2-under windows 10 pro
I published a while ago in Foxite a similar code to extract all the system.drawing functions and build them as a help for user.(i used the function Extract...)

To be informed of the latest articles, subscribe:
Comment on this post