Results 1 to 11 of 11

Thread: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

  1. #1

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    I have found the standard msgbox dialog box to be limited in how I can control it. I rolled my own from a simple lookalike form with my own icons. I can place it where I like and style it too, some functionality that the old msgbox seemed to lack.



    Do we all roll-our-own eventually? Is that what you did? I assume everyone eventually does so...
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    We have TaskDialog now. Simple formats can easily be used from VB6, complex ones require a type library.

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    Quote Originally Posted by yereverluvinuncleber View Post
    Do we all roll-our-own eventually? Is that what you did? I assume everyone eventually does so...
    I passed through this phase at one time. I once write an entire message box class from scratch for some program I was writing in VB.Net many years ago. I wrote it specifically for reporting error messages when a program crashed. It would show all the call stack information, what the error was etc arranged visually in a very specific way that could not be replicated using the standard Windows message box. In those days I didn't know anything about WPF so I was writing the UI code the old fashion way which I learned to from writing similar UI logic back when I was in VB6. This required me writing all of the rendering code myself and it was a maintenance nightmare because it took too much time away from me working on what was actually important which was the program itself that was going to use it. I eventually abandoned it because it was too much of a time sink.

    If I were to do this today, I'd just write it using WPF so it would take like 10% of the effort since I won't have to spend all this time calculating drawing rectangles, measuring text, measuring layouts and clipping and a whole bunch of other painstaking UI logic.

    However, these days I don't really see a need anymore to write my own message box classes because if the standard one is not suitable for what I want, I would just write a normal UI interface for whatever it was I wanted to show. I guess back in earlier times I was just looking for an excuse to do it. It was fun and interesting but not practical from a productivity stand point. If I want to report error messages today, I would use a simple log file. As I've gotten older, I've grown allergic to assigning myself unnecessary workloads and custom message boxes fall into this category, at least for me. The standard Windows message box is sufficient nearly all the time.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    I still use the standard message box, but I virtually always use API calls to display it so I can control my button captions, put timers on it, and a few other things. I've never needed a "roll my own" from scratch though. And, for certain "specific" things (for instance, picking a printer), I just create a dedicated form to get the work done.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,730

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    yeah. a msgbox is basically just a form, that we put on top of the main-form.
    I have added a few. mostly graphical. the latest is not even a form but just graphical. so I render on top of other stuff, but its still a msgbox.

  6. #6
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,477

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    The biggest problem I had with the MsgBox is that it halted execution until it was responded to. So I came up with a form that would show itself in the lower right corner of the screen. The user could simply click on the form or use the "Esc" key to get it out of the way, and it would return 20 seconds later. To get rid of it completely, the user would click on the "X".

    Code:
    Option Explicit
    
    Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    
    Private Sub Form_Click()
        Hide
    End Sub
    
    Private Sub Form_KeyPress(KeyAscii As Integer)
        If KeyAscii = 27 Then Hide
    End Sub
    
    Private Sub Form_Load()
        Me.Left = (GetSystemMetrics(16) * Screen.TwipsPerPixelX) - Me.Width
        Me.Top = (GetSystemMetrics(17) * Screen.TwipsPerPixelY) - Me.Height
        'Set Icon = frmTray.Icon
    End Sub
    
    
    Private Sub Label1_Click()
        Hide
    End Sub
    
    Private Sub Timer1_Timer()
        frmNotify.Show
    End Sub
    The border style I used was "3-Fixed Dialog".

    J.A. Coutts

  7. #7
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,709

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    The Task Dialog is a much improved message box... it can also display a simple message no more complicated than a regular messagebox by just using minimal options.

    I went a little nuts with a class that implements all it's features then bolts even more on top of it.

    If something is more complicated than a Task Dialog can handle... well it's just a form, not really a custom message box. I haven't really done anything beyond that which I'd still call a message box instead of just a regular form, tool window, or dialog. Though before Task Dialog existed, of course... regular message box was far too limited, even the extended versions from API calls.

  8. #8

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    Quote Originally Posted by fafalone View Post
    I went a little nuts.
    Bloody hell! You did, didn't you!

    That is impressive. I do wish I'd known about it before I rolled my own puny attempt. I searched for the wrong thing... probably "msgbox replacement".

    If I had known I would probably have used it, but then again, perhaps it would be massive overkill for my simple needs!

    I'll keep a note for it in future. I am sure there will be something I can learn from it.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  9. #9
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,709

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    That project was a followup to a much simpler version, if that's overkill. But of course, there's no need to use all the advanced options... it's still just a few lines to make a basic dialog once the class is added, e.g.

    Code:
        .Init
        .MainInstruction = "You're about to do something stupid."
        .Content = "Are you absolutely sure you want to continue with this really bad idea?"
        .CommonButtons = TDCBF_YES_BUTTON Or TDCBF_NO_BUTTON
        .IconMain = TD_SHIELD_WARNING_ICON 'TD_INFORMATION_ICON
        .Title = "cTaskDialog Project"
        
        .ShowDialog

  10. #10

  11. #11

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,250

    Re: VB6 QUESTION: How many here have rolled their own msgbox dialog boxes?

    In the end I rolled my own icons, a bit drastic but they look just as efficient as the originals when reduced to 48x48.



    Last edited by yereverluvinuncleber; May 25th, 2022 at 12:04 PM. Reason: Added smaller versions
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

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