Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2007, 02:38 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default drive from MessageBox Class

hi expert
how can i create class with driving from MessageBox Class?
is it possible?
regards
 
Old June 13th, 2007, 09:09 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

According to the MSDN documentation the MessageBox class is not sealed so you can extend it and do whatever you like with it.

-Peter
 
Old June 13th, 2007, 02:12 PM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i create class
my code is
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace favoriteMsg
{
    public class Class1 : System.Windows.Forms.MessageBox
    {

    }
}
i recive th flowing error from compiler

Code:
The type 'System.Windows.Forms.MessageBox' has no constructors defined
then i change my code to this
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace favoriteMsg
{
    static class Class1 : System.Windows.Forms.MessageBox
    {

    }
}
but i recive another error
Code:
    Static class 'favoriteMsg.Class1' cannot derive from type 'System.Windows.Forms.MessageBox'. Static classes must derive from object.
what is the problem ?:(
 
Old June 13th, 2007, 02:29 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Apparently the MessageBox class has no public or protected constructors, therefore you can not create an instance of it. Thus you can not extend the class.

Similarly a class modified as 'static' is not instantiable and can therefore not extend any class other than System.Object.

What exactly are you trying to do? Can you create your own class and just call the MessageBox methods from it?

-Peter
 
Old June 14th, 2007, 02:34 PM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no
i want to create my customize MessageBox form that able me to change the text of MessageBox Buttons
 
Old June 14th, 2007, 08:00 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Aha. Unfortunately, the messagebox class methods don't support the modification of the button text, just the ability to change which buttons and icons appear. You will have to create your own form to show as a messagebox.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
MessageBox Lalit Pradhan ASP.NET 2.0 Professional 1 July 5th, 2006 12:03 PM
MessageBox Ric_H General .NET 2 April 19th, 2006 01:45 PM
How to use MessageBox johnsonlim026 ASP.NET 1.0 and 1.1 Basics 7 June 17th, 2005 10:21 AM
How to find if drive is a mapped drive BrianWren Pro VB 6 1 June 2nd, 2005 04:07 AM
How to find if drive is a mapped drive BrianWren Access VBA 0 June 1st, 2005 04:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.