custom-made msgbox ? custom-made msgbox ? tg2003 (IS/IT--Management) (OP) 24 Jul 08 03:06 Hi,Can I put my own icons and pictures on msgbox message?I found no relevant information in the manuals. Is there any trick that do that, or should I custom a msgbox form by myself?Thanks in advance! RE: custom-made msgbox ? HughLerwill (Programmer) 24 Jul 08 04:40 >Can I put my own icons and pictures on msgbox message?Not in vb. There may be ways using APIs but not easily.>should I custom a msgbox form by myself?That's the way. RE: custom-made msgbox ? Hypetia (Programmer) 24 Jul 08 05:00 MessageBoxIndirect API function offers a feature to display a custom icon. This custom icon must be loaded from an EXE or DLL resource. You can use your own resource from application's EXE/DLL file or load an external resource using LoadLibrary or LoadLibraryEx function.If you want to display a custom icon, you must add it to your application's resource. You can use VB's Resource Editor add-in for this purpose. Alternatively, you can use icons embedded in an external DLL file.See the following code. The wrapper function MsgBoxEx has most of the features of MsgBox function, in addition to displaying custom icons if you want.___Private Declare Function MessageBoxIndirect Lib "user32" Alias "MessageBoxIndirectA" (lpMsgBoxParams As MSGBOXPARAMS) As LongPrivate Declare Function GetActiveWindow Lib "user32" () As LongPrivate Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPrivate Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As LongPrivate Type MSGBOXPARAMS cbSize As Long hwndOwner As Long hInstance As Long lpszText As String lpszCaption As String dwStyle As Long lpszIcon As Long dwContextHelpId As Long lpfnMsgBoxCallback As Long dwLanguageId As LongEnd TypeConst MB_USERICON = &H80&Private Function MsgBoxEx(Prompt As String, Optional Buttons As VbMsgBoxStyle, Optional Title As String, Optional hResource As Long, Optional IconResource As Long) As VbMsgBoxResult Dim mbp As MSGBOXPARAMS mbp.cbSize = Len(mbp) mbp.lpszText = Prompt mbp.dwStyle = Buttons mbp.hwndOwner = GetActiveWindow() mbp.lpszIcon = IconResource mbp.hInstance = IIf(hResource, hResource, App.hInstance) mbp.lpszCaption = IIf(Len(Title), Title, App.Title) mbp.dwStyle = IIf(IconResource, Buttons Or MB_USERICON, Buttons) MsgBoxEx = MessageBoxIndirect(mbp)End FunctionPrivate Sub Form_Load() MsgBoxEx "Standard message box, like MsgBox.", vbInformation '--- MsgBoxEx "Message box with custom icon from application's own resource (in this case, VB6.EXE).", , "Palette", , 1257 '--- Dim hLib As Long hLib = LoadLibrary("shell32.dll") MsgBoxEx "Message box with custom icon loaded from an external resource (shell32.dll).", , "Tree", hLib, 42 FreeLibrary hLib '--- Unload MeEnd Sub___Note that when you use custom icon from your own application resource, the correct icon is not displayed in IDE because App.hInstance returns the instance handle of VB6.EXE. To check if the icon is correctly displayed, you need to compile your app and run the EXE. RE: custom-made msgbox ? strongm (MIS) 24 Jul 08 06:52 Yep, I've got much the same code. No need to post it now, though ... RE: custom-made msgbox ? tg2003 (IS/IT--Management) (OP) 24 Jul 08 10:55 Thank you all! RE: custom-made msgbox ? GeodesicDragon (Vendor) 17 Aug 08 09:43 I am the creator of a (very popular) program that allows users to create their own Windows-based message boxes. In order to make said program better, I am updating it to allow the user to create messages using icons from a certain list I've created (thus, using a .RES file).The following code creates the message box:If MsgBoxEx((msgtext), (msgtype), (msgtitle), , lstCustomIcons.ListIndex) = vbAbort Or vbCancel Or vbIgnore Or vbNo Or vbOK Or vbRetry Or vbYes Thenmsgtext = Text in message box.msgtype = Depends on what type of box the user wants to create. Example: vbInformation or vbOKonlymsgtitle = Obvious.lstCustomIcons.ListIndex refers to the ID number of the icon in the .RES file.msgtext, msgtype and msgtitle are in brackets because every time I tried to compile the program, I got a message saying 'ByRef argument type mismatch'.So, I wrapped them in the brackets, and that fixed it, but now the custom icons are not showing. What am I doing wrong? RE: custom-made msgbox ? HughLerwill (Programmer) 17 Aug 08 12:10 GeodesicDragon,Policy around here is generally one questioner per thread so please begin a new thread for your question. You may reference this thread in it if you wish.When you do that we are going to need a little information about your MsgBoxEx function; e.g. is it something you have written, an alias for an API call etc.