|
These are different languages, with different features, that's it.
This question is kinda like a holywar starter
Regards,
Lev
|
|
|
|
|
|
0) Just because you *can* do something in C++, doesn't mean you should.
1) Macros can be used to circumvent the strong typing requirements of C++. Side effects are possible, and that's bad.
2) Macros cannot be debugged.
Macros that contain code are evil and should be avoided whenever possible.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Have to agree on all points. Macros are about the most evil feature C/C++ have to offer. The looong, late, sleepless nights dealing with macro expansion bugs...what a night terror.
All I can say is, THANK GOD C# doesn't have macros!!
|
|
|
|
|
Using macros, you can redesign your coding 'language' on the fly until your code doesn't even remotely look like C++. If you've seen as much bad C++ as I have, you know why many consider macros evil.
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++
|
|
|
|
|
This is not a question, but is too short to be an article. Learn from my mistake.
Yesterday, I was testing a windows service I wrote using Visual Studio 2008 on a Windows 2000 machine. I had originally targeted .Net 3.5 when I created the project, and had to re-target the assemblies to 2.0 before installing it on the target machine. When I installed it, the event log would say that the service started successfully, but a few seconds later, I would get an error event - an invalid operation exception.
I removed EVERYTHING from the service except a keep-alive thread so it would keep running once installed, and it still threw the exception.
Thinking it might e a flaw in VS2008 when changing from .Net 3.5 to .Net 2.0, I tried creating an entirely new solution targeting .Net 2.0 from the start. It still threw the exception. And then I had an epiphany.
The installer class sets the name of the service. One thing that all windows services do (when you create them with the VS2008 template) is calls the InitializeComponent() method. I had always deleted this call in prior services I had written since it seemed like a pointless thing to do, but this time, I had left the call in. In InitializeComponent , it tries to set the service name to "Service1". This is NOT the name I gave it in the installer object. After changing the name to the same thing I used in the Installer object, it worked just fine - no exceptions.
When I changed the name of the service.cs file, I guess it missed that string in the re-factoring process. I spent four hours on this problem. BTW, the other fix for this would have been to NOT call InitializeComponent .
[EDIT] BTW, I had tested this service on my own Vista box, and it worked fine. While I was waiting for access to the Win2K box, I figured I'd fix the Service name (because it was showing up as "Service1" in the event log). I re-factored and compiled, but did not re-test it before trying it on the Win2K box (I figured the re-factor would have done what it was supposed to do). The lesson here? ALWAYS RE-TEST, NO MATTER HOW MINOR THE CHANGE IS PERCEIVED TO BE. This is proof that even the programmers with 30 years in the industry make the most rookie kind of mistakes every once in a while.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Thursday, January 8, 2009 7:25 AM
|
|
|
|
|
John Simmons / outlaw programmer wrote: This is proof that even the programmers with 30 years in the industry make the most rookie kind of mistakes every once in a while.
Ha. Rookie
|
|
|
|
|
John Simmons / outlaw programmer wrote: but is too short to be an article.
Regarding the current quality of the majority of articles, you probably would get a 5.
|
|
|
|
|
"It takes a big man to cry admit a mistake, and it takes an even bigger man to laugh at that man." -- Jack Handey
I don't think I've created a new Service with VS2008 yet, but I hope to remember that if I do.
And I'll likely remove the InitializeComponent.
|
|
|
|
|
Hi All,
I have a panel in a windows form(C# .Net 3.5) and this panel contains a varying number of usercontrols.
When there are more controls than visible in the panel I get the vertical scroll bar as desired.
My issue is that when scrolling and the controls are redrawn there is a noticible delay and causes a very unsightly display.
Does anybody have an ideas for solving this issue?
I have tried setting the smallchange and largechange values for the vertical scroll and this seems to be a solution, the only problem is that it only seems to apply when the up/down arrow buttons are clicked and NOT when I click and drag the scroll bar.
If anyone knows of a way to apply this small change value for dragging the scrollbar, I think this will be a suitable approach to take.
Thanks in advance
|
|
|
|
|
Did you set doublebuffering on?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Yes i have set it for both the main form hosting the panel and for the usercontrols.
There is no noticible difference between having double buffering on or off.
I have left it set to be on.
|
|
|
|
|
Here's a usability hint - scrolling controls on a form is a *bad* thing (in terms of usability). My advice is to either create a wizard form, or implement tabs.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I appriciate that and if the controls where different then i would take a different approach. In fact i have many tabs in parts of the application, in addition to one form which work like a wizard
But the controls in question are all instances of the same type, and they are used as a list of entries. Similar to having a list box or a datagridview with a number of rows.
The reason the usercontrol was created is to display the information in a custom layout with colors and buttons to match the general style of the application.
So im afraid having a scrolling panel is a must have. Esp considering just one control may be larger than the panel, as the usercontrol can grow based on content.
|
|
|
|
|
How many controls are you talking about scrolling?? If it's a larger number of controls, there's nothing you can do about it. Controls are just very expensive to create and paint.
|
|
|
|
|
well the issue occurs with less then 10 controls but there could potentially be alot more.
Does anybody have a suggestion for setting the scroll position on scroll drag?
I would like to be able to drag the scroll bar in increments of 50 pixels for instance
|
|
|
|
|
Without seeing your implementation, I feel compelled to call the design "crap". I've been coding for Window since Windows 3.0 was a "good idea", and I've NEVER ONCE had to implement a scrolling form, with the exception of a mobile application (using C++/MFC), and even that was eventually scrapped in favor of a wizard-type form.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
have you never used a dataGridView then?
if you want many rows of data they wont always fit on the screen.
hence why controls like dataGridView have scroll bars
what happens if one of your users minimises the application to be smaller then the page with your controls on?
|
|
|
|
|
musefan wrote: what happens if one of your users minimises the application to be smaller then the page with your controls on?
The simple answer is, you don't let them. Forms can have a minimum fixed size, preventing them from shrinking smaller than the minimum size required by their content. Figure out what the smallest possible size is that will fit for the greatest majority of your users, and fix that as your minimum.
|
|
|
|
|
Dont get me wrong i dont want to seem argumentative with this issue as i really do appreciate the feedback from everyone.
One issue as i have said is that even one control can grow to be bigger than the panel, whatever the panel size (which itself has to fit within the users screen).
The controls i am using are not disimilar to those of a forum, where a number of replys are listed on a page. and there size grows as needed to fit the content of the message etc.
If i copy and paste this message a few times, chances are it wont all fit on your screen. hence the scroll bar to show all.
you see this used in many application. for instance a word document will not all fit on screen at once if the content is large enough. You cant just cut the content when it fills the screen and expect to put the rest on another part of the application.
Now i appreciate that certain progroms such as web browsers are made to handle this kind of thing and are therefore optimised for the task, but you cant say that scroll bars should never be used cause some cases require that kind of functionality. (This paragraph would not even be here if the text box i am typing in didnt scroll)
|
|
|
|
|
Hi all,
I want to execute and exe, basically a process. Everything is fine. But I want to know what's the best way to handle this. Let me explain.
Say I start the process on a click event, but the button is not disable. So a user can click on it again. At that point I want to check that process is already running. If it's running I don't want to run it again.
What I have done here is, use a global variable and once the process is started make it to true. Once a user click that button, simply validate that variable. Is that a good practice?
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I would disable the button on starting the process and enable it back when the process is done working.
Like this:
private void button1_Click_1(object sender, EventArgs e) {
button1.Enabled = false;
Process proc = new Process();
proc.StartInfo.FileName = "notepad.exe";
proc.EnableRaisingEvents = true;
proc.Exited += new EventHandler(proc_Exited);
proc.Start();
}
void proc_Exited(object sender, EventArgs e) {
button1.Enabled = true;
}
Regards,
Lev
|
|
|
|
|
But the reason is I cannot disable the button. On that single click event I want to start two process. One of it is continuously running, that's what I want to check in this case. Other process can be start/stop randomly.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Well, if you cannot disable the button, then, I guess, you should go for what Giorgi has suggested
Regards,
Lev
|
|
|
|
|
Well, the behavior of this button is rather confused for user. Sometimes, refactor the design would be better choice.
I Love KongFu~
|
|
|
|