1,105,177 Community Members

Can a JPG be displayed in a message box?

Member Avatar
archangel1177
Light Poster
26 posts since Jun 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I was having a discussion with a co worker just now and we discussed the idea of a message box coming up as part of a search and displaying a JPG picture as part of the results. Is that even possible? If so then how difficult would it be to add it? Thanks for settling this discussion.

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

As far as my knowledge stretch, the msgbox can not accept pictures... That made me develop my own message box which works wonders. Below is some code you can use to create your own message boxes. You can add pictures to your hearts content...

In a module, add the following... (You will notice that I don't use all of the boxes...)

Option Explicit

Public Function MsgQuestion(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String

With frmMessageQuestion
    .lblTitle.Caption = Title
    .lblMessage.Caption = Msg
    .cmdReturn(0).Caption = FirstButton
    .cmdReturn(1).Caption = SecondButton
    '.Image1(0).Picture = .imglstMessage.ListImages(2).Picture
    '.image2(1).Picture = .imglstMessage.ListImages(3).Picture
    .Show 1
        DoEvents
        MsgQuestion = .Tag
        Unload frmMessageQuestion
End With
End Function

Public Function MsgOkOnly(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String

On Error Resume Next

With frmMessageOkOnly
    .lblTitle.Caption = Title
    .lblMessage.Caption = Msg
    .cmdReturn(0).Caption = FirstButton
    '.cmdReturn(1).Caption = SecondButton
    '.image1(0).Picture = .imglstMessage.ListImages(2).Picture
    '.image2(1).Picture = .imglstMessage.ListImages(3).Picture
    .Show 1
        DoEvents
        MsgOkOnly = .Tag
        Unload frmMessageOkOnly
End With
End Function

Public Function MsgOkCancel(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String

'With frmMsgOkCancel
    '.lblTitle.Caption = Title
    '.lblMessage.Caption = Msg
    '.cmdReturn(0).Caption = FirstButton
    '.cmdReturn(1).Caption = SecondButton
    '.image1(0).Picture = .imglstMessage.ListImages(2).Picture
    '.image2(1).Picture = .imglstMessage.ListImages(3).Picture
    '.Show 1
        'DoEvents
        'MsgOkCancel = .Tag
       ' Unload frmMsgOkCancel
'End With
End Function

In your form, call the message box as follows...

Dim strMessage As String

strMessage = MsgQuestion("Please register your Product and create the Setup Data to continue.", "Register Product - Create Setup Data", "Ok, Continue With Registration", "Register Later")

''MsgQuestion calls the appropriate box you want to use...
''First part is the actual message...
''second part is the title...
''third part is the button yes title...
''fourth part is the button no title

Have a look at the code in the module. Create a form for each messagebox, called frmMsgQuestion etc. Also pay attention to the controls needed in the form - labels, commandbuttons etc. In my case, I have made use of images as command buttons (cmdReturn(0),cmdReturn(1) )

You can now also add other static images in the form that will be displayed. Also set the form properties to show in the centre of screen etc...

Member Avatar
harinath_2007
Posting Pro
509 posts since Aug 2010
Reputation Points: 56 [?]
Q&As Helped to Solve: 51 [?]
Skill Endorsements: 4 [?]
 
0
 

Dont know in VB but in java you can ..
However I found similar question asked previousle here in Daniweb...

Check this

Member Avatar
archangel1177
Light Poster
26 posts since Jun 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Wow thanks! I will pass this on to my co worker and let him know!

Question Answered as of 1 Year Ago by AndreRet and harinath_2007
Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

Only a pleasure. :)

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article