|
aei_totten wrote: Thread.Sleep() not working
Of course, it is Thread.Sleep(), it isn't Thread.Work().
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi,
I have a Class named Global and I'm Trying to access Form2 of my App. But sadly I can not. Normally I would use it as
Form2 frm = New Form2();
But I just cannot get Form2 on that Class
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Different namespace? Different project? Form2 already compiled?
|
|
|
|
|
Form2 is already Added to the Project.
Code file Global.cs and Namespace Globals
And in that file I want a common procedure that I can use on any form in my App.
Hope this helps.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Are the Global class and the Form2 class both in the same namespace? Namespaces or reference errors could do that. Sadly without any further information the exact cause would continue to remain obscure to most non-clairvoyants. Another piece of possibly unwanted advice from me would be to avoid at all costs any type of "God Object" global type poison in your code, and please use appropriately named types.
Need more info.
Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Thanks Scott, I had a spelling mistake in namespace
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Out of curiosity, which IDE/editor are you using?
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
carbon_golem wrote: Another piece of possibly unwanted advice from me would be to avoid at all costs any type of "God Object" global type poison in your code, and please use appropriately named types.
Why is this bad?, Because of hackers etc? or...
Regards,
Gareth.
|
|
|
|
|
gareth111 wrote: Why is this bad?, Because of hackers etc? or...
No, not because of hackers. You don't do this because it's horribly bad design. There might be people comming in behind you that get stuck maintaining your code, and, after seeing this, might want to hunt you down and throw you into a vat of boiling lead.
|
|
|
|
|
I should have given a reason for that...
OOP has a few important best-practices guidelines that usually appears in the beginning of text books that sadly are forgotten by the end of them.
Objects should hide data, encapsulate data, and ensure data integrity to name a few. Objects serve a function of providing a structure around important data and work with other Objects to support a few inter-object relationships. (Is-A:association and Has-A:inheritance) Objects should also be coherent meaning if your problem calls for a Person and Pet, you would want to construct Person and Pet classes, and not put them into one 'God Object'. Global objects are not resistant to change either.
I hope you're starting to see the reasoning for this. If you have a library with Person, and Pet classes, you don't have to write them again for one, but now the program is coherent when read.
Tomes upon tomes have been written on the subject. I have given you a barely-adequate explanation, so I strongly recommend getting a book on object oriented programming, it's not just a bunch of fluff, it will save you effort bigtime.
Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
If you're doing this, it's an indication of bad design, violating OOP rules for encapsulation. Why would your "Global" class need to know anything about a form, or the controls on it? Hint: In proper design - the "Global" class shouldn't know or care about anything else outside of itself.
If you want to send data and status information back to Form2, the Globals class should expose events or delegates that an instance of Form2 should subscribe to to get notification of these things.
|
|
|
|
|
Thanks for that Dave.
Regards,
Gareth.
|
|
|
|
|
"Allow service to interact with Desktop"?
What does this mean??
I want to start an application through a windows service (say notepad).. So when I check this option (Allow service to interact with Desktop), I am able to start it, otherwise not..
Does it mean that for GUI application, this option should be checked? What If i want to run a console application? Will checking this option let my console application run or not??
Why is that? And also, how can I programmaticaly check this option for the service that I am creating??
Is it bad for services to interact with the desktop??
Som
|
|
|
|
|
novice1115 wrote: "Allow service to interact with Desktop"?
What does this mean??
In simple terms, Windows Services run under a seperate, non-visible desktop. Checking this option allows the service to interact with the users visible desktop instead of the normal hidden service desktop. Screen Savers run under another seperate desktop, and so does the UI for unlocking the workstation when you hit Ctrl-Alt-Del.
novice1115 wrote: I want to start an application through a windows service (say notepad).. So when I check this option (Allow service to interact with Desktop), I am able to start it, otherwise not..
Of course. If this option is not checked, then Notepad will still launch, but it's window will show up on the service desktop, which you can't see.
novice1115 wrote: Does it mean that for GUI application, this option should be checked? What If i want to run a console application? Will checking this option let my console application run or not??
If the option is checked or not, the process you launch, no matter what type it is, will still launch. It's just a matter of under which desktop the window is going to show up. If this option is not checked, the user will never wee the new application's windows, even if it's a console app.
novice1115 wrote: Is it bad for services to interact with the desktop??
Generally, yes, it's bad practice. Think about it. What if there's no user logged in??? How are you going to tell?? How are you going to handle this situation?? What if the user logs out during an operation your service is performing?? There are just a few of the questions you have to ask yourself if you are going to write an interactive service.
|
|
|
|
|
Thanks a lot for clearing my doubts..
|
|
|
|
|
Hello Experts!
Well, I am in a newer predicament lately. This, after I managed to get some help on customising a listview control.
<a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3089588&SiteID=1"><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3089588&SiteID=1">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3089588&SiteID=1</a></a>[<a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3089588&SiteID=1" target="_blank" title="New Window">^</a>]
The problem I am facing now is that i try to scroll the customised scroll I am facing a StackOverflow Exception.
This is how I am trying to communicate the scroll across
//starts here
if (e.Orientation == ScrollOrientation.VerticalScroll)
{
if (lo == 5)
{
if (SetScrollPos(this.listViewEx2.Handle, SBS_VERT, hi, true) != 0)
{
SendMessage(this.listViewEx2.Handle, WM_VSCROLL, (IntPtr)(4 + 0x10000 * hi), IntPtr.Zero);
}
}
else
{
SendMessage(this.listViewEx2.Handle, WM_VSCROLL, e.WParam, IntPtr.Zero);
}
}
if (e.Orientation == ScrollOrientation.HorizontalScroll)
{
if (lo == 5)
{
SetScrollPos(this.listViewEx2.Handle, SBS_HORZ, hi, true);
SendMessage(this.listViewEx2.Handle, WM_HSCROLL, (IntPtr)(4 + 0x10000 * hi), IntPtr.Zero);
}
else
{
SendMessage(this.listViewEx2.Handle, WM_HSCROLL, e.WParam, IntPtr.Zero);
}
}
//ends here
Someone please help me! All I have is one last day at hand!
-
Roger
|
|
|
|
|
This code runs in your scroll event handler ? That will do it, you send a message to scroll, then it fires an event, then it sends a message, etc, until the stack overflows
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Oh! You mean me's actually performing a loop!
What way do i not loop that? What i need to perform here is when ListView1 is scrolled, ListView2 also gets scrolled to the same level!
|
|
|
|
|
Fixed it!
All it needed was a PostMessage() instead of a SendMessage()!
Thanks guys!
|
|
|
|
|
Dear all,
I have to use a paretrized function as example sum(x,y),
i dont know how to use this piece of code for such function can anybody help me here..
ThreadStart job = new ThreadStart(sum);//what to do for parametrized functions
Thread thread = new Thread(job);
thread.Start();
please help me here...
Thanks in advance...
vikas da
|
|
|
|
|
There's a ParameterizedThreadStart class, it's start method takes an object. If you have more than one parameter, define a struct, and make that the object you pass through. Your method will need to take an object and you'll need to cast it to be the right object type to get the values out.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello all
I have known how to create database application with C#.
But it's stand-alone database in my computer.
I want to study how to make database server.
Is programming different from stand-alone database ?
What is important I should study to start to create database server?
Thank you.
|
|
|
|
|
You want to learn how to write a program like SQL Server ? That's a big, big task.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
toeh wrote: What is important I should study to start to create database server?
Security. Reliability. Threading. Transactional Support. ACID rules. Scalability. Replication. Fault tolerance. SQL standards.
Those are just a few of the things you would need to start. May I ask why you would want to do this though? It seems a heck of a lot of work for something when there are free databases out there right now.
|
|
|
|
|
Start buying some cheap OS and sell it to IBM...
|
|
|
|