|
well, don't think too badly of yourself.
From the SDK Docs:
-----------------------
The as operator is like a cast except that it yields null on conversion failure instead of raising an exception. More formally, an expression of the form:
expression as type
is equivalent to:
expression is type ? (type)expression : (type)null
except that expression is evaluated only once.
-----------------------
so it is logically exactly as you claim... but the actual IL implementation is different, and not describable with c#... which explains the requirement of the new "as" keyword.
|
|
|
|
|
ah, maybe thats why I thought that
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
Does anyone know what the equivalent would be in C#? System.Drawing.Graphics does not seem to have a means of doing what I want, which is a recangle with rounded corners.
|
|
|
|
|
Charles Petzold's Programming Microsoft Windows with C# has an example demonstrating how to create one.
Unfortunately the code from the book isn't available on his website, nor MSPress' website so I can't give you his exact code.
But I don't think there would be any harm in giving you the algorithm since it is common sense when you think about it
First break up your rounded rectangle up into its distinct sections. You have the four sides, and 4 rounded parts. The rounded parts if you put them together form an ellipse. So all you have to do to create your own rounded rect function is to use the DrawArc and DrawLine methods of the Graphics object to position each part where it needs to be.
HTH,
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
I have written an article showing how it's done, but as the other poster said, it's pretty obvious. I provide a function that allows you to set % rounded, just like GDI did.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Thanks both of you. I was hoping I was missing something and would not have to do it manually.
I don't understand why they would not have brought RoundRect forward into C#/.NET, it seems like something that would be useful (at least to me).
|
|
|
|
|
okay here is my problem, i have asked this question about a million times, and everybody keeps giving me the same answer...
which leads me to the conclution that nobody understands or knows anything about windows XP themes!!!
basically if you look at the theme example in MSDN (ms-help://MS.MSDNQTR.2002JAN.1033/dnwxp/html/xpvisualstyles.htm) you see that the example is first of all written in c++, and that they dont expand much on how to do any of this in .NET (e.g. c# and vb.net)
now the reason i said that nobody seems to know the answer to this question is that every time i ask it, i get this response
**************************
use a manifest file
**************************
i knew about using manifest for quite a long time now, that is NOT theming in windows XP.
microsoft says that there are new MSLOGO compliancy standards for XP... there are lots of doc's available on the logo site about this, but NONE of them tell you how to do it in .NET!!!!
i find this to be extremely unfair as MS wants us (the developers) to use .net it is only right for them to tell us how to stick to the standards that they Set.?!?!
am i wrong in asking this?
|
|
|
|
|
To enable XP Themed controls in a .NET application you need to do two things. First, include the manifest file; second, set the FlatStyle property of your controls to System.
If you are creating your own controls then you need to use P/Invoke to obtain the functionality needed for themes.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
akr0 wrote:
okay here is my problem, i have asked this question about a million times, and everybody keeps giving me the same answer...
So everyone is wrong and you are right. Congrats to you.
Enlighten everyone and write an article.
|
|
|
|
|
hehehe
Mark Nischalke wrote:
So everyone is wrong and you are right.
i did not say that. what i meant was this, look at james' post, he also makes reference to the manifest file and the flatstyle of controls... this is all fine and well. it gives the illusion of a themed application. but do this and place a tab page control on the form. add two or three tabs.
then run the app, right click on your desktop and goto properties. look at the difference between the actual pages (not the tabs, the page colors)... this is where you need the uxtheme.dll...
Mark Nischalke wrote:
Enlighten everyone and write an article.
there is an idea, i have discovered some things in the last week on how to access normal DLL's and API's... which will enable me to access uxtheme.dll
|
|
|
|
|
akr0 wrote:
then run the app, right click on your desktop and goto properties. look at the difference between the actual pages (not the tabs, the page colors)... this is where you need the uxtheme.dll...
The page color issue is an acknowledged bug by MS.
I'm sure there are other controls where this is a problem though which is why you'll need to P/Invoke to get around it until MS fixes it.
akr0 wrote:
there is an idea
Please do I always look forward to new articles, especially on new topics such as this.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
I know that this topic was discussed, but no-one wrote how to compile manifest as a resource (into the EXE file). So I ask how to do it?
|
|
|
|
|
I'm just about to leave again, but I figured I'd throw this out so you can look at it while I'm gone.
Assuming you are using VS.NET, add the .manifest file to your project as an "Embedded Resource" and see if that works. If not add it as "Content". This option is accessed in the build property for the file.
Let me know if either of those work. I know its possible to do it in VS.NET I just need to remember how.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
I've already tried it and it works neither "Embedded Resource" nor "Content". I think it should be compiled as a Win32 resource and C# compiles it a little bit different (resx). But I'm not sure.
|
|
|
|
|
Who knows how to link all DLL's which an C# app need into one EXE file staticaly. In VS C++ there is a choice called "Use MFC in a Static Library" and then the c++ app runs on every system, but how to do it in C#???
|
|
|
|
|
Which DLL's?
If you mean the .NET framework stuff, then you have to distribute the framework with the application.
Michael
|
|
|
|
|
If you are referring to .NET framework (you mentioned MFC), well, you can't: you have to redistribute dotnetfx.exe (~20Mb) and install on each client machine.
Crivo
Automated Credit Assessment
|
|
|
|
|
It's me again...
I want to add scrolling to a control I've wrote.
Is there a scrolling component like JScrollPane in java, or must I write it all by myself?
10X,
Inbal
|
|
|
|
|
There are several classes you can inherit from: ScrollableControl, Panel, or ContainerControl. The documentation recommends inheriting from Panel or ContainerControl but you can inherit from ScrollableControl if you wish.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
10x, but how do I register for the scrollbars events? As far as I could see, these events wasn't accessible to a ScrollableControl like myself.
What I used to do back in java was to override Paint and draw only the clip rectangle it gave me. That represented the viewport area out of the big I should have drawn without scrollbars.
Is there any component like that (JSrollPane) out there?
Inbal
|
|
|
|
|
Hi,
I want to add a large number of nodes to a tree-view, but such operation halts the app.
I've tried using a separate thread, but the framework won't allow it, because the thread I've created it's the one that holds the control's windows handle.
Is there a way to pass that handle?
10X
Inbal
|
|
|
|
|
First call Begin/End Update on the treeview that should speed up the process a bit because it won't try to redraw after every addtion.
Then instead of calling the actual methods on the treview object you need to use the Invoke method on the object, which will marshal your calls to the thread that owns the handle.
The documentation will have to be your guide on on using Invoke because I've got another 2-3 days before I'm about to tackle the same thing in my app :-P
HTH,
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
10x,
I've tried it, but the result was the same. 'Invoke' calls my method on the main thread, which means that the app stucks all the same.
I need means of calling AddNode from a completely different thread, so that my main thread can still listen to user mouse clicks etc.
Inbal
|
|
|
|
|
you should go down to TVN_GETDISPINFO in a WndProc override
|
|
|
|
|
modified 1-May-21 21:01pm.
|
|
|
|