|
Mike_V wrote:
I must resort to GetProcAddress which returns a function pointer.
Why? You dont need GetProcAddress for DllImport.
How do I get that to a Delegate? Should I make special delegates, like OpenThemeDataDelegate or just cast them all to Delegate?
Again, why?
[dllimport...]
static extern IntPtr OpenThemeData(IntPtr hWnd, string classlist);
You need IntPtr here, you are working with HANDLES, not CALLBACKS.
<a TITLE="See my user info" href=http:
|
|
|
|
|
Okay. Now that I'm awake, maybe I can write better
What I want to do is call functions in uxtheme.dll. Since the DLL is only present on XP, I cannot use the [DllImport] attribute, because then my program will not load on Win9X/2000. So first I need to check if the DLL is present, and if it is, then call GetProcAddress to load in the proper function pointers.
My question is, how do I use P/Invoke to do this? I know that I would need a Delegate to call the function, but how would I create a delegate from an unmanaged function pointer?
|
|
|
|
|
Mike_V wrote:
I cannot use the [DllImport] attribute, because then my program will not load on Win9X/2000. So first I need to check if the DLL is present, and if it is, then call GetProcAddress to load in the proper function pointers.
Why wont it load? It wont work if you use those functions, but you are gonna check anyways... I dont see the point of using GetProcAddress here. Perhaps you dont realize DllImport does not link the dll, it searches for it only when you invoke the function (or maybe a class that exposes it, but then dont instantiate that).
<a TITLE="See my user info" href=http:
|
|
|
|
|
leppie wrote:
Perhaps you dont realize DllImport does not link the dll, it searches for it only when you invoke the function
Umm.. Actually it does. Create a sample program that imports GetLastError. Invoke ILDASM on this class and look at the MANIFEST (top node in ildasm). At the very top, it has .module extern kernel32.dll . Fusion, or whatever loads the module, will see that directive and will not load the module if the dll is missing. I have tried not using GetProcAddress and it did not work on Win2K.
|
|
|
|
|
Ok then, my mistake. I suggest you wrap the Uxtheme dll in a seprate assembly and only call it if necesary
<a TITLE="See my user info" href=http:
|
|
|
|
|
What is the matter with Environment.OSVersion.Platform. Create properties
that does this for you and then call them to figure out what the os is.
<br />
public static bool IsThemeOS<br />
{<br />
if ( Environment.OSVersion.Platform == Platform.Win32NT&&Environment.OSVersion.Version.Major >= 5<br />
if ( Environment.OSVersion.Version.Minor >= 1 )<br />
{<br />
return true;<br />
}<br />
}<br />
<br />
Bo Hunter
|
|
|
|
|
Read one of my earlier messages. This will not work because .NET will link your module to the dll. Since uxtheme.dll is only on winxp, the module will fail to load on any other OS.
This would be easy to do in Managed C++, but I have an existing, extensive utility library in C#.
Mike_V
Tech Support: "Do you have any windows open right now?" Customer: "Are you crazy woman, it's twenty below outside..."
|
|
|
|
|
it like a calling function ???
i feel confused ,please help me
please particular description
thanks
|
|
|
|
|
A delegate is a pointer to a function.
An event is a special multicast delegate. Other than that, they are exactly the same (bar a few access methods, event is more restrictive).
EG (this probably wont work as you need to define the structure):
void MyMethod(string str)
{
}
Delegate a = new Delegate(MyMethod);
a.Invoke(this, new object[]{str});
Once you get the hang of them they become very handy and easy to understand.
<a TITLE="See my user info" href=http:
|
|
|
|
|
i need to get a DataRow[] from MyDataRow.GetChildRows(MyRelation) in a specified order.
right now it simply returns the DataRow[] where the rows are in the same order as in the parenting DataTable.
so is it possible to do this somehow?
(i dont think i can use dataviews or such in this case , since i only have access to a DataRow , and i guess i cant create a DataView from that )
i want the rows to be sorted the way its specified in MyRow.Table.DefaultView.Sort
//Roger
|
|
|
|
|
Please help i need to know how to do this. I can do it in VB.NET but how do i do it in C#?
VB.NET
<br />
Dim i() As Integer<br />
ReDim i(5)<br />
ReDim i(20) <br />
Please help with c#
|
|
|
|
|
static Array Resize(Array src, int newsize)
{
Array dest = Array.CreateInstance(src.GetValue(0).GetType(), newsize);
Array.Copy(src, dest, (src.Length < newsize ? src.Length : newsize));
return dest;
}
<a TITLE="See my user info" href=http:
|
|
|
|
|
Thank you so much I appreciate it.
|
|
|
|
|
leppie wrote:
static Array Resize(Array src, int newsize){ Array dest = Array.CreateInstance(src.GetValue(0).GetType(), newsize); Array.Copy(src, dest, (src.Length < newsize ? src.Length : newsize)); return dest;}
The code has problems if
1) the first value is null
2) if array is an array of interfaces or abstract classes
(for example, the most common type of array, object[], can't be resized by this method)
3) if first value represents an derived class, rather than the appropriate base class
Correction: Use src.GetType().GetElementType() rather than src.GetValue(0).GetType()
Thanks,
Wes
|
|
|
|
|
Wesner Moise wrote:
1) the first value is null
I was aware of that
Wesner Moise wrote:
2) if array is an array of interfaces or abstract classes
(for example, the most common type of array, object[], can't be resized by this method)
Eek! Didnt know that!
Wesner Moise wrote:
Use src.GetType().GetElementType() rather than src.GetValue(0).GetType()
thanks!!! I hate it when you look for a function that is "meant" to be there and you cannot find
<a TITLE="See my user info" href=http:
|
|
|
|
|
Wesner Moise wrote:
Use src.GetType().GetElementType() rather than src.GetValue(0).GetType()
Unfortunately that does NOT work with boxed arrays
<a TITLE="See my user info" href=http:
|
|
|
|
|
What do you mean boxed arrays?
Arrays which are ValueType[] or Enum[] should still work.
Valuetype arrays (int[], byte[]) will still work with this method.
The other case where your resize code doesn't work is if you have an empty zero-length array.
Thanks,
Wes
|
|
|
|
|
Does anyone know format of RegionData ?
Thankx
Wiizi
|
|
|
|
|
Wizard_01 wrote:
Does anyone know format of RegionData ?
Can you be more specific in what you are asking? The RegionData Class[^] class is listed here in MSDN.
-Nick Parker
|
|
|
|
|
I am trying to save at bitmap that has been loaded with
bitmap = (Bitmap) Bitmap.FromFile(FileName);
When I try to save it again with bitmap.Save(FileName); I get an error message:
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll
Additional information: A generic error occurred in GDI+.
If I try to it save with bitmap.Save(FileName2); everyting is fine, but it's not ok to me that you have to give the bitmap a new name. It's like the file is blocked by the system.
I have noticed that the Image Processing for Dummies by Christian Graus have the same problem. How to solve that?
|
|
|
|
|
While working on an Image Processing App I encountered the same kind of
generic error while using the Bitmap.Save() method. I did some searches in the www and it turns out that the Image/Bitmap class uses some type of on-demand loading scheme that requires the file to be open all through the object's life (therefore minimizing the amount of memory being used by big images)
This creates several problems. For instance, when you call the Image.Save("filename") to save the image to same file from where it was loaded, your program crashes because it is trying to overwrite an open file.
One workaround for this would be to save the changes to another file or to use unmanaged code to load all the image to memory.
If the bitmap is not too big you might also consider caching the bitmap in memory, ie:
1. Open the bitmap
2. Do a Bitmap.Save to a memoryStream
3. Dispose of the bitmap object and work with the memorystream
4.When your work is finished save the memorystream to a file.
But be carefull with this last approach when working with big bitmaps (big overhead)
|
|
|
|
|
Well - what is big bitmaps? Mine is about 3000px x 2000px, and i'm making the program as mdi, so there could be up to 20 bitmaps loaded into memory, but of cause you only would have to save one bitmap at the time. Anyway, i'm kind of new to c# (only been programming for a few weeks), so i'm not sure about what memoryStream i about yet. Might the be any othe solutions?
|
|
|
|
|
Well, How about this way?
1. save the bitmap using another name, say temp
2. Delete the old bitmap file
3. rename temp to the old bitmap name.
I realize that this is probably a long way around, but it'll probably save memory for thos big bitmaps
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Thanks, I will try that solution. I have just testet the method with memoryStream - it works, but it used 600 MB of memory!!! I only have 256 MB RAM, so my harddisk went totaly crazy, and even after I had shut down the program, Windows has totaly wierd.
|
|
|
|
|
Hey
I have i Rich Text Box that displays som info with out a visible scroller Vertivcal.
I read a txt file in to a string thats add one char to a temp string(one per second).
This temp string is then loaded in to the Rich Text Box.
I also Selects the last char in the Text Box so its scrolling to the buttom.
With other words, a simple Type writer that writes one char per second.
The problem is:
Every time a adds a char to the temp string and updates the text box with temp string, then it look a bit strange.
Maby you could tell me how to scroll in a Rich Text Box by code.
//Jimmy
|
|
|
|