INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Graphics

How to display any picture format on a form by mgagnon
Posted: 1 Sep 02 (Edited 8 Oct 02)

This requires the Imaging Control Activex that shipped with Win95 and up. Cut and paste this code into a program and run.


PUBLIC frmImage
frmMyForm = CREATEOBJECT('images_demo')  && Create a Form
frmMyForm.SHOW()  && Display the form
READ EVENTS
DEFINE CLASS images_demo AS FORM
    AUTOCENTER = .T.
    TOP = 0
    LEFT = 19
    HEIGHT =450
    WIDTH = 485
    DOCREATE = .T.
    CAPTION = "Show picture demo"
    NAME = "Form1"
    ADD OBJECT command2 AS COMMANDBUTTON WITH ;
        TOP = 372, ;
        LEFT = 26, ;
        HEIGHT = 34, ;
        WIDTH = 431, ;
        CAPTION = "Select Image file to show", ;
        NAME = "Command2"
    ADD OBJECT optiongroup1 AS OPTIONGROUP WITH ;
        AUTOSIZE = .F., ;
        BUTTONCOUNT = 4, ;
        VALUE = 1, ;
        HEIGHT = 27, ;
        LEFT = 26, ;
        TOP = 339, ;
        WIDTH = 431, ;
        NAME = "Optiongroup1", ;
        Option1.CAPTION = "Best fit", ;
        Option1.VALUE = 1, ;
        Option1.HEIGHT = 17, ;
        Option1.LEFT = 5, ;
        Option1.TOP = 5, ;
        Option1.WIDTH = 55, ;
        Option1.AUTOSIZE = .T., ;
        Option1.NAME = "Option1", ;
        Option2.CAPTION = "Fit to width", ;
        Option2.HEIGHT = 17, ;
        Option2.LEFT = 98, ;
        Option2.TOP = 5, ;
        Option2.WIDTH = 76, ;
        Option2.AUTOSIZE = .T., ;
        Option2.NAME = "Option2", ;
        Option3.CAPTION = "Fit to height", ;
        Option3.HEIGHT = 17, ;
        Option3.LEFT = 215, ;
        Option3.TOP = 5, ;
        Option3.WIDTH = 81, ;
        Option3.AUTOSIZE = .T., ;
        Option3.NAME = "Option3", ;
        Option4.CAPTION = "Actual size", ;
        Option4.HEIGHT = 17, ;
        Option4.LEFT = 330, ;
        Option4.TOP = 5, ;
        Option4.WIDTH = 76, ;
        Option4.AUTOSIZE = .T., ;
        Option4.NAME = "Option4"
    ADD OBJECT label1 AS LABEL WITH ;
        AUTOSIZE = .T., ;
        CAPTION = "Height", ;
        HEIGHT = 17, ;
        LEFT = 254, ;
        TOP = 412, ;
        VISIBLE = .F., ;
        WIDTH = 38, ;
        NAME = "Label1"
    ADD OBJECT label2 AS LABEL WITH ;
        AUTOSIZE = .T., ;
        CAPTION = "Width", ;
        HEIGHT = 17, ;
        LEFT = 381, ;
        TOP = 410, ;
        VISIBLE = .F., ;
        WIDTH = 33, ;
        NAME = "Label2"
    PROCEDURE INIT
    THISFORM.ADDOBJECT('olecontrol1','OleControl','Imaging.EditCtrl.1')
    THISFORM.olecontrol1.TOP = 2
    THISFORM.olecontrol1.LEFT = 26
    THISFORM.olecontrol1.HEIGHT = 333
    THISFORM.olecontrol1.WIDTH = 431
    THISFORM.olecontrol1.NAME = "Olecontrol1"
    THISFORM.olecontrol1.VISIBLE = .T.

    IF !EMPTY(THISFORM.olecontrol1.IMAGE) AND FILE(THISFORM.olecontrol1.IMAGE)
        THISFORM.olecontrol1.DISPLAY
    ENDIF
ENDPROC

    PROCEDURE DESTROY
    THISFORM.REMOVEOBJECT("olecontrol1")
    DODEFAULT()
    RELEASE ALL
    CANC
ENDPROC

    PROCEDURE command2.CLICK
    LOCAL lcFile
    m.lcFile = GETPICT()
    IF FILE(m.lcFile)
        THISFORM.olecontrol1.IMAGE = m.lcFile
        THISFORM.olecontrol1.DISPLAY
    ENDIF
ENDPROC
    PROCEDURE optiongroup1.CLICK
    THISFORM.olecontrol1.FitTo(THIS.VALUE-1)
ENDPROC
ENDDEFINE


Mike Gagnon


Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close