|
Ok....
Actually it is setup this way anyway
public class1
{
Form1[] myForms; //member variable array of Forms
public class1() //class1 constructor
{
myForms = new Form1[50];
myForms[0] = new Form1();
static void Main()
{
class1 myClass = new class1();
myClass.myForms[0].Show();
}
}
Still get blank form with hour glass
Am i doing something wrong
Kourvoisier
|
|
|
|
|
class Main : Form
{
private Form1 myForm;
Main()
{
myForm = new Form1();
myForm.Show();
}
}
Now when main us constructed, a member variable is initialised and shown.
kourvoisier wrote: Am i doing something wrong
I reiterate: your instance of class1 is local to a method, which means it has no persistent lifespan. You have a collection of forms as a member variable inside a class, but you've not made the instance of that class a member.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry sir
but your code above also gives the same exact blank screen with hour glass mouse over
maybe u should compile and run and see what i mean.
Christian Graus wrote:
class Main : Form
{
private Form1 myForm;
Main()
{
myForm = new Form1();
myForm.Show();
}
}
Now when main us constructed, a member variable is initialised and shown.
I really am trying to understand your concept and whats going on.
here you have created a class called main which implements form -- (dont know why it implements form)
You then create a member variable 'myForm' in the main class which is an instance of the Form1 class which is not shown(this class is the actual form i assume because this is what i meant in my code in earlier post)
Then u created the main class constructor which initializes myForm member variable then u call the
show method which should run the form.
Christian Graus wrote: Now when main us constructed, a member variable is initialised and shown.
Now where would you call the constructor for the main class to initialize and show the form which is the member variable.
Christian Graus wrote: I reiterate: your instance of class1 is local to a method, which means it has no persistent lifespan. You have a collection of forms as a member variable inside a class, but you've not made the instance of that class a member.
How do i make the instance of the class a member...i get confused here
(could you send me a visual c# solution source code to show me exactly how u do this
maybe if see the code of all this your saying in action i may be able to understand it better)
if you do this i would highly appreciate it
you can zip it and email to for_now_us@yahoo.com
|
|
|
|
|
kourvoisier wrote: but your code above also gives the same exact blank screen with hour glass mouse over
Yes, I always said that while your code was plain wrong, it was also true that the result I'd expect would not be the hour glass you're seeing.
kourvoisier wrote: I really am trying to understand your concept and whats going on.
here you have created a class called main which implements form -- (dont know why it implements form)
Here's the core issue. As someone else said, you need a message pump. The first step is to create a windows forms app, and then when you've got your main form class, you can create other forms off it, because you have a message pump going already.
kourvoisier wrote: How do i make the instance of the class a member...i get confused here
It's a member if it's declared in the class and not in the method, as in my examples.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
kourvoisier wrote: static void Main()
{
class1 myClass = new class1();
myClass.myForms[0].Show();
}
That is what is creating the problem. For a Windows application to run properly, it needs a message pump to process messages from the operating system. For the .NET API, Application.Run[^] does the message looping. In your program, you don't have a message loop and that is what is causing the problem. This code will help you get rid of the problem.
class1 myClass = new class1();
myClass.myForms[0].Show();
Application.Run();
However, it now becomes your responsibility to handle termination of the application. Application.Run will continue processing messages even if you've closed all the forms. Ideally, you'd have one main form, and from within that, launch other forms
static void Main()
{
Application.Run(new MyMainForm());
}
class MyMainForm()
{
private void MyMainForm_Load()
{
myClass.myForms[0].Show();
}
}
This way, when MyMainForm is closed, the application shuts down cleanly.
Either way, remember that all the forms share the same message loop, so if one of them is busy processing something, all the other forms will also appear to be hung.
To learn more about message pumps, you might want to read this[^] article.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
now i get it.....
thanks for the explanation makes perfect since to me....
especially the article...well put.
I will revise and run my code again i will let you guys know the results
You all have been of great help!!!!
Kourvoisier
|
|
|
|
|
My problem is solved i just needed a Application.run method there
so it can handle the form request(the looping message queue)
Awesome!!!!
im good to go
thanks Alot!!!
|
|
|
|
|
Hi do you know if exists any tools to automatically change Java code in C# code?
|
|
|
|
|
Please Help
I want my program be started up with windows.
and user must log in it first before working with any other program
|
|
|
|
|
You should be patient and wait for a reply before posting the same question over and over. Thats generally considered rude, and is generally bad netiquett.
You should be able to set your windows form to on-top in its properties in the VS.NET designer. You should also be able to set it to be maximized by default, too.
There isnt any way to prevent a user from ALT-TABbing to another app, though, at least as far as I know. The only thing I know of in windows that prevents someone from using apps or alt-tabbing is the main windows login screen. You might be able to hook into the alt-tabbing process and override it until someone logs in, but you would have to make sure you alert the users of your product that your doing so (leagally, otherwise your app could be considered spyware or a hyjacking program).
|
|
|
|
|
I want to make my program in the top ,full screen.
and user must log in it,
(i.e ,No "alt+tab")
|
|
|
|
|
shdelpiero wrote: in the top
this.TopMost = true;
shdelpiero wrote: full screen.
this.WindowState = FormWindowState.Maximized;
"The Soapbox has been so ..."
|
|
|
|
|
What i am trying to do. When a user mouse clicks on a label control, label changes color. If user continues to holds down mouse button and moves over other labels (a click and drag), those labels will change to same color.
How does one detect when the mouse cursor is leaving and entering label controls during a click and drag scenario? I have tried MouseEnter/MouseLeave and DragEnter/DragLeave and the events do not fire when one clicks and drag.
Any suggestions what i should be looking at? I am stumped.
Thanks.
|
|
|
|
|
You will need to do a couple things. First, you will need to set .AllowDrop on each label to true, so that they can accept a drop. By default, most controls ignore drops.
Second, you will need to capture the drag action on the source label (the one being dragged) by calling .DoDragDrop (from Control.DoDragDrop), and writing event handlers for DragOver, DragEnter, DragLeave, DragDrop events for each label to accept a drop and respond to it.
|
|
|
|
|
Thanks Jon. I was able to figure out drag-and-drop from your hints. I found that drag-and-drop is not giving me the right solution as i had thought. I am going to repost question with a different focus. Thanks for the help.
|
|
|
|
|
OK, I have created an AddIN for MS Word, which takes the content of the document, and saves it to a variable...
Microsoft.Office.Interop.Word.Application my_app = (Microsoft.Office.Interop.Word.Application) applicationObject;
Microsoft.Office.Interop.Word.Document my_doc = my_app.ActiveDocument;
my_doc.Select();
my_app.Selection.Copy();
string myText = my_app.Selection.Text;
(the above code works great)
I tried using the Navigate() to send the data to our web application, but I am unable to retrieve it when the Webpage opens:
string strPostData = "SomeData=" + myText;
object strPostHeader = "content-Type:application/x-www-form-urlencode";
string strLocation = "http://mysite.devsite.com/zTest.cfm";
object strTarget = "_BLANK";
System.Object null_obj = 0;
byte[] results;
results = UnicodeToAscii(strPostData);
SHDocVw.InternetExplorer webPost = new SHDocVw.InternetExplorer();
webPost.Navigate(strLocation, ref null_obj, ref strTarget, ref results, ref strPostHeader);
****This is the conversion method*****
public byte[] UnicodeToAscii(string src)
{
int len = src.Length;
byte[] result = new Byte[len + 1];
for (int i = 0; i < len; i++)
result[i] = Convert.ToByte(src[i]);
result[len] = 0;
return result;
}
I keep getting "Argument 4:cannot convert 'ref byte[]' to 'ref object'"
and if I just cast strPostData to an object, the Webpage loads, but nothing is passed in...
Confused? Yes!
|
|
|
|
|
use marshal class
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Hi All,
I am trying to do the following in a web control that I am creating:
I have a username and password textboxes and a login button.
when the user is in the password textbox and if they hit <enter> I want either one of the following two behaviours to happen:
1. do nothing, or
2. automatically fire the login button's clicked postback event
Right now when a user hits <enter> it loses focus from the textbox and does nothing! (If it is doing a postback then what event is it firing!!!)
This is driving me crazy!
any help would be greatly appreciated!
schoudhr@hotmail.com
|
|
|
|
|
Hi All,
I am trying to do the following in a web control that I am creating:
I have a username and password textboxes and a login button.
when the user is in the password textbox and if they hit "ENTER" I want either one of the following two behaviours to happen:
1. do nothing BUT don't lose focus on the textbox either!, or
2. automatically fire the login button's clicked postback event
(#2 is preferable)
Right now when a user hits "ENTER" it loses focus from the textbox and does nothing! (If it is doing a postback then what event is it firing!!!)
This is driving me crazy!
any help would be greatly appreciated!
schoudhr@hotmail.com
|
|
|
|
|
If you are talking about a C# Windows application then here's an idea, may give you a place to start.
this.txtPassword.KeyPress +=
new System.Windows.Forms.KeyPressEventHandler(this.txtPassword_KeyPress);
.....
private void Generic_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar == (char)13)
cmdLogin_ButtonClick(this, EventArgs.Empty);
}
|
|
|
|
|
Hello folks!
I need an help with the ascii code.
I must convert a number in the corresponding ascii symbol. Now, from the number 32 to the number 127 it works; but after that, it returns sometime the char '' and sometime a strange symbol which doesnt coincide with the one in the ascii table.
How can i solve?
ps: i write the symbol in a textBox if it can help...
Thank You
Enrico
|
|
|
|
|
ASCII is a 7 bit code, values 128-255 are undefined in it. There are multiple 8 bit extended ascii encodings. The default in .net is apparently different than the one used in what your reference is erroniously calling ascii. YOu'll need to find the ISO number for the encoding you want and set your app to use it instead.
|
|
|
|
|
Can you explain better what u mean for ISO?
I dont know what u are saying...
|
|
|
|
|
Bascially a sequence of bytes only makes sense as a text file in connection with a code page (and encoding).
The code page define which character is at which integer position, while the encoding determines how the number is stored in the byte stream. Rememeber that it was only back in the dark ages people thought 256 charactes where enough, so you need a way to store for example character 7625 (what it is I do not know - that depends on the code page).
You mention you use the ASCII table. As correctly pointed out, the ASCII table only defines characters in the range 0-127. So if you have anything in the 128-255 range, it is certain you are not loading ASCII, but something else.
As the .NET framework obviously use Unicode internally (stored in memory with a UTF-16 encoding) it will need to know how to map the byte stream into characters. This is done with an Encoding (see System.Text.Encoding). So with "ISO" in this case is ment you need to know the encoding so you can specify it to the loader.
You can try using the Default encoding - it is the dafault ANSI encoding on the system so it is what outdated programs would use when processing text. While no modern program should touch ANSI encoding with the water from a remote controled fire hose - except when loading outdated dataformats - it is still commonly used, mainly due to ignorance from developers. The ANSI code page can be changed from the control panel, effectively changing the content of all you text files (start to see why no sane person would use it)?
If ANSI does not load, you can try UTF-8 - and if that won't work either you have to find a way of identifying the code page (to use as a parameter in a call to GetEncoding)... You can try loading the file in Word, it tend to give a fairly good guess.
|
|
|
|
|
Is there a nice way to do this so I could dynamically resize the leftmost column when a V scroll appears to avoid creating an hscroll bar as well?
Theoretically I could use the Graphics class to measure the string height and use that to compute how many lines would fit, but I'd prefer a more natural solution.
|
|
|
|