Results 1 to 7 of 7

Thread: Would it be possible ..... ???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Would it be possible ..... ???

    Hi there,

    One item which always interested me, was if it is possible to use a message box not as a pop up window but as part of a container i.e. picture box or so to open up ONLY in that container and any error message for that matter as well ??? So what I'm trying to get is a guided operation of that so beloved MsBox.

    Maybe somebody could help in any way ???.

    Thanks aktell

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Would it be possible ..... ???

    I really dont think so AFAIK but its a whole lot easier if you create a small form that duplicates a msgbox. Then use the SetParent API to nest the form into your container.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Re: Would it be possible ..... ???

    Thanks alot it is a beginning and I will try to find something on these lines.
    There is not anything you would know of how it's or has been done ???.

    Thanks aktell

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Would it be possible ..... ???

    Nope, just like I posted is your best bet.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Re: Would it be possible ..... ???

    I just found this !!! within this Forum - http://www.vbforums.com/showthread.php?t=409165 - and it is a very simelar question I had ??? and you (RobDog888) where so kind to reply too.
    Now as we are so far I really need some help to redirect ALL - AND ONLY the App's Error MsBoxes etc. of to this Form2 !!!

    Thanks aktell

  6. #6
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    NonModal MessageBox Inside A Container

    This is what I've tried. I'm using a timer, so there is a slight flickering.
    I'll post again if I find any better way.

    VB Code:
    1. ' add 2 form in the project
    2. ' place a picturebox, a command button and a timer in Form1
    3. ' and place this code inside Form1
    4. Option Explicit
    5.  
    6. Private Type RECT
    7.     Left As Long
    8.     Top As Long
    9.     Right As Long
    10.     Bottom As Long
    11. End Type
    12.  
    13. Const MB_ICONASTERISK = &H40&
    14.  
    15. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    16. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    17. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    18. Private Declare Function MessageBoxNonModal Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
    19. Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
    20.  
    21. '==============================================================================
    22. Private Sub Form_Load()
    23.     Timer1.Enabled = False
    24. End Sub
    25.  
    26. '==============================================================================
    27. Private Sub Command1_Click()
    28.  
    29.     Timer1.Interval = 5
    30.     Timer1.Enabled = True
    31.  
    32.     'shows non-modal messagebox
    33.     ' (Form2 is a hidden form)
    34.     Call MessageBoxNonModal(Form2.hwnd, "Hi! I'm inside PictureBox", _
    35.        "MessageBox inside PictureBox", MB_ICONASTERISK)
    36.  
    37. End Sub
    38.  
    39. '==============================================================================
    40. Private Sub Timer1_Timer()
    41.     Dim hMsgBox As Long
    42.     Dim rectMsgBox As RECT
    43.     Timer1.Enabled = False
    44.  
    45.     ' Find the hWnd of the MessageBox
    46.     hMsgBox = FindWindow("#32770", "MessageBox inside PictureBox")
    47.  
    48.     ' Get screen co-ordinate of the MessageBox
    49.     GetWindowRect hMsgBox, rectMsgBox
    50.  
    51.     'Change the messagebox's parent.
    52.     SetParent hMsgBox, Picture1.hwnd
    53.  
    54.     'Move the Messagebox to PictureBox's top,left corner
    55.     MoveWindow hMsgBox, 0, 0, (rectMsgBox.Right - rectMsgBox.Left), (rectMsgBox.Bottom - rectMsgBox.Top), 1
    56.  
    57. End Sub
    58.  
    59. '==============================================================================
    60. Private Sub Form_Unload(Cancel As Integer)
    61.  
    62.     'This ensures that all forms get unloaded
    63.     UnloadAll
    64.  
    65. End Sub

    Inside a Module:
    VB Code:
    1. ' Inside a Module
    2. Option Explicit
    3.  
    4. Public Sub UnloadAll()
    5.  
    6.     'Unloads all Form from Forms collection
    7.     Dim frm As Form
    8.  
    9.     For Each frm In Forms
    10.         Unload frm
    11.     Next
    12.  
    13. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Re: Would it be possible ..... ???

    Hi there,

    I'm very impressed Thank You Very Much. Please don't hessitate to get back to me if you find more.

    Thanks aktell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width