Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


This is very simple demo to demonstrate how to use path API in grawing.

To learn more about path Please visit following URL
http://msdn.microsoft.com/library/en-us/gdi/paths_8acz.asp

To implement Quick Demo, Copy/Paste following code in to the form code window

Click here to copy the following block
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function StrokePath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function FillPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function StrokeAndFillPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function AbortPath Lib "gdi32.dll" (ByVal hdc As Long) As Long


Private Sub Form_Paint()
  Dim hBrush As Long, oldBrush As Long, TargetDC As Long
  Const sText = "BinaryWorld"
  Me.Cls
     
  'set the form's font to 'Times New Roman, size 48'
  Me.FontName = "Tahoma"
  Me.FontSize = 35

  'make sure Me.TextHeight returns a value in Pixels
  Me.ScaleMode = vbPixels
    
  TargetDC = Me.hdc
  'create a new, white brush
  hBrush = CreateSolidBrush(vbWhite)

  'replace the current brush with the new white brush
  oldBrush = SelectObject(TargetDC, hBrush)

  'set the fore color to black
  Me.ForeColor = vbBlack

  '********************************
  'open a path bracket
  BeginPath TargetDC
  
  'draw the text
  ret = TextOut(TargetDC, 0, 0, sText, Len(sText)) '//To test AbortPath specify -1 in last parameter
  
  If ret Then
    'close the path bracket
    EndPath TargetDC
    
    'render the specified path by using the current pen
    FillPath TargetDC
  Else '//Cleanup Path if cannot Draw
    AbortPath TargetDC
  End If
  '********************************
  
  
  '********************************
  'open a path bracket
  BeginPath TargetDC
  
  Me.ForeColor = vbBlue
  'draw the text
  ret = TextOut(TargetDC, 0, 50, sText, Len(sText)) '//To test AbortPath specify -1 in last parameter
  
  If ret Then
    'close the path bracket
    EndPath TargetDC
    
    'render the specified path by using the current pen
    StrokePath TargetDC
  Else '//Cleanup Path if cannot Draw
    AbortPath TargetDC
  End If
  '********************************
  
    
    
  '********************************
  'open a path bracket
  BeginPath TargetDC
  Me.ForeColor = vbRed
  'draw the text
  ret = TextOut(TargetDC, 0, 100, sText, Len(sText)) '//To test AbortPath specify -1 in last parameter
  
  If ret Then
    'close the path bracket
    EndPath TargetDC
    
    'render the specified path by using the current pen
    StrokeAndFillPath TargetDC
  Else '//Cleanup Path if cannot Draw
    AbortPath TargetDC
  End If
  '********************************
   
  
  'replace this form's brush with the original one
  SelectObject TargetDC, oldBrush
  'delete our white brush
  DeleteObject hBrush
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.