|
Thank you for your answer. I know what the ControlStyle bits, and I know what is it doing, the reason why i am asking for a way to perform the SAME thing(as SetStyle does)
I think we are able to set the styles with API
e.g (As I mentioned) Instead of SetStyle (opaque,true) you can use the SetBkmode API, and (I am not sure) instead of Double buffer, you can use CreateCompatibleDC API. I am asking for the other ones' apis.
Do you know them?
Thanks
Best Regards
Emre YAZICI
|
|
|
|
|
Okay, you've misused the work API--which is an interface (or a group of functions/methods). You're looking for all the methods that perform the same thing as SetStyle for each bit...
There normally isn't a one-to-one correspondance with a style bit and a method or a function. Many of the styles shouldn't be changed after the window has been created, they're ment to be used as the window is being created where calling a dozen or so methods instead of SetStyle would be tedious. Even in other APIs like MFC hyou have to resort to SetStyle (which wraps SetWindowsLong(GWL_STYLE,...) ).
Some of the styles in ControlStyles are .NET specific; meaning they're only handled as a cohesive attribute in .NET.
I don't know of any exhaustive lists that would give you the information you want. Maybe you could detail what you want to do or why simply calling SetStyle doesn't suit your needs.
PeterRitchie.com
|
|
|
|
|
Well
Thank you for your answer
Your answer was just like i guess
SetWindowsLong api does not support all of these styles, we need to use others i think
Why dont I call the SeetStyle , because i do create a window using CreateWindowEx and all the other operations like Moving, Showing the window or drawing line, filling a rectangle will be performed by APIs. I want to do everything with apis. Because the way is faster!!
Thanks anyway..
Best Regards
Emre YAZICI
|
|
|
|
|
Are you using the Win32 API, via P/Invoke?
Why are you using .NET at all if you're simply doing everything via Win32 API?
PeterRitchie.com
|
|
|
|
|
I tried both, I mean
1 ) I have tried writing a grid control with usercontrol and .net frameworks' Graphics object( using Drawline, FillRect...)
2 ) I have tried the same thing with CreateWindowEx, LineTo, MoveToEx ....
When I compare them the second one was faster than the first one
This is why i want to use APIs
Best Regards
Emre YAZICI
|
|
|
|
|
If it's a stand-alone application (i.e. not client-server) then I would suggest just writing it in C++. The work involed in marshalling all the API structures and data just isn't work the time otherwise.
If speed is that much of an issue for you. Even with .NET 2.0 there are some performance differences between .NET applications and "native"/unmanaged.
see http://www.sysinternals.com/blog/#111409937327999900[^]
PeterRitchie.com
|
|
|
|
|
Of course, c++ is the best way of doing that, I was looking for a way to do it in VB.Net or C#.Net
Thank you anyway
Best Regards
Emre YAZICI
|
|
|
|
|
It'S funny... i have made some same tests... the better performance dosen't comes from the native window creation, beacause the control class do the same thing (only one time)...
The better Performance comes only from the usage of native drawing functions...
|
|
|
|
|
Of course it comes from the usage of native drawing functions
Best Regards
Emre YAZICI
|
|
|
|
|
Hello... At first... It don't exists any API Functions for setting Doublebuffer...
It's only implemented in the controls class to perform manged offscreen drawing operations...
It's a simple concept for flickerfree drawing...
There are many good articels about offscreen drawing at the Codeproject...
It's absolutly not recommend to completely rewrite a smarter Control Class which derived from the NativeWindow... They will come more and more problems when you implement multithreading situations...
When you only rewrite the control class to perform faster drawing operations
then create a class which derived from the system.windows.forms.control class
override or reimplement the OnPaint, OnPaintBackground method to perform native drawing operations and doublebuffering effect...
Everything else makes to much troubles in my mind...
Good Luck...
|
|
|
|
|
I am actually going to write a control class with only apis (without using nativewindow class)
For the Events, I will use the WindowProc Api to handle the events
For the drawings, I will use the MoveToEx LineTo DrawText FillRect... apis
For the styles and messages, I will use SetWindowLong and SendMessage apis
As I mentioned , the double buffer could be created by using the CreateCompatibleDC api, which creates an extra buffer for graphical operations.
Thank you
Best Regards
Emre YAZICI
|
|
|
|
|
Your concept is for me really clear...
It was only a hint in front of rewritting the complete control class, because it's absolutly enough work to implement (savely) the native drawing functions in the control class...
I don't believe that you really see the problems in front of native resources and the gabrage collection routine...
- You must manage ((re)allocating, deleting) all native Resources for all possible situations, which is not the problem but many code...
- They are also several handle protector meachanism in the control class for preventing memory leaks which can created during the gabrage collection routine...
You see it'S not so easy to create a save and stallable control in front of all these aspects...
Best regargs, and good luck...
|
|
|
|
|
OK i have already install the framework 2 redistributable package an then the framework 2 sdk beta 2 my problem is that i dont know how to use the framework 2 class library in the Visual studio 2003
note in the resource mannager the type of the net librarys its 1.0 not 2.0 for librarys like system.dll system.windows.dll
can anyone helpme with this stuff please
|
|
|
|
|
|
In order to compile against the .NET Framework 2.0, you need to use the Visual Studio .NET 2005 compilers. VS.NET 2003 won't do it. Remember, the compilers are built into the .NET Framework, not Visual Studio...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Why couldn't you simply download vs2005 beta2 express ?
|
|
|
|
|
In a project I'm developing, I need to duplicate the functionality of the Display Properties -> Screen Saver tab. Most importantly, I'd like to list the screensavers the person has installed on their computer, complete with descriptions. I know that screensavers are usually located in the "%windir%\system32\" folder (Usually C:\Windows\System32), but is there a possibility that a screensaver that's available in this list could be located elsewhere on the system? If so, then what method can I use to reliably list the screensavers available?
I've searched through the registry, and there don't seem to be any keys that I can enumerate to give me a list. The other problem I'm encountering is that I can't seem to locate the "title" of the screensaver. I assumed it would be visible through FileVersionInfo.GetVersionInfo, but that doesn't seem to be the case (unless I'm blind).
Can anybody point me in the right direction here?
|
|
|
|
|
Yep it just lists the *.SCR files that impelement the screen saver entry points.
PeterRitchie.com
|
|
|
|
|
But how can I extract the "title" of the screensaver to list them on my form? I'd like to use the same display title as the Display Settings window uses, if that's possible - I assume you have to be able to find that somewhere, since Windows does it.
|
|
|
|
|
The string resource with ID 1 is used as the title to display in Display control panel applet.
PeterRitchie.com
|
|
|
|
|
I guess I'm missing it here, but how do I extract a resource from another EXE file? Is there some code available to do this rather simply? Either VB or C# will do. Thanks for your help!
|
|
|
|
|
.NET doesn't have support for Win32 resources. You have to pinvoke LoadStringW from kernel32.
A little helper class:
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace PeterRitchie
{
[ComVisible(false)]
sealed class Helper
{
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("user32", EntryPoint="LoadString")]
private static extern int LoadStringW(int hInstance, int wID, [Out] StringBuilder lpBuffer, int nBufferMax) ;
public static void LoadString(String ModuleFilePathString, int ID, ref String LoadedString)
{
IntPtr InstanceHandle = LoadLibrary(ModuleFilePathString);
StringBuilder BufferString = new StringBuilder(1024);
LoadStringW(InstanceHandle.ToInt32(), ID, BufferString, BufferString.Capacity);
LoadedString = BufferString.ToString();
}
}
}; Sample usage:
using PeterRitchie;
string LoadedString = "";
Helper.LoadString(@"C:\windows\system32\ssbezier.scr", 1, ref LoadedString);
Debug.WriteLine(LoadedString);
Enjoy!
PeterRitchie.com
|
|
|
|
|
Using .NET CF does anyone know if its possible to get an objects instance name.
ie the variable name. I want to serialise a bunch of objects and it would be nice for each to include its nme with data to allow better versioning
eg
<br />
class MyObject<br />
{ .....<br />
<br />
public Write ( TextWriter tw)<br />
{<br />
tw.Write( this.GetType().ToString() );
tw.Write( this.GetMyInstanceNameIfPossible );
}<br />
So I can later do
<br />
MyObject.Write( writer );<br />
This way when I read it in I can decide what variable to init. rather that rely on the order the data was written out.
I know I can just manually write the name, but this would be automatic and less prone to error.
Thanks
.nuetter
|
|
|
|
|
Are you asking how to get an instance variable's name? For instance, if I wrote:
public void DoSomething()<br />
{<br />
string myFoo = new FooType();<br />
}
would you want to know, at serialization time, that the variable name was 'myFoo '? If so, what advantage does that provide?
In any case, I don't think that's possible at runtime. A quick look at the ILDASM (Intermediate Language) representation of the class above makes it clear that locally scoped member variable names are discarded in the compilation to IL.
It is probably important to note that the names of field-level variables, method names etc., whether public or private, are preserved during compilation, so technically you could use reflection to get the names.
However, if your class(es) implement the ISerializable interface (as opposed, or in addition to being marked with [SerializableAttribute] ), then you are free to develop your own serialization and deserialization plans for the class(es). The ISerializable interface exists to deal with just this kind of issue (provide developers with a way to prevent deserialization exceptions caused by versioning), among other things.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
You would have to manually parse the debugging information; which, of course, does not exist in release builds.
The best you could hope for is the address (using the &[^] Operator in an unsafe[^] context).
PeterRitchie.com
|
|
|
|