Results 1 to 13 of 13

Thread: PictureBox.hdc?

  1. #1
    chenko
    Guest

    PictureBox.hdc?

    VB Code:
    1. Public 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
    2.  
    3. Public Sub Text2Picture(ByVal sString As String, ByVal PicBox As PictureBox, Optional ByVal posX As Long = 0, Optional ByVal posY As Long = 0)
    4.     TextOut(PicBox.hdc, posX, posY, sString, Len(sString))
    5. End Sub

    I use this code in vb6 to create an image from a string of text... when i try using it in .NET it tells me - " 'hdc' is not a member of system.windows.form.picturebox" - how do i go about this?


    cheers
    si

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    .NET has something new called GDI+ that handles all graphics stuff which is probably what you need. I dont know alot about it yet, but I just wanted to give you the keyword to look for. Try searching the net for GDI+ if you dont get a better answer.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    chenko
    Guest
    Originally posted by Cander
    .NET has something new called GDI+ that handles all graphics stuff which is probably what you need. I dont know alot about it yet, but I just wanted to give you the keyword to look for. Try searching the net for GDI+ if you dont get a better answer.

    oh fun


    cheers i will look into that

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    your welcome. In fact, now that I think about it, there is a Text drawing class in GDI+. Dont remember the namespace, but I know it exists.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    chenko
    Guest
    yea i noticed that... I did a search and mostly it was only for C# or ASP

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7
    chenko
    Guest
    thanks

    whats this Protected Overrides... new to me?



    been visiting Programmers Heaven recently mate?

  8. #8
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Nah ..havent been around PH for awhile. Not much happens around there.

    Protected means the procedure can only be called by a class that inherits the class the procedure is in.

    Overrides tell the system to to run your procedure in the case of another procedure of the same name, that can be overrided, being called. Sort of like sub classing. In short your procedure takes precedent over the other.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  9. #9
    chenko
    Guest
    ok cheers, that code seems what i want sorta


    I want to beable to put the image into a picture box, and save it (2 different steps) ... just what do i replace for the 'e' varible if i put it somewhere else


    oh frig this is confusing

  10. #10
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    the e parameter is only for Subs/functions that are called by an object. In other words an event and is a collection of arguements for an event.

    Im not sure what you mean by replace it if I put it somewhere else.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  11. #11
    chenko
    Guest
    well nore do I really, confused myself

    VB Code:
    1. Protected Overrides Sub OnPaint(e As PaintEventArgs)
    2.     Dim g As Graphics = e.Graphics
    3.     e.Graphics.FillRectangle(New SolidBrush(Color.White), ClientRectangle)
    4.     g.DrawString("Hello World", Me.Font, New SolidBrush(Color.Black), 10,10)
    5. End Sub

    that code works fine and dandy, thou paints it on a form, whereas i want it in a picturebox, also i want to beable to call on it as a sub procedure so somit like

    Sub Text2Pic(sString as String, picBox as Picturebox, Font as Font, FontSize as Integer)

    yea, i know its vb6 but that is what i am trying to get to thou

  12. #12
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    hmmm. Well let me see what I can come up with. ill give it some thought as time permits.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  13. #13
    chenko
    Guest
    ok cheers, another small thing, do you think its possible to display a font which isnt installed on the system, thou i have the .ttf file? Ive just downloaded that free book someone posted, im gonna have a quick read thru that and see what I come up with

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width