|
hi,
Why don't u do some reading and then ask some serious and clear questions. cause no body can give u a lecture in c# on a discussion board.
THis board is for discussion not for lectures
Jamil Abou Khalil
|
|
|
|
|
The taskbar has nothing to do with it. If you want to manipulate other windows currently running, you'd have to send them messages. This can be done in C# indirectly using windows API calls. The messages you'd look for would start with WM_, short for "Windows Message". The functions you'd use to send these messages are PostMessage() and SendMessage() . I'll let you kmnow the difference from your MSDN.
Look for P/Invoke section in C# articles page. You'd find some useful articles on how to call the above functions from your C# code.
Regards
|
|
|
|
|
hey, hope somebody can help me on this... i need to read all the files from a cd... how should i start?.. is that can be done in c++ or c#?
|
|
|
|
|
|
Iv01 wrote: i need to read all the files from a cd
Define "read"? Read them as binary, text, hex, etc... or just copy them somewhere else?
Iv01 wrote: how should i start?
By making yourself clear first I guess. Also have you done some reading in the article section first?
Iv01 wrote: is that can be done in c++ or c#?
File IO can be done in any language. C# isn't that weak or God sake!!
Regards
|
|
|
|
|
I am trying to insert an item at a specific index. However it puts the new item at the end of the list. Not where it is needed.
There is only one exception to this. If I switch the view to 'list' it puts the item in the correct place.
Does the 'Items.Insert(5, lvitem)' command only work when in the 'list' view? If so, what is the best way of ordering items and adding items where I would like them to be put?
Thanks in advance,
Phil
"Rules are for the obedience of fools and the guidance of wise men"
|
|
|
|
|
Phillip Hodges wrote: Does the 'Items.Insert(5, lvitem)' command only work when in the 'list' view?
No, but the behavior is effected by having more than one "group". I was researching this but never got back to it. My next phase was going to look at using the "group" interface for inserting.
led mike
|
|
|
|
|
Thanks for that... Will look into it...
Phil
"Rules are for the obedience of fools and the guidance of wise men"
|
|
|
|
|
Phil, I went back to work on that project and got groups working. How are you doing with it?
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
|
|
|
|
|
I'm using a textbox to display a short running buffer for character data with new data being appended to the right of the string and old values falling off the left end. I'm measuring the length of the string in pixels to determine if I need to remove characters from the front to make it fit. The issue I have is that I can only get the total width of the textbox, not the width of the area available to display text within it. Is there any way I can get that value for use directly instead of coding in a magic number that appears to work for all testcases?
Graphics g = TheTextBox.CreateGraphics();
while (g.MeasureString(theString,TheTextBox.Font).Width >this.TheTextBox.Width -5)
theString = theString.Remove(0,1);
|
|
|
|
|
dan neely wrote: Is there any way I can get that value for use directly instead of coding in a magic number that appears to work for all testcases?
They hide that information in the documentation[^]
led mike
|
|
|
|
|
How do I perform a binary search on an array with a struct type?
Lets say I have this as my struct:
[StructLayout(LayoutKind.Explicit, Pack=1)]
public struct allInfo
{
[FieldOffset(0)] public byte rating;
[FieldOffset(1)]public ushort movieId;
[FieldOffset(3)]public uint id;
}
The I have an array:
allInfo[] example = new allInfo[100];
How do I do a binary search just for movieId?
I want to do something like:
loc = Array.BinarySearch(example, mId);
where loc is the index of the element in array example where example[loc].movieId = mId
|
|
|
|
|
You create a custom comparer for the structure and use the overload for BinarySearch where you can specify a comparer.
---
b { font-weight: normal; }
|
|
|
|
|
I thought it might have something to do with a comparer. Comparers confuse the hell out of me, could someone provide an example of one along the lines of what I'm trying to do?
|
|
|
|
|
Something like:
public AllInfoComparer : IComparer<AllInfo> {
public int Compare(allInfo a, allInfo b) {
return a.movieId.CompareTo(b.movieId);
}
}
---
b { font-weight: normal; }
|
|
|
|
|
The compiler didn't like your example so I tired this:
class movieIdCompareValueClass:IComparer
{
public int Compare(allInfo a, allInfo b)
{
return a.movieId.CompareTo(b.movieId);
}
}
except I get this now:
test.Class1.movieIdCompareValueClass' does not implement interface member 'System.Collections.IComparer.Compare(object, object)'
I tried changing public int Compare(allInfo a, allInfo b) to public int Compare(object a, object b) but I got an error saying that movieId isn't part of object.
the compiler doesn't like adding <allInfo> after :IComparer.
Any idea why this isn't working?
|
|
|
|
|
kshet26 wrote: the compiler doesn't like adding <allinfo> after :IComparer.
Any idea why this isn't working?
Because you are not using C# 2.0, so generics is not available.
kshet26 wrote: I tried changing public int Compare(allInfo a, allInfo b) to public int Compare(object a, object b) but I got an error saying that movieId isn't part of object.
You have to cast the objects to allInfo before accessing the properties:
return ((allInfo)a).movieId.CompareTo(((allInfo)b).movieId);
---
b { font-weight: normal; }
|
|
|
|
|
Hi, In order to instantiate a HTMLDocument object, I need to load the URL or HTML to a web browser control. So, I have to place a web browser control on my form which really an inefficient way. Is there any way I can instantiate a HTMLDocument object just from HTML Stream ? like ,
IHTMLDocument2 doc = (IHTMLDocument2)SOME_CLASS.SOME_METHOD(string HTML_CODE) ;
Instead of
IHTMLDocument2 doc = (IHTMLDocument2) webBrowser1.Document;
Thanks
|
|
|
|
|
I have this method from an ocx that is expecting safearray object as arguments
ocx.GetData(ref object ySafeArray, ref object xSafeArray, ref int pts, ref double xbeg, ref double xend);
How do I create a SafeArray object in C# for the first two arguments? I did something like this...but that does not seem to work.
object yArray = new object();
object xArray = new object();
Thanks
|
|
|
|
|
|
Hi, is there any good tools available for cleaning up unnecessary codes and tuning up the codes for better performance ? (C#)
Example : Deleting all unused event handlers which was not automatically removed after deleting the control from the form.
Thanks.
|
|
|
|
|
Hi there,
I’m trying to implement a plug in API in a application and I’m having problems in getting the Custom Attribute from an Assembly.
First the custom attribute is something like this:
[global::System.AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)]<br />
public class AssemblyPluginAttribute : Attribute<br />
{<br />
readonly string pluginName;<br />
<br />
public AssemblyPluginAttribute(string PluginName)<br />
{<br />
this.pluginName = PluginName;<br />
}<br />
<br />
public string PluginName<br />
{<br />
get<br />
{<br />
return this.pluginName;<br />
}<br />
}<br />
}
Than in order to find a reference to this custom attribute I added to the plug-in project the following line.
<br />
...<br />
using Enki.UI.ComponentModel;<br />
<br />
[assembly: AssemblyPluginAttribute("TestPlugin")]<br />
<br />
namespace TestPlugin<br />
{<br />
...<br />
Now ... to find if its a plug-in type assembly i look through the custom attributes of the assembly in order to find one matching with the one i defined (AssemblyPluginAttribute).
The following line returns null list.
<br />
Type AttType = typeof(Enki.UI.Plugins.AssemblyPluginAttribute);<br />
<br />
object[] obj = assembly.GetCustomAttributes(AttType, true);<br />
and the next one too...
Attribute[] attlist= Attribute.GetCustomAttributes(assembly,AttType);
but if instead of one of this two lines i use the following code
...<br />
foreach (Attribute att in Attribute.GetCustomAttributes(assembly))<br />
{<br />
if (att.GetType().FullName.CompareTo(AttType.FullName)==0)<br />
return true;<br />
}<br />
<br />
...<br />
it matches the full names!! I’ve tried many other ways to establish a possible comparison but none has the same result. I know, that if i found a way to get the result i desired i should stick to it an go on but I believe that this might lead me to a dead end in the future.
Please, can anyone help me... to "see the light in the end of the tunnel"!
Tanks
Pedro M.
|
|
|
|
|
Here is the factory method I use in a plug-in application I have. You do not appear to have a need for the "ICustomAttributeHandler" aspect of the logic so you should ignore that part.
public static object newInstanceFromCustomAttribute( Assembly assm, System.Type tAttribute, ICustomAttributeHandler handler)
{
object oret = null;
Module[] modules = assm.GetModules(false);
for(int nMod=0; null == oret && nMod<modules.Length; nMod++)
{
Type[] types = modules[nMod].GetTypes();
for(int nType=0; null == oret && nType<types.Length; nType++)
{
object[] attributes = types[nType].GetCustomAttributes(tAttribute, true);
for(int nAttr=0; null == oret && nAttr<attributes.Length; nAttr++)
{
if( handler.attributeQualifies( attributes[nAttr] as Attribute))
oret = assm.CreateInstance( types[nType].FullName);
}
}
}
return oret;
}
led mike
|
|
|
|
|
Hi mike,
i believe that i miss guided you. I dont want to find which types in an assembly have a custom attribute. I pretend to find which assembly has a specific custom Attribute.
So, want happens is I have an assembly that i know for sure that the custom attribute and i the only way that I get it saying that it has that attribute (return true) is comparing their FullName which,i think, is a rude solution to the problem.
Tanks for your help.
Best Regards
Pedro M.
|
|
|
|
|
hi
how to deploy my app with crystal report XI ? i am use VC# 2005.
and my another question is that how to access crystalreport objects (like text object) and change it's value ?
thanks.
|
|
|
|