|
Application.Run(form) shows the form, runs a message pump, and waits until the form gets closed.
it exists in the Main() method of most WinForm applications.
I've never used Application.Run() without form.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
I'm guessing it tells an Application to Run, but some context might be helpful.
|
|
|
|
|
|
I'll wait for the OP to give context; it could be some wacky WidgetCo.Application.Run .
|
|
|
|
|
You're not the adventurous type then?
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Jumping to conclusions doesn't pay.
|
|
|
|
|
|
How do you know that's what the OP means?
|
|
|
|
|
|
|
Windows is basically a message-driven system. Unlike the programming model we get to play with, where we "receive events" when they occur, each application actually has to make system calls to get messages for the application from the system. These messages are generated by the OS and/or other programs and represent information such as a key changing state from up to down, the mouse moving, the program needs to redraw itself, and a gazillion other things.
So crudely put, and surely leaving out lots of detail, the Run() method displays the form passed to it, implements a loop that calls the Windows GetMessage() function and processes the messages in the queue. Messages received will be passed to relevant controls and the controls in turn raise events, providing us with a way of plugging our custom code into this loop. When the application receives a WM_CLOSE message or the form closes, the loop terminates and the Main method returns, terminating the program.
This is also why normal Windows Forms apps are terrible for implementing things like games. The GetMessage() function blocks when the message queue for an application is empty, which is very good when the application *is* event-driven and doesn't need to do anything other than in response to some external event - because it let's Windows allocate CPU to other programs that do have something in their message queue. Games however need to keep working and drawing and calculating object movements and so on even if there are no external events. They therefore implement the message loop a little differently, calling the system function PeekMessage() instead, which never blocks but returns immediately even if there are no messages. That's great for games, but it also explains why games are so unfriendly multi-taskers - they always take a lot of resources.
A digression if I may: Unfortunately this does make some seemingly simple things a bit tricky to implement in Windows Forms apps. For example, let's say you want to do something *while* a mouse button is pressed, as opposed to in response to the transition from up to down or down to up. You could do this with a timer (which is a WM_TIMER message - the lowest-priority message of all Windows Messages), but it wouldn't be very nice. You might have to start another thread doing the work when the button is pressed and cause it to stop when the button is released, but that's a bit complicated too, because the controls are not thread-safe so this other thread can't update anything in the UI, but instead has to marshal calls back to the UI thread to do the updating... Of course, if the control had an event that fired on every iteration of the program loop as long as the mouse button is pressed this would solve the problem, but generally the controls don't have any such events!
|
|
|
|
|
Hello.
Is it possible to create a program in c#, so when you log on with your username and password, to a forum, so can i create what the user can do.
Also make so he can write on forums and so on.
Also a "virtuel" browser in the program?
-Ahlm
|
|
|
|
|
The question is not clear to me. Are you talking about a keylogger ??
|
|
|
|
|
No i ain't.
Well. Let me tell you a bit detailed then
You know EX. The code prjects login bar?
I want to make a program, where i can login with my program, and be logged in, in the program.
So can i design something with messageboards and so on, in the program, if you are logged on.
I hope you can understand me now
|
|
|
|
|
Hey,
I think CodeProject puts an authentication cookie in the browser, so that whenever the user comes back to the site, it checks if auth cookie is there in the browser and tries to authenticate with it.
so in your case, I think you need to do something like this.
Use
Response.Cookies["uid"].Value = userid;
Response.Cookies["pwd"].Value = passkey;
And whenever the login page is requested, first check
Request.Cookies["uid"].Value
Request.Cookies["pwd"].Value
and try to authenticate with them. If not successful show the login screen, otherwise show the home screen for that user.
Note :
It is always better to have this optional, as you might have a checkbox for Remember Me, to put the cookie in the browser.
|
|
|
|
|
Are you really serious when you say that CodeProject puts the password in the Session ?
|
|
|
|
|
Have I ever told you about storing password in session ??
I used the term cookie rather than session.
Most of the sites even Yahoo / google stores Authkeys in cookie fields once you choose "Remember Me". A warning is also put below the Remember me checkbox telling you not to check if you are in a shared computer.
In case of mozilla, passwords gets stored in browser too, obviously if you choose so.
Just open Tools -> Options -> Security ->Show passwords
This is actually browser password storage.
For your solution, you can also generate an Auth key which remains in database, store it in cookie. When the user navigates to the page, just get the auth key from cookie and then check with the auth element in database. Based on this you make the user authenticate (so you dont need password)
Hope you got the trick.
|
|
|
|
|
To me it sounds like a spammer, not a keylogger.
A program that can log in to forums and post messages on behalf of the user... Of course, he could just mean "a browser", or user-agent as it's more formally called!
In any event, if this interpretation is correct then yes, surely it's possible, at least if the site has no mechanisms to prevent programs from accessing it, such as CATCHPAs. But it isn't *easy* because it's an interface designed for humans and not programs. And it's not reliable because the interface might change at any time, and making a program interpret and understand the changes isn't easy. A browser only needs to understand how to display pages and how to post forms (well, there's a bit more to it but leaving aside scripts and plugins for the time being it is conceptually like this) and can rely on the human user to understand how to use the interface. An automated client has to either be intelligent enough to work out how to do so or make assumptions about what the requests it generates should be like.
If the site doesn't have any anti-bot measures (some use tests that aim to see if the client is a real browser as a less intrusive alternative to CATCHPAs, such as testing DOM functionality or JavaScript execution) at all, the easiest is probably to use an HTTP request analyzer (such as Fiddler) to see what requests are actually sent when you use your browser, and write a program that sends the same requests. Obviously this is likely to break as the site in question changes, but there's no way around that unless you solve problems the AI community are nowhere near solving after 50+ years of research. (Perhaps Jeff Hawkins and Numenta are closer though; at least their approach to machine intelligence seems to hold a lot more promise.)
|
|
|
|
|
I want to know how to do it, because i will get login to a website with username and pass, but design my own interface
|
|
|
|
|
On a new windows form app, I have this code:
public Form1()
{
InitializeComponent();
this.AutoScroll = true;
for (int i = 0; i < 500; i++)
{
Button btn = new Button();
btn.Text = i.ToString();
btn.Height = 100;
btn.Dock = DockStyle.Top;
this.Controls.Add(btn);
}
}
so I should get 500 buttons, 100px height each on a scrollable form. However I don't, I get the following:
http://img204.imageshack.us/img204/2564/22179761.png[^]
however, if my scroll bar is NOT at the top, and I resize the form a little bit, everything shows up. Any ideas? Thanks.
edit: the height before the form cuts off controls is around ~32 800px.
|
|
|
|
|
Long ago, parts (or all?) of GDI was using 16-bit integers, limiting Form height to 32767. Seems like some of that is still in there somewhere. Anyway, you should not have huge Forms, nor hundreds of Controls, it will never be an attractive GUI.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Luc Pattyn wrote: Anyway, you should not have huge Forms, nor hundreds of Controls, it will never be an attractive GUI.
This is the critical point!
And while we're at it, let's stop making interfaces that load all twenty thousand rows into a datatable before the page displays and the user can perform a search... it's kind of silly to spend all those resources and make the user wait when with this much data it is virtually guaranteed that the user *will* need to search and thus discard the expensively-obtained results immediately.
Just a sigh... I see this all the time, unfortunately.
That having been said, if MS Word had only 500 buttons it would have been a lot easier to use....
|
|
|
|
|
i found my problem
my problem is the application is not read the connection string in app.config so when i start with debugging, it is all write but when start without debugging the exception is thrown
another thing
when i clear the comming from machine.config as the following code
<configuration>
<clear/>
<connectionStrings>
<add name="ConnectionString"
connectionString="Data Source=.;Initial Catalog='Computer Sales System';Integrated Security=True"/>
</connectionStrings>
</configuration>
the exception is thrown in both sides
so
i understand that the connection string in app.config is not read by application
so i want to know why???????? and what is the solution for this problem
thanks
|
|
|
|
|
Don't use app.config -- write your own configuration file.
|
|
|
|
|
<clear/> should appear between <connectionStrings> and </connectionStrings>
|
|
|
|
|