CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2012
    Posts
    53

    Dynamically updating image (PNG)

    Hello there,

    I am working on a Windows application using Visual Studio 2012. One of the screens have a text entry field for the user. Instead of using a standard text field control, am placing a image which looks exactly like a text field. Now what i want to do is, capture the key stroke and update this image with the characters entered by user.

    The initial image shown to the user is "Blank_Text_Entry.png" and this is added to the resource as IDB_BLANK_TEXT_ENTRY.
    This is a rectangular white image with dimensions 153 x 27, with a size of 250 bytes.

    My goal is to be able to update this image dynamically based on key strokes by user and display it.

    Is it possible to do something like this? If yes, can anyone share some sample code?

    Thanks in advance.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Dynamically updating image (PNG)

    What's the underlying goal? I mean, you seem to be going out of your way not to use the control designed for text input.

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Dynamically updating image (PNG)

    Basically "capture the key stroke" can be done by handling keyboard messages WM_KEYDOWN, WM_KEYUP or WM_CHAR.
    "Update the image dynamically" can be done by handling WM_PAINT message. In the WM_PAINT message handler can use device context(s) to draw/compose images, texts and so on.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Dynamically updating image (PNG)

    Quote Originally Posted by Don Guy View Post
    I am working on a Windows application using Visual Studio 2012. One of the screens have a text entry field for the user. Instead of using a standard text field control, am placing a image which looks exactly like a text field.
    What you do here looks like implementing just a custom edit box. I'm pretty sure there might be some other and much easier ways to achieve the same result.

    I can imagine only one reason for placing image instead of text: a protection from grabbing text. So, is it your ultimate goal?
    Best regards,
    Igor

  5. #5
    Join Date
    Aug 2012
    Posts
    53

    Re: Dynamically updating image (PNG)

    The ultimate goal is protection itself.

  6. #6
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Dynamically updating image (PNG)

    Quote Originally Posted by Don Guy View Post
    The ultimate goal is protection itself.
    Protection against what? Copy and paste, human recognition, OCR, something else?
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

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

Featured