|
Hi All,
This might seem a bit simple but I have been using C# to create my ASP.NET applications and it has been going okay.
Now I am trying to create a windows application and have run into a problem.
I have a form called MainForm which has a button on it, when I click this button I want my other Form 'Form2' to open up.
How do I do this?
Thanks,
|
|
|
|
|
Hi,
Using your form2 as an example;
Form2 myForm2 = new Form2();
Form2.Show();
Cheers
Paul Mason
|
|
|
|
|
|
If you want to open it as a Modal Dialog
Form2.Showdialog()
or
Form2.Show()
to open it as a form (or no modal dialog)
Remember to reference your other form.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I am trying to port some C++ code from PC with some classes using MFC over to UNIX, I dont really want to re-write all of the MFC classes that it uses and was wondering if anyone has seen, these classes re-written in standartd c++
classes are:
CMapStringToPtr
CMapStringToString
CRect
CMapWordToPtr
CObArray
CPtrArray
CMapStringToOb
CObject
CStringList
CPtrList
CString
CMap
Clist
CArrayCInstructionList
any help with this would be greatly appreciated
michael.fellows@amsjv.com
|
|
|
|
|
Most of those are found in STL, which is what you will have to learn before porting.
Some have no direct companion, and you will have to write a port or change the code.
// Rock
|
|
|
|
|
How would I go about associating a shortcut key, say CTRL+F, with a button on a form so that the button's click event would fire when the shortcut key was hit?
|
|
|
|
|
Anyone know the code to make a program press the F1 key without touching the keyboard? In other words when I click a button I want the computer to respond as if I had pressed the F1 key. Any help would be appreciated.
Kyle
|
|
|
|
|
keybd_event(VK_F1, 0x45, 0,0);
keybd_event(VK_F1, 0x45, KEYEVENTF_KEYUP,0);
=================
Or something like that:
GL
Igor
|
|
|
|
|
Hi,
I am trying to send a list of urls to the clipboard from my app which will be caught by a download manager. I have got it to work with a single url no problem, but when I select multiple items (in a ListView) the app crashes after the first URL has been sent to the clipboard.
This is the code I am using;
public void mnuDownloadItem_Click(object sender, System.EventArgs e)
{
// Some variable declarations
int i = 0;
String sCurrentURL = "";
// This stops it crashing when the listView is empty
if (listView1.SelectedItems.Count != 0)
{
for(i=0; i < listView1.SelectedItems.Count; i++)
{
sCurrentURL = listView1.SelectedItems[i].Tag.ToString(); Clipboard.SetDataObject(sCurrentURL);
}
}
}
Would appreciate any help with this.
Thanks
Paul Mason
|
|
|
|
|
What exception is being thrown?
I see nothing wrong with your code as is; so the exception would help diagnose the problem
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
Hi,
First thanks for the reply! Secondly after some more experimenting I've found it isnt actually my application raising the exception, its external and is in the download manager (Flashget) which is catching the clipboard copies.
So Im wondering if its perhaps sending the copies too quickly for Flashget to catch them, would there be any way I can insert a short pause to test that?
Im sure its now pasting OK as I checked the last URL on the clipboard against my ListView and it matched.
Thanks Again
Paul Mason
|
|
|
|
|
Just need some advise:
I need to find possibility of converting existing pretty complicated MFC SDI Application, which is dynamic Control Container into C#?...
OK, it's enhanced version of MFC Application created by VisualStudio (MDI + Compound Document Both Container and Server + Active Document Server + Support for Compound Files + Automation + ActiveX Controls...
How and where should I start?...
Any recommendations or possibly samples??
Maybe it's wrong idea??...
Any views on that subject, please!!!
Thank you,
Igor
Happy Valentine
|
|
|
|
|
Hi guys, I'm trying to draw an icon onto the surface of a form. What I do is create the icon in the bitmap editor in VS.NET and then perform the following in my Form's code
private Icon myIcon
...
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
myIcon = ((System.Drawing.Icon)(resources.GetObject("icon1.ico")));
... myIcon however is always null
It's a simple matter I'm sure but I'm brain dead at the moment. How can I make sure that I have a valid icon instance in this case?
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Just looking at form designer generated code I get this:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
I seems like it gets the icon out of the associated resx file.
--
Peter Stephens
|
|
|
|
|
Thans, I'll give that a try
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
I have a P2P .Net Service that is connecting to another machines P2P .Net Service using Sockets. I would like both of these services to pass along a username and password so each P2P service can authenticate against the local security list. (win2k OS)
1) After getting the username and password from the other machine, what method/WIN API can I call to authenticate the remote user?
2) I’m apparently going to have to store the username and password somewhere on the remote machine. Any Ideas about the best (most secure) way of doing this.
a. Encrypt it to disk?
b. Registry?
Thanks in adance,
Brad Cooper
|
|
|
|
|
Hello there....
I am new to c# (and c like languages in general) and I am trying make a user defined control - essentially just a graphic with a few methods for moving it around and collision detection etc (guess what I am trying to write!).
So far I think I have got my head around overriding the onPaint method for my new control, and in this overridden method I construct a simple polygon out of an array of points. Now, I think I have conquered the collision detection (in a somewhat shoddy manner I am sure) but for can't work out how to make my control background transparent - the only part of the control I want displayed is the polygon, but instead I get the polygon and the control background (a grey rectangle or whatever colour I set it to).
My current investigations are leading me in the direction of Control.setStyle but can't quite get it right. Can anybody please help me?
Incidentally, I have tried setting the paintEventArgs.graphics.cliparea to be a region that matches the polygon, but I still get the graphics object background being displayed.
Write soon, and save me a headache.
Cheers,
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
I've just done a quick check and it seems user defined controls ie, anything derived from UserControl (or Control I think) cannot set it's BackColor property to transparent. Why not set the controls BackColor to be the same as the BackColor of the form containing the controls?
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Hi Senkwe,
Thanks for taking the time to help me. I have tried your idea but nfortunately your suggestion does not solve the problem.
My polygon represents an irregular shape - actually, an asteroid.
The foreground is, say, red - yes, a red asteroid (and why not?).
The background which c# paints it on is the same colour as the form (grey).
It is possible to change the background colour to black, green etc etc. When you do this, you get a red asteroid in a black (or whatever) rectangle.
When two asteroids overlap slightly the rectangle from one blocks out (is on top of) the other asteroid - this is my problem. All asteroid need to be drawn on a transparent rectangle so that their canvasses do not obscure each other.
If you look at control.settype, it seems there may be a way to make the background colour transparent, in fact I have managed this, however, the asteroid is redrawn very slowly.... here is some of the code from the constructor of asteroid:control
public asteroid(int startX, int startY, int incX, int incY, Form theForm)
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.backgroundColor = Color.FromArgb(1,Color.Gray);
...
I think I will tidy up my code and paste here for people to read. As an additional problem, when I am performing collision testing, I have a peculiar problem that seems to be inconsistent. When I create a rectangular region from my asteroid control, I can use region.isVisible(point) to test whether point is included in the region. This works. When I create an asteroid shaped region (instead of a rectangular shape), the call to region.isVisible(point) always seems to return false. Perhaps I am misunderstanding the region concept. Any ideas?
Jase
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
One thing that might speed up your drawing code is to enable double buffering, then all of your graphics drawing is done in system memory; then copied to video memory once; by passing the system->video bottle neck.
Hope that helps a little,
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
Thanks to the 2 people that helped me out. Neither solution really helped that much, but I did learn, so that's a good thing.
In the end, to remove background rectangles, I made one big background rectangle and drew everything on that, in other words, I painted everything on one canvas (instead of one canvas per game character). This seems to have done the job nicely.
If anyone wants to see the finished code, drop me a mail.
Jase
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
I want to buy two books:
One C# book, and one .NET book.
Which books should I choose?
|
|
|
|
|
Øyvind Bratland wrote:
C#
I have "Beginning C#" by "wrox".Thats average,not bad not excellent.
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I want "the ultimate" books, not average ones
|
|
|
|