none
PictureBox Control (Labans) RRS feed

  • Question

  • I am using Stephen Labans picture control on one of my access forms.   Is there a good place to ask questions if not here?

    My problem is I load a GIF image into the picture box and I recieve errors about incorrect formatting but when I use the form in Stephen's example database I do not get any errors.

    Another problem I am having is when I go to draw on the image my GIF disappears and the drawing is replaced.

    Anyone have an idea as to how I can resolve this?

    Wednesday, January 16, 2013 12:29 AM

Answers

  • Hello K. Kazinski,

    I have looked at Stephen Lebans' PictureBoxA2K.mdb and found the likely reason you are encountering errors. After copying the code into a new Access database, I too was encountering errors when loading an image and I was unable to use the 'Start Draw with Mouse'.

    When I stepped through the code, I found that my new database had a value of 71 for the bArray(0) array but the PictureBoxA2K.mdb had a value of 14. The value of bArray(0) is used within the PictureDataToMetafile function to determine the clipboard format. Here I found that 71 is not defined and the error is raised, but 14 is used for the case CF_ENHMETAFILE statement.

    I believe the source of this difference is in how you created the new database. When you create a new in Access 2010, the default file format is an Access 2007-2010 format (*.accdb) database. When you create a database of this type, there is a database property 'Picture Property Storage Format' which is set to the value 'Preserve source image format (smaller file size)'. If you were to use an older database format (*.mdb), the 'Picture Property Storage Format' property is set to 'Convert all picture data to bitmaps (compatible with Access 2003 and earlier)'.

    Long story short. If you go to the File tab > Options > Current Database -  Picture Property Storage Format and change the setting to 'Convert all picture data to bitmaps (compatible with Access 2003 and earlier)', you should not encounter errors using Stephen's sample in your database.

    Regards,

    Dennis


    • Marked as answer by K. Kazinski Monday, January 21, 2013 11:19 PM
    Monday, January 21, 2013 2:47 PM

All replies

  • Hi K. Kazinski

    If you don't get help here you may try on http://www.utteraccess.com/forum/forums.html

    Henry

    "K. Kazinski" schrieb im Newsbeitrag news:0171dcd7-aefc-4c68-ae77-8775d49832ee@communitybridge.codeplex.com...

    I am using Stephen Labans picture control on one of my access forms.
    Is there a good place to ask questions if not here?

    Wednesday, January 16, 2013 8:53 AM
  • maybe you should try to find out how the code works that doesn't give any problems, analyse it!
    Wednesday, January 16, 2013 8:44 PM
  • Mr. Rik,

    Thanks for the advice.  I have analyzed it.  Once I get to the statement "m_ImageControl.Picture = strfName."  Once this statement gets executed the image is loaded into the image control and displayed.

    I printed using the debug command in each database to print out what what in m_ImageControl.PictureData but there are differences when loading the same file.

    I have gone through each of the controls settings to verify they are the same and they appear to be.  I have checked to see if I have the same references which I do.

    So I am at a loss as to what could be different which is why I asked the question.

    Thursday, January 17, 2013 12:37 AM
  • Hi K. Kazinshi,

    thanks for posting in the MSDN Forum.

    I would recommend you show your code for further research.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 18, 2013 1:39 AM
    Moderator
  • Tom,

    I started by getting a copy of the picture box class (http://www.lebans.com/imageclass.htm).

    I copied the form over to my database.

    I call the routine from pb.LoadImageControl <Path name to file.GIF>

    When I get to the call m_ImageControl.Picture = strfName in the clsPictureBox class.  The image loads into the image/picture box control.

    I step throught the code to the SaveImagetoBuffers call and step into the function.  I get to the "If m_ImageControl.PictureData(0) <> 40 Then" which turns out to be true and I follow the code into the function "PictureDataToMetafile"

    Once in this function the program falls throught the case statement "Case CF_METAFILEPICT" and I get the error.

    I tried loading the gif file using the form in the A2KPictureBoxV35 and do not get any errors but when I load it in my database I get an error.  I did a quick debug.print of the bArray and see the data is different, but I do not understand why the two databases are loading the same file differently.

    I have tried to just copy the Form_frmPictureBox from the orignal database and get the same error as when I have the image control on my form.  The only reference I do not have in my database is DAO3.6. I would not have thought that would be causing my problem.

    Any suggestions would be a great help.

    Friday, January 18, 2013 12:49 PM
  • Hi K. Kazinski,

    I can open the hyperlink http://www.lebans.com/imageclass.htm . I will involve some experts into your issue to see whether they can help you. There might be some time delay, appreciate for your patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 21, 2013 2:29 AM
    Moderator
  • Tom,

    Any help you can provide would be great.  I am at a loss as to why one database/form loads the file correctly and mine (the other one) does not.

    K. Kazinski

    Monday, January 21, 2013 4:13 AM
  • Hello K. Kazinski,

    I have looked at Stephen Lebans' PictureBoxA2K.mdb and found the likely reason you are encountering errors. After copying the code into a new Access database, I too was encountering errors when loading an image and I was unable to use the 'Start Draw with Mouse'.

    When I stepped through the code, I found that my new database had a value of 71 for the bArray(0) array but the PictureBoxA2K.mdb had a value of 14. The value of bArray(0) is used within the PictureDataToMetafile function to determine the clipboard format. Here I found that 71 is not defined and the error is raised, but 14 is used for the case CF_ENHMETAFILE statement.

    I believe the source of this difference is in how you created the new database. When you create a new in Access 2010, the default file format is an Access 2007-2010 format (*.accdb) database. When you create a database of this type, there is a database property 'Picture Property Storage Format' which is set to the value 'Preserve source image format (smaller file size)'. If you were to use an older database format (*.mdb), the 'Picture Property Storage Format' property is set to 'Convert all picture data to bitmaps (compatible with Access 2003 and earlier)'.

    Long story short. If you go to the File tab > Options > Current Database -  Picture Property Storage Format and change the setting to 'Convert all picture data to bitmaps (compatible with Access 2003 and earlier)', you should not encounter errors using Stephen's sample in your database.

    Regards,

    Dennis


    • Marked as answer by K. Kazinski Monday, January 21, 2013 11:19 PM
    Monday, January 21, 2013 2:47 PM
  • Hi Dennis,

    That did the trick.  I am able to display the graph and draw on it without wiping out what is below it.

    Do you think there might be a fix to the code so you can use the picture control with Access 2007 & 2010?

    Again I really appreciate the time you have taken to look into this.

    Monday, January 21, 2013 11:19 PM
  • Hi K. Kazinski,

    Great to hear this is working for you. I'm sure there is a way to fix the code, but I'm not familiar with how to parse the PictureData to build the metafile that's passed to the clipboard.

    Regards,

    Dennis

     

    Thursday, January 24, 2013 5:26 PM