|
How can I read a specific bit or series of bits (as a bit array) from a file. I can use a file stream and binary reader to get specific bytes but I do not know how to easily convert this into a bit array (at least not very efficiently).
Jim
|
|
|
|
|
To turn a byte into bits, bool is the most obvious choice ( the only one I can think of with 2 states ) and you & the value with 0x1, 0x2, 0x4, 0x8, ox10, etc to strip the bits.
I reckon this is what you've thought of, but I don't know of any more efficient way, excepting that I'd be more inclined to do this when I need the value, and not store it as bits in memory.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I still wonder if there's a quicker way - but speed is not essential for what I am doing - reading mp3 header information.
Jim
|
|
|
|
|
How can I set the position that is used for determining which item is chosen by the user pressing the up/down arrow keys? I've tried .Items[pos].Selected which works if called after the form is loaded, but it doesn't work when called from the constructor.
|
|
|
|
|
Answering my own question. making the call in the load event handler did the trick.
|
|
|
|
|
I'm creating a class that inherits from TreeView, the structure of the treeview ends up like this:
MapCategory
-Map
--MapFolder
---MapContents
-Map
MapCategory
-Map
etc. The class has two view modes, which arrange the contents into different folders. It's a complete change so I clear the Map node's children and recreate by parsing through a nested Hashtable.
However this is slow, parsing through the hashtable doesn't take long at all, but removing/adding nodes does take a noticable time. I tried to serialize the two views, but TreeNodeCollection isn't serializable, and copying the nodes out of the collection into an array, serializing it, then deserializing it into an AddRange() method call doesn't improve speed at all, since it still has to add them all.
Is there any quicker way of switching these views?
|
|
|
|
|
Could you not just have 2 treeviews, one for each view. Then just display the correct view?
|
|
|
|
|
That's my last resort, however I would prefer a solution that doesn't use up that much memory. Since each map can take up to 2MB of memory for one view, and 6MB for the other view, so having 8MB for each map could be too much. Actually on second thoughts that's not how much the nodes take up, I was watching the memory in the Task Manager, forgeting it's also loading the map at the same time. But memory is still an issue, just not that big an issue.
-- modified at 13:00 Wednesday 30th November, 2005
|
|
|
|
|
Don't know if you've solved it yet, but the tree exposes two functions called BeginUpdate and EndUpdate . Put the BeginUpdate before any tree modifications and EndUpdate when you're done. Should do the trick.
--
Joel Lucsy
|
|
|
|
|
Pen p = new Pen( Color.Blue );
p.EndCap = System.Drawing.Drawing2D.LineCap.Triangle
//How do I get it triangle to be bigger?
//How do I get a dashed line?
Thanks a lot in advance.....
|
|
|
|
|
Hello Dear SkunkedWorks
For drawing Dashed Line use these sample codes :
dashValues is an array of dash's length.
float[] dashValues = {5, 2, 15, 4};
Pen blackPen = new Pen(Color.Black, 5);
blackPen.DashPattern = dashValues;
e.Graphics.DrawLine(blackPen, new Point(5, 5), new Point(405, 5));
Bye.
|
|
|
|
|
I like formatting my constructor initializers like this:
public MyClass(int a) :
base(a)
{
} but for some reason VS 2005 likes formatting them like this:
public MyClass(int a)
:
base(a)
{
} It's really annoying and I haven't found a way to prevent it. Anyone have any tips?
Thanks,
Alvaro
I cannot take anything the Bush administration does seriously. The corruption, the cynical disregard for humanity, the cronyism and incompetence, all wrapped in a slimey flag of ultra-marketed nationalism repulses me. -- consdubya from fark.com.
|
|
|
|
|
VS2005 has alot of autoformating features that you can turn on and off. You can even turn on adding a space before and after a . for a class member. Its one of the many settings, but I don't know why they have some of them. I would look in the options->Customize and see if you can find these autoformat settings.
Steve Maier, MCSD MCAD
|
|
|
|
|
Steve Maier wrote: would look in the options->Customize and see if you can find these autoformat settings.
I've looked but found nothing. I'm hoping there's some undocumented Registry setting or something like that to allow me to adjust it.
I find it hard to believe the Microsoft guys actually like using that convention. I've never seen it before -- what a waste of space!
Thanks,
Alvaro
I cannot take anything the Bush administration does seriously. The corruption, the cynical disregard for humanity, the cronyism and incompetence, all wrapped in a slimey flag of ultra-marketed nationalism repulses me. -- consdubya from fark.com.
|
|
|
|
|
When my listview control loses focus the selected item is unhighlighted but not removed from the SelectedItems collection. How can I keep it highlighted even after a different control gains focus.
|
|
|
|
|
dan neely wrote: How can I keep it highlighted even after a different control gains focus.
Sent the .HideSelection property to false .
Share and enjoy.
Sean
|
|
|
|
|
I have a user that is wanting to automatically log in to some web pages, and I've got most of them doing this, but there's still one that's giving me fits that I'm hoping someone can help me with. I'm writing the code in C#, and am displaying the webpage via the Microsoft Web Browser COM component. The webpage that I'm having issues with is popping up a login box that looks very much like an AD login box. Any idea how I can capture control for this box so I can programatically populate it and hit the "OK" button?
|
|
|
|
|
Some more information:
I'm using the old VB WebBrowser COM Component (AxSHDocVw.AxWebBrowser). I think I've narrowed it down to the fact that I need the headers passed to the Navigate method to include the authentication information, but I'm not quite sure how to do this. Does anyone have any sample code (like this for Posting) for the Headers/Authentication?
Thanks
-- modified at 15:00 Wednesday 30th November, 2005
|
|
|
|
|
Hi.
I am trying to build a VS 2005 addin and I want to add a commandbar with a custom image (I am using VS's AddNamedCommand and a satellite dll). It seems that if the image is 16-colored then it is correctly attached to the commandbar. If it is 256-colored, then all I can get is a blank (missing) image. Is there any way to have 256 bitmaps attached to custom commandbars? Thanks.
Daniel
|
|
|
|
|
Hi,
I have some kind of synchronisation problem. I have a C# Word Add-in,
and in it I want to close a file and then delete it. I use code as follows,
// Close the file
pDoc.Close(ref saveChanges, ref missing, ref missing);
// Delete the file
System.IO.File.Delete(pDocStr);
This works fine for a small file, but for a very big file I catch an
exception that says that "the file x.doc being used by another
process".
Anybody any suggestions for handling the synchronisation?
Thanks in advance
|
|
|
|
|
Hi,
I have not mailed to help you in solving your query. In fact seeing your query I thought you might help me in solving my query. I think you have used word document in C#. I am getting problem in opening existing word document in c#. I hope you may help me in solving it. Thanks in advance
Hiral
|
|
|
|
|
if i can help then sure, send me some details of the problem.
|
|
|
|
|
Hi,
Thanks for replying. Actually I got my solution.Anyways thanks for your help.
Hiral.
|
|
|
|
|
Hi Everyone,
I got this code:
if(file.Name.StartsWith(Cont_"))
{
engine = new FileHelperEngine(typeof(Contact));
Contact[] details = (Contact[])engine.ReadFile(file.FullName);
foreach(Contact info in details)
{
txtoutput.Text += info.toString();
}
}
else
{
engine = new FileHelperEngine(typeof(OSFUNOUT));
OSFUNOUT[] details = (OSFUNOUT[])engine.ReadFile(file.FullName);
foreach(OSFUNOUT info in details)
{
txtOutput2.Text += info.toString();
}
}
and wanted to change it to this sort of code:
System.Type type;
if(file.Name.StartsWith("Cont_"))
{
type = typeof(Contact);
}
else
{
type = typeof(OSFUNOUT);
}
engine = new FileHelperEngine(type);
type[] details = (type[])engine.ReadFile(file.FullName); *****
foreach(type info in details) ****
{
txtoutput.Text += info.toString();
}
However the lines with the **** are giving me problems, how do I create an instance of that type?
I could change it to
object[] details = engine.ReadFile(file.FullName);
foreach(object info in details) ****
{
txtoutput.Text += info.toString();
}
however i still need then to cast info to the class I'm working with...how would i do this (type)info doesn't work...
thanks.
|
|
|
|
|
This should work.
Array details = engine.ReadFile(file.FullName) as Array;
if (details == null)
return;
for(int i=0; i < details.Length; ++i)
{
txtoutput.Text += details.GetValue(i).toString();
}
If you need to access a non virtual method of the object.
Use type.GetMethod("methodName").Invoke(details.GetValue(i), null); or
type.GetProperty("propertyName).GetValue(details.GetValue(i), null);
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
-- modified at 14:27 Thursday 1st December, 2005
|
|
|
|