Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:07:42+00:00 2026-05-24T08:07:42+00:00

How does .NET’s MessageBox determine its size relative to the resolution of the screen

  • 0

How does .NET’s MessageBox determine its size relative to the resolution of the screen on which it is displayed?

I am writing a slightly more flexible dialog window for a WPF application. The layout of the window is layed out in a Grid:

+-----------------
| auto: Header      // A header for the dialog.
+-----------------
| auto: Content     // can be any FrameworkElement.
+-----------------
| auto: BottomPanel // With buttons <OK>, <Cancel>, <Delete>, etc. 
+-----------------

The Contentcell can be VERY large. In one of my use cases, the user wants to delete x elements from a list. The elements are then listed in the confirmation dialog. If there are many (let’s say 50+) elements, the window can get large—too large for my taste.

What I would like is a function that determines the MaxHeightand MaxWidthproperties of the dialog window from the current screen in a way that mimics Microsoft’s own MessageBoxdialog.

PS: I invoke the message dialog with the following static method:

// MessageDialog class
public static object Show(
        Window owner, 
        FrameworkElement content,
        string title,
        string header,
        params MessageDialogButton[] buttons
        );
/* The MessageDialogButton class has the following properties: 
 * Text, ReturnValue, IsDefault, IsCancel. The class produces 
 * System.Windows.Controls.Button objects that when clicked 
 * return the value of their ReturnValue property--which is then
 * returned by MessageDialog::Show(...)
 */

PPS: To determine the screen on which to display the dialog, the screen on which the MessageDialog window’s Owner is located. As a fallback, the first (primary) screen is used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:07:43+00:00Added an answer on May 24, 2026 at 8:07 am

    You aren’t going to find anything like that documented, however according to Raymond (outdated link, this link is more recent) in Windows Vista the message box algorithm determined the width of the message box by choosing the smallest of the following which resulted in a box that fits in the working area:

    • The width of the longest line
    • 278 DLU (Dialog units)
    • 5/8 of the width of the working area
    • 3/4 of the width of the working area
    • 7/8 of the width of the working area

    (I interpred this to mean that (for example) the width will be 5/8th of the width of the working area unless this results in the dialog which is taller than the height of the working area, in which case it will use a wider width).

    This should at least give you some pointers for choosing a maximum width that doesn’t look out of place.

    As far as I am aware the message box doesn’t have a maximum height, but I imagine a similar algorithm would work nicely.

    If your dialog genuinely is very large then you might want to consider just making the dialog resizable / maximizable. (I’m not a fan of dialogs that display lists that are too large but don’t allow you to resize the dialog to a more suitable size).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does .net have a way to determine whether the local filesystem is case-sensitive?
Does .NET have anything similar to Perl arrays, which are indexed numerically but automatically
Does .NET detect and use Hardware Cryptographic Accelerator for its cryptography operations (the way
Does .NET already include something which I can use to prevent selection of a
When I use the foreach statement in C# .net, how does .net determine in
Does .NET come with a class capable of representing extremely large integers, such as
Does .NET Compact Framework 3.5 work on Windows Mobile 2003 SE without limitations?
Does .NET have some type of built in function that allows filtering on Gridviews?
Does .NET natively support anything similar to PHP's variable variables ? If not, how
Does .NET 3.5 provide any build-in support for charts and graphs for Windows Forms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.