|
thanks now only if that worked semi-accuratly for height
|
|
|
|
|
Everyone, I have a bug which doesn't seem to be related to my code (no, really! ) but instead to my configuration. The following line:
Application.Run(new MyApplicationWindow());
throws a NullReferenceException. The MyApplicationWindow constructor executes in full, and the exception is thrown from within Application.Run; here's the stack trace:
StackTrace " at System.Windows.Forms.SafeNativeMethods.ShowWindow(IntPtr hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
Interestingly, I have two identical copies of this solution on my machine. One is tied to source control, and one that isn't. The one not tied to source control runs without a problem, but the one tied to source control throws the exception. The code also runs just fine on coworkers' machines.
I've reinstalled MDAC 2.8 most recently, and I also upgraded to .NET 1.1. I'm using the 2002 version of Visual Studio.
Anything obvious come to mind? I appreciate any help I can get here.
Jerry
|
|
|
|
|
First, I need to mention that VS.NET 2002 will not compile 1.1 apps.
What's happening is the message loop is processing some message (probably WM_SHOW?) and it is being dispatched to your form and the appropriate methods are ran to process it. The ShowWindow method is trying to use a reference that hasn't been correctly initialized and is thus null. I see two possible problems: 1) Your code has a bug in the constructor or InitalizeComponent method that leaves some reference null that the ShowWindow method needs or 2) You have somehow manifested a bug in the framework either indirectly by your code or the controls you have placed on the form or by the configuration of your computer.
Here's what I would do. Comment out different things in the constructor and InitializeComponent method in a trial-and-error process seeing if that eliminates the problem. Try removing controls one at a time and see if that eliminates the problem. Try googling the usenet groups for the exception and stack trace you have provided to see if anyone else has encountered the same problem and what they did to solve.
Most importantly, if you find the problem post back and let us know!
|
|
|
|
|
How could I get the number of (local - belonging to the same application) forms on the screen ?
There is a class Screen at System.Windows.Forms.Screen but it doesn't hold any variable of visible forms on the screen (of the current application). If the class has nothing to do with forms then why is it under the FORMS.Screen namespace at all, rather that just Windows.Screen ?
Regards, Desmond
|
|
|
|
|
if i am not mistaken, there is nothing in "System.Windows" except the forms namespace...
this is probably because the current .net windows gui system is called "Windows Forms"
as to counting the number of open forms, why not either make an inheritable form with a counter to use in your applications, or increment and decrement a counter when you open/close forms....
other then that all i can think of is using EnumWindows in user32, and checking the window titles...
|
|
|
|
|
I think it's easier just to derive a class from System.Windows.Forms.Form, overload it's constructor and add there itself to a arraylist MyForms, or something like that. That way I also don't have to identify the forms (if they belong to me not another application on screen).
|
|
|
|
|
sure it
wasn't sure that was your goal
|
|
|
|
|
Anyone know where I can get icons to use in my app?
Most of what I need comes with XP so I'll use them but I need a few others aswell preferably with the xp look.
The smaller the mind the greater the conceit.
Aesop
|
|
|
|
|
A quick google reveals two stock icon sites:
http://www.iconpharm.com/
http://www.stockicons.com/
You buy the icons from the sites but they appear to have royalty-free distribution.
Sincerely,
-Ron
|
|
|
|
|
Thank you , they look good.
The smaller the mind the greater the conceit.
Aesop
|
|
|
|
|
http://www.iconarchive.com/
http://www.glyfx.com/
http://office.microsoft.com/clipart/default.aspx
|
|
|
|
|
those are much better links
Sincerely,
-Ron
|
|
|
|
|
Brilliant, exactly what I need, thanks
The smaller the mind the greater the conceit.
Aesop
|
|
|
|
|
Hi,
Does anyone know how to generate datagrid with dynamic no. of rows and columns that is specified in the database and each cell conataining check boxes.
I am trying to dispaly dynamic seating arrangement of theatre, needed for booking the tickets.
Any idea is appreaciated.
Ananth.
|
|
|
|
|
You could create a list of booleans and bind this to the DataGrid :
using System;
using System.Windows.Forms;
public class DGTest : Form
{
static void Main()
{
Application.Run(new DGTest());
}
public DGTest()
{
DataGrid dg = new DataGrid();
this.Controls.Add(dg);
DataGridBoolColumn boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Value";
boolCol.HeaderText = "Value";
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "DGValue[]";
tableStyle.GridColumnStyles.Add(boolCol);
dg.Dock = DockStyle.Fill;
dg.TableStyles.Add(tableStyle);
DGValue[] values = new DGValue[10];
for (int i=0; i<values.Length; i++)
values[i] = new DGValue();
dg.DataSource = values;
}
private class DGValue
{
private bool _Value = false;
public bool Value
{
get { return _Value; }
set { _Value = value; }
}
}
} There's also more documentation about this for the DataGridTableStyle.MappingName property in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, I have a question concenrning user defined app code. I want to allow my user define his own algorithms to add flexibility to the operation. Is there a simple way of compiling a C, C#, or VB etc. routine in CLR, and executing that? MS Office uses a scripting facility, but in the past that has been known to be rather slow! I was just wondering if it's possible, and if it is how fast will it be at raw number crunching in comparison to say C or C#?
Joel Holdsworth
|
|
|
|
|
Yes. Many of the languages expose CodeDOM compilers that are programmatically accessible and can be used to compile your code. There's several examples available throughout the web (like on MSDN), but you can find a good one right here on CodeProject, Dot Net Script[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm trying to figure out authentication using the HttpWebRequest class. When I try to connect to a resource that requires a password in IE, a dialog pops up where I enter that information. How can I implement the same behavior using HttpWebRequest? When I connect with that class, I receive a 401 not authorized error. Which is fine, but I can't figure out how to show the proper dialog.
Thanks.
|
|
|
|
|
If you get a 401, the correct procedure is to either pass credentials or prompt if you don't have them. So, lets say you have a while (or for) loop (it's good to terminate it at some point). If you get a 401, prompt the user with a Form you could easily create that asks for a username and password (don't forget to set the PasswordChar on the password TextBox ). Then, create an instance of an ICredentials implementation - like NetworkCredentials which is provided in the .NET base class libraries - and assign that instance as your HttpWebRequest.Credentials property. You may want to keep that once you get a 200 (or something besides 401 or another error) response.
If you're running on Windows XP or newer, you can use DPAPI to store the password, which is a Windows facility for storing network and Internet (including Passport) credentials. There's a pretty good article about it on MSDN at http://msdn.microsoft.com/library/en-us/dnnetsec/html/dpapiusercredentials.asp[^]. This isn't required for a solution, though, just more of a nicety for users (and alliviates the burden on you of securely caching passwords for remote resources if you choose to support it).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hmmm. The problem with that solution is that I really don't know what the server requires. The dialog that is displayed can be customized at the server level and I just want to display that one. Some will require the domain and some do not. I have no idea what to put on the form. The wininet dll just handles all of that for you. Isn't there a .NET equivalent?
|
|
|
|
|
The HTTP response will tell you what authentication is supported. That's the HTTP standard (most likely a different RFC - it's been a long time since I studied them). For example, Digest will also pass you a hashcode that you use with yours - can't remember off the top of my head how - and that you pass back to the server for verification and that it uses to verify the password (by performing the same hash and comparing).
You can use some of the other classes in the System.Net namespace, such as the AuthenticationManager , which automatically registers handlers for basic, digest, negotiate, NTLM, and kerberos. Look at the docs for the AuthenticationManager (the actual class documentation, or overview) for an example. Some of these things are handled for you but you still have to tell the HttpWebRequest what the credentials are, which requires that you prompt. Based on the HttpWebResponse.StatusDescription , you could customize your dialog accordingly (providing the basic REALM or something like that).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
friends , i has such problem now, help me plz
I'm going to program a webservice. Its my first time to code such project. i find that when i setup sql server2000 ,the setup progress reminds me that it will be only run on win 2000 system. i want to know that whether anybody who program a webservice project must use win2000 operation system or you can choose winxp? ps: my operation system is winxp. thank u for your help
|
|
|
|
|
Download and use the MSDE (Microsoft Data Engine) from http://www.microsoft.com/sql/msde[^] instead. In most ways, it is SQL Server, but with a limit on connections and lacking only a few features that you most likely won't use (IIRC, like DTS).
This is meant for - and commonly used for - development purposes and you can also distribute it with an application if you have a qualifying product like VS.NET, MS Access, MS Office, and a few others. You can read more about it at the link above.
Also, don't forget to download and install the MSDE Service Pack (SP) 3, which includes a fix for a bad RPC worm that is still seeking vulnerable systems. I forgot to patch one of our web servers once before co-locating and it got infect within 10 seconds of starting the SQL Server instance.
EDIT: Also, any databases you create in the MSDE can be attached to SQL Server. They are the same, in most respects. They support the same T-SQL and many of the same utilities. You can develop on the MSDE and easily move the database to a full-blown SQL Server later if you like.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you very much for your patient help i'll try MSDE. thanks
|
|
|
|
|
Hi,
I need to check a database at a set interval without holding up the rest of the program. Also, there is a client-server aspect to the program running over a network and I need to be able to send a message from server to client (using a message box popup on the client) without the server waiting for the client to press the 'OK' button before it can continue. Is this a case of using threading? Hope this makes sense,
Regards,
John
|
|
|
|