|
If I understand your question correctly, it should be pretty simple. Just add a new form to your app and make sure the new form is derived from System.Windows.Forms.Form. This would be like adding a new dialog which is derived from CDialog in C++.
Hope this helps.
|
|
|
|
|
Thank everybody!! But, I mean I don't want to appear a form handle "button" on tne operation system (ex WindowsXP)' toolBar !( usually appear on tne bottom of screen, if you create a application program!), If I create a Dialog inheritance Form, what kind of method can I use ?? or I should inheritance other something ??
|
|
|
|
|
I have constructed many dialogs in my apps where I would do the following:
Build the dialog as a form within the project
Fill out the dialog box with everything I wanted to collect form the user.
Expose those items with public accessors
Add an Okay button which sets DialogResult = DialogResult.OK; etc.
(example: AskForFiles has englishDict frenchDict and germanDict exposed as public accessors. The user can click buttons to browse for the dictionary files in the dialog)
In my main program I then add this code:
AskForFiles newDialog = new AskForFiles();
if (some file names already defined)
{
newDialog.englishDict = value;
newDialog.frenchDict = value;
newDialog.germanDict = value;
}
newDialog.ShowDialog(this);
if (newDialog.DialogResults == DialogResults.OK)
newFileName1 = newDialog.englishDict;
...
This way you can issue a dialog, get the results from that dialog, with OK indicating they set all the values and Cancel indicating they changed their minds. You need to make sure you never issue a return without a this.Close() and setting this.DialogResult.
I also make the form properties for Abort and Accept set to the corresponding buttons on the form so any key input creates the desired results as well. For example: the user enters all dictionary names and hits enter is the same as clicking the Okay button. the user hits Esc is the same as clicking the Cancel button. etc...
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
...on the other hand...
If you want to issue an OpenFileDialog then that is simpler:
add OpenFileDialog from the toolbox to your form
then in your code your issue:
OpenFileDialog1.ShowDialog(this);
which is much easier if that is all you want to do.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hi all,
I'm trying to learn C#. I know C. Are there any links where I can get some tutorials / info.
names of a couple of good books would also help?
thanks
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
Inside C#, Second Edition
by Tom Archer
is a very good book for learning and understanding C#
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
parths,
C# Essentials from O'Reilly for $25 bucks is well worth it. It's thorough for a small book, provides concise descriptions, and has lots of small examples.
-- James --
|
|
|
|
|
Thanks Micheal, James,
I'll go get one of those books. Thanks a lot.
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
hello,
here is a little problem that i am facing at now.
on getting the html of a web page, i am getting some strange characters in place of space.
this is what i have in the text box (on web page).
Xavor Corp.
Katharine Yau
and this is what i get in the html source.
"Xavor%2520Corp%252e%02Katharine%2520Yau"
how can i remove these %2520 sort of characters.
LOOKING FOR HELP
ASIM
Asim
|
|
|
|
|
This is standard.
Any non-ascii characters are being Encoded.
use Uri.Unescape
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
HTTPUTILITY.decode();
this worked in my case.
THANKS
ASIM
Asim
|
|
|
|
|
i face some problem in developing a simple file encryption/decryption by using RSA algorithm.
i fail to read private key from a file.
here is my portion of code in saving the private key:
------------------------------------------------------
private void WritePrivateKeyToFile(RSAParameters param, string fileName)
{
FileStream fs = File.Create(fileName);
fs.Write(param.P, 0, param.P.Length);
fs.Write(param.Q, 0, param.Q.Length);
fs.Write(param.D, 0, param.D.Length);
fs.Write(param.DP, 0, param.DP.Length);
fs.Write(param.DQ, 0, param.DQ.Length);
fs.Write(param.InverseQ, 0, param.InverseQ.Length);
fs.Write(param.Exponent, 0, param.Exponent.Length);
fs.Write(param.Modulus, 0, param.Modulus.Length);
fs.Close();
}
------------------------------------------------------
however, something goes wrong with reading the private key:
------------------------------------------------------
private RSAParameters ReadPrivateKeyFromFile(string fileName)
{
RSAParameters param = new RSAParameters();
FileStream fs = File.OpenRead(fileName);
fs.Read(param.P, 0, param.P.Length); //large prime
fs.Read(param.Q, 0, param.Q.Length); //large prime
fs.Read(param.D, 0, param.D.Length); //private exponent
fs.Read(param.DP, 0, param.DP.Length);
fs.Read(param.DQ, 0, param.DQ.Length);
fs.Read(param.InverseQ, 0, param.InverseQ.Length);
fs.Read(param.Exponent, 0, param.Exponent.Length);
fs.Read(param.Modulus, 0, param.Modulus.Length);
fs.Close();
return param;
}
------------------------------------------------------
the above function was called inside a method named:
------------------------------------------------------
private void RSADecryptFile(String sInputFilename, String sOutputFilename)
{
FileStream fsread = new FileStream(sInputFilename, FileMode.Open, FileAccess.Read);
FileStream fsDecrypted = new FileStream(sOutputFilename, FileMode.Create, FileAccess.Write);
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
// Read the file text to the byte array.
byte[] bytearrayinput = new byte[fsread.Length];
fsread.Read(bytearrayinput, 0, bytearrayinput.Length);
RSA.ImportParameters(ReadPrivateKeyFromFile(sOutputFilename+".rsa.private"));
RSA.ImportParameters(ReadPublicKeyFromFile(sOutputFilename+".rsa.public"));
byte[] RSAOutput = RSA.Decrypt(bytearrayinput, false);
// Write out the DES encrypted file.
fsDecrypted.Write(RSAOutput, 0, RSAOutput.Length);
fsDecrypted.Close();
fsread.Close();
}
------------------------------------------------------
i obtain the error state that "Object reference not set to an instance of an object" which occur at line fs.Read(param.P, 0, param.P.Length) in method ReadPrivateKeyFromFile.
i was wondering whether u can give me any suggestion how can i solve this problem?
thank you.
regards
yccheok
|
|
|
|
|
how do i read a minimized form/window into a bitmap?
|
|
|
|
|
Can anybody show me in steps by steps how to upload a
.NET web application/ web service into a webhost/webserver? I have no idea on how to do this.
Help me out, pleasee!!!!
|
|
|
|
|
Can anyone suggest the best way to constrain a form to horizontal resizing only?
Delegating a Resize handler doesn't work so great. If I set Height=400; in the Resize handler, it does indeed force the window to a height of 400 (or whatever you like) but when the user drags the window border, the window momentarily resizes to fit the mouse, and then the handler kicks in and pushes it back to 400 and back and forth causes a nasty flicker.
I've seen some Win32 examples that process WM_NCHITTEST messages and return 0; but I don't see a way to do this with C# .NET Framework. Any ideas?
-- James --
|
|
|
|
|
Have you looked at the MinimumSize/MaximumSize properties?
You can also check for the WM_GETMINMAXINFO message.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
set the maximumsize.Height and minimumsize.Height Form properties to 400.
The user will not be able to resize the form vertically (less than 400).
|
|
|
|
|
Thanks Jim Stewart and peenu for the help! I see there are a lot of properties I overlooked. The MaximumSize and MinimumSize properties did the trick:
this.MinimumSize = new Size (400,400);
this.MaximumSize = new Size (1280,400);
-- James --
|
|
|
|
|
This will help you manage all those brushes and pens you so relentlessly create without disposing of them correctly. YES YOU!!!
public class GDIBuffer
{
static Hashtable pens = new Hashtable();
static Hashtable brushes = new Hashtable();
public static Brush GetBrush(Color color)
{
if (!brushes.Contains(color))
brushes.Add(color, new SolidBrush(color));
return brushes[color] as Brush;
}
public static Pen GetPen(Color color)
{
if (!pens.Contains(color))
pens.Add(color, new Pen(color));
return pens[color] as Pen;
}
public static Pen GetPen(Brush brush)
{
if (!pens.Contains(brush))
pens.Add( brush, new Pen(brush));
return pens[brush] as Pen;
}
public static Pen GetPen(Brush brush, int width)
{
Tuple t = new Tuple();
t.left = brush;
t.right = width;
if (!pens.Contains(t))
pens.Add( t, new Pen(brush, width));
return pens[t] as Pen;
}
struct Tuple
{
public object left;
public object right;
}
}
Now instead of calling new Pen/SolidBrush , just call the buffer.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Wrong! but can be used.
in net we have such classes: SystemPens, SystemBrushes and etc.
Your class does not check is requiered Pen or Brush can be replaced by System version, which are exist as singleton instance for hole application and does not use additional GDI Objects.
Good Luck
Alex Kucherenko
|
|
|
|
|
I have a question about these System Objects. What if the user changes his/her properties in Display Settings while the app is running? Do these colors change?
Quote from MSDN:
"Public Properties:
ActiveBorder: Gets a SolidBrush object that is the color of the active window's border.
ActiveCaption: Gets a SolidBrush object that is the color of the background of the active window's title bar.
ActiveCaptionText: Gets a SolidBrush object that is the color of the text in the active window's title bar. "
To me this would imply that the colors are changing. But then again I have been known to be wrong at times.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Try to search more in MSDN.
look into Brushes.Black
Good Luck
Alex Kucherenko
|
|
|
|
|
Ahhh, ok... That makes sense.
Thanks,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
|
Alex Kucherenko wrote:
Wrong!
Why?
Alex Kucherenko wrote:
in net we have such classes: SystemPens, SystemBrushes and etc.
Your class does not check is requiered Pen or Brush can be replaced by System version, which are exist as singleton instance for hole application and does not use additional GDI Objects.
Thats exactly what I am simulating...and those singletons DONT exist unless they are used.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|