Creating a MessageBox in a Windows 8 Store app - Sample-VBForums
Results 1 to 6 of 6

Thread: Creating a MessageBox in a Windows 8 Store app - Sample

  1. #1

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Cool Creating a MessageBox in a Windows 8 Store app - Sample

    Hello.

    Once I figured out how to create a message box in a Windows 8 Store app, I made myself a new class that allowed me to easily create message boxes using the way I had always done so in all of my WinForm applications. I have attached this class so that others can use it in the hopes that it makes programming a Windows 8 app easier.

    Take the attached class file and add it to your solution. CustomMessageBoxClass.vb

    Then you can easily create a message box using code from these examples:

    Code:
        Private Async Sub btnTHREE_Click(sender As Object, e As RoutedEventArgs) Handles btnTHREE.Click
            Dim xMsgBox3 As New EnhancedMessageBox("Shall I format and re-install the operating system?", "Start Over", MessageBoxButtons.OkCancel)
            Dim xResult3 As DialogResult = Await xMsgBox3.ShowDialog
            If xResult3 = DialogResult.OK Then
                lblButtonThreeResult.Text = "You have agreed to re-install the OS."
            Else
                lblButtonThreeResult.Text = "You clicked the Cancel button."
            End If
        End Sub
    
        Private Async Sub btnFOUR_Click(sender As Object, e As RoutedEventArgs) Handles btnFOUR.Click
            Dim xMsgBox4 As New EnhancedMessageBox("Hurry and click the Yes button!", "", MessageBoxButtons.YesNoCancel)
            Await xMsgBox4.ShowDialog
        End Sub
    Note #1: Yes I realize that the new method of creating a message box in much more versatile. This is not meant to stop anyone from using the new method. This is simply an aid to help people like myself who struggle to get some of the basics figured out.

    Note #2: I built and tested this on Windows 8.1 using Visual Studio 2013, as a Windows 8 Store app. I have not tested it as code for a Windows Phone 8 app.
    ~Peter


  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,295

    Re: Creating a MessageBox in a Windows 8 Store app - Sample

    I built and tested this on Windows 10 using Visual Studio 2015, as a Universal Windows app running on Lumia 640 XL phone, only message box with two buttons can be shown, if three buttons specified, the message box doesn't appear at all and the code after Await xMsgBox.ShowDialog executed!



  3. #3

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Cool Re: Creating a MessageBox in a Windows 8 Store app - Sample

    Hi 4x2y.

    I tried my revised Windows 10 (UWP) version, and yes, you can only use 2 buttons on Windows 10 Phone. I'm guessing it's a limitation built into the MessageDialog class for mobile devices. Nice job discovering that!

    In reality, a message box should just be used as a boolean (ie: do you want to save? yes or no). If you're asking something with 3 answers, you should probably be using a radio button or a list box.
    ~Peter


  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,012

    Re: Creating a MessageBox in a Windows 8 Store app - Sample

    That's debatable... "XYZ has been modified, do you wish to save before exiting?" - yes, no, cancel... then again, I think about all the mobile apps I use, how they work... don't really know that I've ever seen a three option dialog anywhere.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,295

    Re: Creating a MessageBox in a Windows 8 Store app - Sample

    I think it is limited to two buttons only for mobile apps because the device's Back button is used to cancel the message box.



  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,012

    Re: Creating a MessageBox in a Windows 8 Store app - Sample

    Yeah, I kinda realized that after the fact. ;P

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.