|
Thanks a lot Rocky , but would you please clarify some things for me? They are:
-Don't you think that installing .Net framework on every computer using .Net applications is somehow a dirty requirement? Suppose you have developed a .Net application and you want to sell it, you should say to customers: "Please first download .Net framework!"
-Do you feel the lack of some things like ATL in C#?
-Is it possible to develop high speed applications with C#? For example suppose a robot which should do a fast reflection after processing an image. Does have C# the same performance as VC++ in this situation?
Thanks again! ;)
Don't forget, that's <font color="blue">" Persian Gulf "</font> not Arabian gulf!
|
|
|
|
|
Meisi wrote:
Don't you think that installing .Net framework on every computer using .Net applications is somehow a dirty requirement? Suppose you have developed a .Net application and you want to sell it, you should say to customers: "Please first download .Net framework!"
(1) If you are distributing your software on CD, you can distribute the .NET Framework on your CD, and then they won't have to download it.
(2) Even if they do have to download it (because they're downloading your software, or whatever), they'll only have to do it once, and chances are getting higher and higher that they'll have already done it by the time they want to try/buy your software.
Meisi wrote:
Do you feel the lack of some things like ATL in C#?
You know, I haven't used ATL myself, but it seems to me that the .NET BCL partially takes it's place. Also, in .NET 2.0 there will be Generics (read: templates) available in C#.
Meisi wrote:
Is it possible to develop high speed applications with C#? For example suppose a robot which should do a fast reflection after processing an image. Does have C# the same performance as VC++ in this situation?
Yes, it'll be somewhat slower, but to me, it's worth it.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Meisi wrote:
-Don't you think that installing .Net framework on every computer using .Net applications is somehow a dirty requirement? Suppose you have developed a .Net application and you want to sell it, you should say to customers: "Please first download .Net framework!"
Nope, not dirty at all. From this point on in time at Microsoft, .NET will be part of the OS. No more downloading. Currently, .NET is an update module for the standard Windows Update and many people have already installed it not even knowing what it was.
As time goes on I expect to see it already on systems. There are many new programs coming out that rely on .NET. I was surprised to hear on the ScreenSavers on Tech TV (a show for geek type people on the tech tv channel) that one of their top picks for RSS view was a .NET viewer and they mentioned it required .NET to be installed. There will be many more software products hitting the shelves that people will want to use and they will require it.
It is a lot like COM. In the early days we wondered how we could justify forcing everyone to update to have COM available (showing my age again). While it seemed at the time it would be a hard sell to some, it took over.
Meisi wrote:
-Do you feel the lack of some things like ATL in C#?
It is not "lack of", in the older days I could write about any kind of program for my Commodore 64 computer that I could find on a IBM compatible, but it would take less time, be easier to create and have a future if I built it on my IBM compatible computer (again showing my age at pre Windows OSs ). The future is .NET. That is simple and no two ways about it. Do you write code today that will soon be considered "legacy" or just start writing for the future. Usually, an application of any serious size will take 6-18 months. At that end of that cycle, .NET will be on most Windows based computers and I believe on many Linux machines as well.
Meisi wrote:
-Is it possible to develop high speed applications with C#? For example suppose a robot which should do a fast reflection after processing an image. Does have C# the same performance as VC++ in this situation?
No, C# or any managed language in .NET will be hugely slower than VC++ calling native Windows API. I expect this to continue for a year or two until .NET V4 or something like that. Remember, with Microsoft it is usually several versions before they take over the world. Happend with Windows, happened with IE, .NET is no different. But they have created a VERY good version 1.0!
If you need raw horse power graphics such as a video game, there is little need for .NET. As in the old days, those type of applications where all DOS based until many later versions of Direct-X. Now many of the games are native to Windows. Same thing coming down the road for .NET.
I personally think that Microsoft has been surprised. They were originally thinking of tools to help build backend, mostly networked based applications and interfaces. Once developers got their hands on C# and WinForms, it probably surprised them to see how quickly we adapted to them and wanted to go further down that road. They know now and and planning for it this time.
There I go again, start typing and it just don't stop. And I don't even get paid for pushing .NET on everyone
Rocky Moore <><
|
|
|
|
|
The way you answer my questions, encourages me to ask more and more...;)
My friend says C# is a managed language and will never have good performance as vc++ has. But you say we should wait for 1 or 2 years and it will happen as happened for other Microsoft products. So I am confused and you should clarify!
Thanks a lot
|
|
|
|
|
Meisi wrote:
My friend says C# is a managed language and will never have good performance as vc++ has.
It depends on the type of application. VC++ will not give you much different from C# when you are building normal data driven business apps. Now, if you look and development time and debugging, you are talking a major time diference as VC++ will take longer and require far more debugging (unless you are a perfect programmer and never make typos or errors in logic ). The current .NET works wonderful for this type of application while VC++ really lags behind.
Now, if you are developing a cpu consuming graphical game or CAD program, they C# would be very slow in its current form. In the future I would imagine we will see the line blur more.
So, basically, it is the type of application and how much time your want to spending building, debugging and maintaining.
Another aspect is if you plan to do any web work. Designing apps in C# for Windows and C# for the web allows you to share a lot of the code with little work. In VC++ it is a royal pain since you would be wrapping your C++ in COM to access it from scripting on the web site or digging ISAPI plugins for your web site which is still a pain. With C# you will be able to take most of your data and business logic and simply call it from you web application just as easy as your Windows application.
Rocky Moore <><
|
|
|
|
|
I'm trying to do a drop-down color picker, more or less using the same design as Watson39's code (here:http://www.codeproject.com/cs/miscctrl/color_picker.asp). What I find is that if you do ShowDialog() on the form, it goes Modal, and of course, you can't access the app that called it to click off the color picker and basically cancel. If you go with the Show() option, you end up losing focus on your app (it becomes "inactive") and you have a new, blank icon in your alt-tab window. I've tried setting the owner and parent of the color picker to the TopLevelControl of the calling control. No love. Anybody have any guesses on how to solve this?
thanks,
~Pb
|
|
|
|
|
With menus and combo dropdowns, you grab the mouse capture with SetCapture() when the mouse is outside your menu, and release the capture with ReleaseCapture() when the mouse is inside your menu (so that any contained controls can get mouse messages). So this would be the way to do it here. You will also want to close the popup when it recieves a WM_APPACTIVATE message where the app being activated is not your own.
I had been struggling with this with my CommandBar, but when I discovered this way, everything worked perfectly.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Those methods don't exist on a C# Windows Form, which is what my drop-down is. I'm not quite sure what the equivelant would be, either. I'm not having any trouble capturing the events, or for that matter, getting the forms to be active appropriately. At this point, the only problem I'm still having is that when the drop-down occurs and the form is show, the main app's form becomes inactive, which should not be the case for a drop-down menu.
Thanks ~Pb
|
|
|
|
|
Patrick Bristow wrote:
Those methods don't exist on a C# Windows Form, which is what my drop-down is. I'm not quite sure what the equivelant would be, either.
Just use the APIs.
Patrick Bristow wrote:
the only problem I'm still having is that when the drop-down occurs and the form is show, the main app's form becomes inactive, which should not be the case for a drop-down menu.
Did you set the WS_EX_PALETTEWINDOW style?
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
Did you set the WS_EX_PALETTEWINDOW style?
According to MSDN, that's only going to set the form topmost and give it a raised border. By making it a child form, I've already made it topmost. And given the design I'm using, I don't really want a raised border. Unfortunately, none of that solves the fact that the window takes the focus away from the main application, which I don't know how to stop. Really, it's just appearance, but most apps don't have this problem, and I'd like to fix it.
Thanks, ~Pb
|
|
|
|
|
|
jdunlap wrote:
Sorry, I forgot - setting the popup's parent window to the desktop window is the most important part.
Actually, I long since did that (I think I said it earlier). I set the "Owner" form. However, the "Parent" control gets mad at me when I set it to the parent window. The exception reads "Cannot add a top level control to a control." I assume that I'm only supposed to set the Owner, not the Parent (in C# terminology).
Any more guesses? Thanks.
|
|
|
|
|
I've experimented a little and found that when you set the styles correctly for a popup in SWF, it puts your window in a "parking window". How to get around this, I don't know.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
It's that naughty WS_POPUP style bit! Remove it, and you'll be fine. You'd think that it should be there for a popup, but that's just not true.
I remember that when I did the commandbar, I took about 3 days searching for the answer to this, and finally got it. But by today I'd forgotten it, and it wasn't obvious because I didn't explicitly remove it - I just didn't add it.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Now, any idea how to change that bit in C#? The library I happen to be using nicely redefines that enum in C#, but unfortunately, I don't know what function to use to set it. It's been far too long since I've had to use C++/MFC style stuff.
|
|
|
|
|
Just use the SetWindowLong API:
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int Index, int NewLong);
For the styles to take effect, you'll need to do SetWindowPos with the flags set to SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE SWP_NOMOVE .
Here's the import for SetWindowPos:
[DllImport("user32.dll")]
private static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndAfter,int x,int y, int cx,int cy,uint flags);
NOTE: If the popup recieves the focus at any time before the WS_POPUP style is removed, the currently focused form will not have the focus. However, once it gets the focus again after the WS_POPUP flag is removed, you can safely set focus to your popup without it losing the focus. So you have to remove that bit as early as possible in the form's creation.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
int nStyle = GetWindowLong(this.Handle, GWL_STYLE);
nStyle^=Win.User.WS_POPUP;
nStyle^=Win.User.WS_POPUPWINDOW;
SetWindowLong(Handle,GWL_STYLE,nStyle);
int nExStyle = GetWindowLong(this.Handle, GWL_EXSTYLE);
nExStyle|=WS_EX_PALETTEWINDOW;
SetWindowLong(Handle,GWL_EXSTYLE,nExStyle);
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
You just remove the WS_POPUP style. (BTW, you probably don't need to remove the WS_POPUPWINDOW style.)
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I use it as:
Form fPom=new Form();
fPom.ControlBox=false;
fPom.ShowInTaskbar=false;
fPom.StartPosition=FormStartPosition.Manual;
fPom.FormBorderStyle=FormBorderStyle.FixedToolWindow;
fPom.Deactivate += new EventHandler(this.fPom_Close);
fPom.Location ...
I open this form by Show() method and close it in Deactivate event (other events doesn't work good)
Hi,
AW
|
|
|
|
|
A.Wegierski wrote:
I open this form by Show() method and close it in Deactivate event (other events doesn't work good)
This works in some cases, but suppose it's a menu, and has submenus? When the submenu recieves focus, the original menu disappears.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi,
I am writing a multi-threaded program that involves concurrent access of ArrayList objects. Some threads need to read the list, while others need to modify it. Both operations must NOT occur at the same time, and none of the thread need read & write access. they are either reader / writer. actually, in my case, there's multi-reader and a single writer. How can i manage the access with SyncRoot or any other synchronization API in C#?
MSDN disnt provide much info...
Thanks.
|
|
|
|
|
viperxp wrote:
MSDN disnt provide much info...
Static members are often easily overlooked (Intellisense is partially to blame). Have a look at the ArrayList.Syncronized() that returns a thread safe wrapper for the arraylist that you passed to the method. I have never needed to use it, but that is how I understand it.
Hope this helps
<a TITLE="See my user info" href=http:
|
|
|
|
|
You may also want to look into locking the SyncRoot instance property.
|
|
|
|
|
I ahve looked at both the Synchronized() and the SyncRoot property in MSDN, but i dunno how to use them (to solve my problem) ... maybe can someone provide some hints on how can i use them to address my prob?
|
|
|
|
|