• What are you working on? V5
    2,005 replies, posted
[QUOTE=Ortzinator;18914877]Having trouble with MDI and OnFormClosing. My question is here: [url]http://stackoverflow.com/questions/1894985/how-to-properly-prompt-the-user-when-closing-an-mdi-form-and-children[/url][/QUOTE] Cant you pass an "IsParentClose" variable in the OnFormClosing function and only prompt from the child if it's false or empty?
The childrens' OnFormClosing is called before the parent's, that's the problem.
I think its because MDI children are (in microsoft's eyes at least) designed to be their own little mini-application just to save you re-creating a UI on each form.
[QUOTE=nullsquared;18909944]Go to projecteuler.net and start doing all the problems sequentially. It's quite a bit of fun, just try to resist looking up the answers.[/QUOTE] Thanks =) Oh jeez, these look difficult =P [QUOTE=jmanmc;18914177]Another good "practice" site for programming would be codechef.com. Although I think it is indian.[/QUOTE] I'll check it out as well. Thanks.
windows 7 it should come out soon [highlight](User was banned for this post ("If you don't have anything to add that is relevant to the topic please do not post." - verynicelady))[/highlight]
[QUOTE=ProboardslolV2;18919850]windows 7 it should come out soon [highlight](User was banned for this post (\"If you don\'t have anything to add that is relevant to the topic please do not post.\" - verynicelady))[/highlight][/QUOTE] jesus christ vnl dont get your twat in a spot [highlight](User was permabanned for this post ("thats VNL you're talking to" - garry))[/highlight]
[QUOTE=DoritoBanditV2;18920716]jesus christ vnl dont get your twat in a spot[/QUOTE] Thank you for the advice. How did you get those back slashes in your quote? They aren't in my original ban. Perhaps it's your browser? By the way, please post on topic from now on - or you will be banned too.
It means he's using a (badly coded) proxy
[QUOTE=garry;18922333]It means he's using a (badly coded) proxy[/QUOTE] or they've got magic quotes on, which is terrible and only exists for bad coders who can't use mysql_real_escape_string()
I'm proud of myself, I coded a console/chat thing =) It has commands and stuff. Also question. What's the code that I can use to execute a block of code if a key is pressed or something? C# by the way.
[QUOTE=Scoooooby;18922607]I'm proud of myself, I coded a console/chat thing =) It has commands and stuff. Also question. What's the code that I can use to execute a block of code if a key is pressed or something? C# by the way.[/QUOTE] [cpp]if(checkForKeyOrSomething) { //code }[/cpp] ? I think you should rephrase your question. It's not quite clear what you want.
[QUOTE=Robber;18923033][cpp]if(checkForKeyOrSomething) { //code }[/cpp] ? I think you should rephrase your question. It's not quite clear what you want.[/QUOTE] The "checkforkey" part, I mean, what's the thing I put there if I wanted to say "If G was pressed".
[QUOTE=Scoooooby;18923104]The "checkforkey" part, I mean, what's the thing I put there if I wanted to say "If G was pressed".[/QUOTE] Windows has a function called GetAsyncKeyState. Check MSDN.
[QUOTE=ThePuska;18923849]Windows has a function called GetAsyncKeyState. Check MSDN.[/QUOTE] NO! You're suggesting polling which is a horribly inefficient technique to detect a key press. The right way is to make a key hook proc using the Windows API. Normally you'd get a message in your window message queue, but without that you need to make a hook. [URL]http://msdn.microsoft.com/en-us/library/ms644984%28VS.85%29.aspx[/URL]
[QUOTE=Spoco;18926116]NO! You're suggesting polling which is a horribly inefficient technique to detect a key press. The right way is to make a key hook proc using the Windows API. Normally you'd get a message in your window message queue, but without that you need to make a hook.[/QUOTE] I'll check it out. Lol yeah ;P --v
You caught me in the middle of editing, anyway check the url in my last post. Oh wait, you're using C#. I'm not sure if it has anything better, but definitely not GetAsyncKeyState.
[QUOTE=Scoooooby;18923104]The "checkforkey" part, I mean, what's the thing I put there if I wanted to say "If G was pressed".[/QUOTE] Well, what library are you using? In Windows forms? XNA?
I think this might be what you're looking for: [URL]http://msdn.microsoft.com/en-us/library/471w8d85.aspx[/URL] Note that it is a blocking call, which means it will wait until the user presses a key before continuing with the code. If there's any need to run other code while waiting, you need to stick it in a thread, but that's something I know nothing about in C#. Not even sure if you can do that with the console stuff.
[QUOTE=Spoco;18926506]Not even sure if you can do that with the console stuff.[/QUOTE] of course you can thread in a console app
[QUOTE=turby;18926720]of course you can thread in a console app[/QUOTE] Yeah you can thread, but what about printing stuff in the console while it's waiting for input? Though the input and output streams should be separate and I'm probably doubting for nothing.
Ehh, thanks guys. But I think I'm trying to do something too complicated. The whole keyboard input part was only a bit of it. Thanks though :) And just because this is what I was working on: [img]http://img695.imageshack.us/img695/5779/captureih.png[/img] I'm pretty proud of myself, I created that from scratch, it's like a chat room thing. And the whole Key Press thing was that I want the user to be able to just press the Enter key to submit the message instead of pressing the Enter button on the form.
[QUOTE=Scoooooby;18927176] And just because this is what I was working on: [img]http://img695.imageshack.us/img695/5779/captureih.png[/img] [/QUOTE] Could end up nicely if you have the right idea's.
[QUOTE=Scoooooby;18927176]Ehh, thanks guys. But I think I'm trying to do something too complicated. The whole keyboard input part was only a bit of it. Thanks though :) I'm pretty proud of myself, I created that from scratch, it's like a chat room thing. And the whole Key Press thing was that I want the user to be able to just press the Enter key to submit the message instead of pressing the Enter button on the form.[/QUOTE] Aw, man, if that's what you want it for that stuff is easy. Say your textbox is named "TextBox1", all you have to do is add an event handler to the KeyDown event. Here, like so: [code] void TextBox1KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.Enter) { e.Handled = true; // Stop it beeping because the key is "invalid" // Your code here } } [/code] I would have posted this earlier as it's a much easier method, but I wasn't sure what you were doing. This code should all work, assuming I've got everything about what you're doing right so far.
-snip- Nevermind, thought it was for something else. :) [editline]02:58AM[/editline] Since I've already posted, I suppose one thing I could say is that to tidy up the code a little you could make a control that derives from TextBox, and override the OnKeyDown method with the same code. Particularly useful if you think you're going to reuse a textbox of that type, or if you just want to clear up the code in your main form.
[QUOTE=VoiDeD;18929842]Since I've already posted, I suppose one thing I could say is that to tidy up the code a little you could make a control that derives from TextBox, and override the OnKeyDown method with the same code. Particularly useful if you think you're going to reuse a textbox of that type, or if you just want to clear up the code in your main form.[/QUOTE] Even better, you could add a new event - OnEnter. Then you could just handle that; though in the end it's just as easy to have your code in KeyDown and check to see if enter was the key. Also if you want to clear up the code in your main form, you could always just use folding or use partial classes and stick the code in multiple files or even #regions. [editline]03:10PM[/editline] Hey, right, Enter is the focus event. Scratch that idea, then.
Anyone know how I can use my switch statement to check if a string has a substring inside? Trying to make it recognize "Print" but if I put "Print CAKE" it doesn't like the command.
How about using string.find("PRINT") and checking if it returned number isn't string.npos? ([url]http://cplusplus.com/reference/string/string/find/[/url])
[url]http://research.microsoft.com/en-us/projects/kodu/[/url] :v:
[QUOTE=Ritave;18933294]How about using string.find("PRINT") and checking if it returned number isn't string.npos? ([url]http://cplusplus.com/reference/string/string/find/[/url])[/QUOTE] That's C++. I said C#.
[cpp]string s = "Print CAKE"; s.StartsWith("Print"); //use s.StartsWith("Print", CurrentCultureIgnoreCase); if you don't care about the case[/cpp]
Sorry, you need to Log In to post a reply to this thread.