Display picture in a form

cn2607cn2607 Member Posts: 5
edited 2004-07-28 in Navision Attain
I want to show picture in the picture box on a form. However, BMP file is stored at c:\pictures\xxxx.bmp. It is easy to show picture from a BLOB field of a table but how to show it by exporting from the above path. I tried with bitmaplist property but get an error "Invalid Device-independent Bitmap file"
Is it doable and if so how. Thanks for your input
cn

Comments

  • bostjanlbostjanl Member Posts: 107
    cn2607 wrote:
    I want to show picture in the picture box on a form. However, BMP file is stored at c:\pictures\xxxx.bmp. It is easy to show picture from a BLOB field of a table but how to show it by exporting from the above path. I tried with bitmaplist property but get an error "Invalid Device-independent Bitmap file"
    Is it doable and if so how. Thanks for your input

    Create C/AL global - type BLOB, make it a source exp for picture box and use IMPORT to import picture.

    C&P from OnLine Help:
    ****************************************************
    b.IMPORT
    Use this function to import a BLOB (Binary Large Object).

    [ImportName :=] := BLOB.IMPORT([Name [, CommonDialog]])
    ImportName

    Data type: filename

    The name and path of the file the system imported.

    If ImportName is...
    It means the BLOB was...

    The file's name and path Imported
    Blank Not imported

    BLOB

    Data type: variable

    The BLOB you want to import.

    Name

    Data type: text or code

    The path and name of the BLOB you want to import. When you enter the path, keep in mind these shortcuts:

    You can...
    If the command is located...

    Omit the drive designation On the current drive
    Omit the full path In the current directory
    Enter only the subdirectory name In a subdirectory of the current directory

    CommonDialog

    Data type: boolean

    This tells the system whether or not you want it to display a dialog before it imports the BLOB. This dialog window lets you select the file you want to import. Based on the SubType property, the system only lists the appropriate file type, such as bitmap files (*.bmp), memo files (*.txt), or all files (*.*).

    If CommonDialog is...
    It means the system will...

    TRUE Display the confirmation dialog
    FALSE (default) Not display the confirmation dialog
  • cn2607cn2607 Member Posts: 5
    Thank you, bostjanl.
    From your response, I understand that ImportName is the name of the imported picture which then is used as a SourceExpr in the picture box's property.
    However, when I tried to create a variable BLOB in C/AL, (been thru the help on the b.import function) I keep getting errors and seem to be missing something. Can you please expand on the definitions of eg ImportName supposed to be of type: filename, but is defined where?
    BLOB of data type: variable - again defined where. I am not able to do it in C/AL.
    I guess what I am asking is where do I assign the filename of the picture (C:\picture\xxxx.bmp) and will the adding of the import code in "OnActivate()" of the form will then work. Perhaps a code example will help. Thanks.
    cn
  • bostjanlbostjanl Member Posts: 107
    cn2607 wrote:
    Thank you, bostjanl.
    From your response, I understand that ImportName is the name of the imported picture which then is used as a SourceExpr in the picture box's property.
    However, when I tried to create a variable BLOB in C/AL, (been thru the help on the b.import function) I keep getting errors and seem to be missing something. Can you please expand on the definitions of eg ImportName supposed to be of type: filename, but is defined where?
    BLOB of data type: variable - again defined where. I am not able to do it in C/AL.
    I guess what I am asking is where do I assign the filename of the picture (C:\picture\xxxx.bmp) and will the adding of the import code in "OnActivate()" of the form will then work. Perhaps a code example will help. Thanks.

    Hi!

    Ok, here it is:

    1. Define C/AL global temporary record, which has BLOB field,.. Let say "Company Information".
    Picture 1

    2. Add picture box to form ans set its SorurceExpression to Picture field in temporary record
    Picture 2

    3. Add push butttom with code
    Picture 3

    4. run the form
    Picture 4

    5. Push te button
    Picture 5

    Regads

    bostjan
  • cn2607cn2607 Member Posts: 5
    Thank you, bostjan. Works like a charm. It's the temporary 'record' type variable which uses 'picture' field from table company info.. etc and this is what I was missing.
    Many thanks again for an extremely descriptive explanation of the whole process.
    cn
Sign In or Register to comment.