|
I think you'll need to handle the drawing yourself to do that.
You can get the same effect by using a ListView with the View set to List and CheckBoxes to true, then set the Font of any ListViewItems that you need to have different.
[edit] Just had a look, and the CheckedListBox doesn't support DrawItem so it's going to be a little more difficult if you don't want to use a ListView. You'd have to derive your own class from CheckedListBox and override OnDrawItem there.[/edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I've tryed to handle drawing, but it draws all control and I need one item (
|
|
|
|
|
See the edit to my previous post.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hello. I'm working on a remote desktop program and since I couldn't find a way to create a hook for the video, I'm taking screenshots and send them. Needless to say this is very slow. I'm looking for a method to read the video card buffer directly (only the last changes). This way the cpu doesn't have to process a few MB of data few times per second.
Any input would be appreciated.
|
|
|
|
|
xax wrote: This way the cpu doesn't have to process a few MB of data few times per second.
Let's see. Take a 1024 x 768 x 328 bit color. That's an odd 750KB, updating roughly 60 or more times a second. So we end up with around 45MB of memory that needs to be scanned every second, nevermind any other processing.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
modified on Friday, October 10, 2008 12:07 PM
|
|
|
|
|
leppie wrote: Take a 1024 x 768 x 32 bit color. That's an odd 750KB
hmm....my calculator must be broken...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Whahahahaha! I didnt even notice! Of course there is only 8 bits in a byte
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Well, technically, you did say "odd", and it IS indeed close
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: and it IS indeed close
Like NASA close
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Like Leppie said, dumping the whole screen as a buffer and transmitting will take a huge amount of memory. You should look at the following:
There is a pretty well standardised way of doing this with a protocol called remote frame buffer[^]. You should look into this protocol if you are writing a remote desktop program, as it will give a guide of good ways to do things (Even if you decide not to follow the protocol).
An alternative protocol used by MS is the remote desktop protocol[^]
The general area you are talking about is called Virtual network computing[^].
The general idea behind these protocols is to break the screen down into the smallest possible rectangle primitives and transmit them to be drawn on the client. A common way of reducing bandwidth is to only transmit what has changed between each refresh.
Ultra VNC[^] is an open source implementation of the RFB protocol. You can look at the source code for this to see how they are grabbing the screen.
Simon
|
|
|
|
|
I already know that the algorithm takes a large amount of memory, not to mention CPU. I've read the remote frame buffer documentation and that is why I'm looking for a way to "hook" the program to the video card. The biggest problem is the CPU consumption because the memory can be recycled: let's say 10 times per second I take a screenshot scan it and send only the changes. Still the CPU is at around 25-30% on a single core AMD.
What I want is to get only the changes(the updates) from the video buffer.
|
|
|
|
|
Read the ultra vnc source code. They obviously have a way of doing it that doesn't use that much cpu.
Simon
|
|
|
|
|
How are you accessing the image data? What do you use for screen capture?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: How are you accessing the image data? What do you use for screen capture?
Hi leppie, I'm using the Graphics class to get the screenshot (only 3 lines of code). Accessing the image data is very slow using safe code (GetPixel) so I'm using unsafe to access the memory.
|
|
|
|
|
|
Hey guys
I'm just wrote a simple struct to contain an int and two boolean values. Its is as follows..
struct NodeModuleLevelStruct
{
public NodeModuleLevelStruct(int ModuleID, bool IsActive, bool IsAdvanced)
{
moduleID = ModuleID;
moduleActive = IsActive;
level = IsAdvanced;
}
private bool moduleActive;
public bool IsActive
{
get { return moduleActive; }
set { moduleActive = value; }
}
private bool level;
public bool IsAdvanced
{
get { return level; }
set { level = value; }
}
private int moduleID;
public int ModuleID
{
get { return moduleID; }
set { moduleID = value; }
}
}
Now i need to query a NodeModuleLevelStruct[] using Linq so i have to inherit IEnumerable right?
so ive got
struct NodeModuleLevelStruct : IEnumerable<int>
...int cause i want to check if the given moduleID exists within that array
now the compiler is moaning that i havnt implemented System.Collections.Generic.IEnumerable<int>.GetEnumerator() or System.Collections.IEnumerable.GetEnumerator()
1) Am I on the right track here?
2) How do i implement those interfaces in my struct?
Thanks
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Harvey Saayman wrote: Am I on the right track here?
No, you are doing it wrong
NodeModuleLevelStruct[] is already IEnumerable<NodeModuleLevelStruct> . So all you need to do is:
NodeModuleLevelStruct[] l = ...;
var q = from x in l
where x.ModuleID == 12345
select x;
Also, you should not use a struct in this case AFAICS.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: NodeModuleLevelStruct[] is already IEnumerable<nodemodulelevelstruct>
ah, i didnt know that... it works by just querying the NodeModuleLevelStruct[]
leppie wrote: Also, you should not use a struct in this case AFAICS.
what do u think i should use? And when should one use a struct anyway?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Harvey Saayman wrote: what do u think i should use?
A class. Structs are mostly useless in .NET unless you require their special semantics. Example:
MyType[] list = new MyType[10];
Now define MyType as a class and see what the content is in 'list'. Now do the same but define MyType as struct.
An important point to notice is the way 'instances' are passed around. With structs, a copy of the value of the instance will be made, where classes will just send a reference to itself. So if used wrong, structs can become a big performance/memory killer. There are also other considerations, like modifying structs and things to keep in mind like boxing, that just blurs everything!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
thanks leppie
as always you rock
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
I slightly disagree with Leppie on this one.
I've seen it written many times that classes are easier to deal with and everyone says use them in C#.
If your example is really as simple as you've posted then seeing as each NodeModuleLevelStruct is going to be very small and is only using value types for properties/fields I'd be tempted to keep it as a struct. Small basic structs are easy to deal with, and if you want it to act like a reference type in a method you can always use the ref keyword. I find using structs very useful as I can be sure (so long as I've coded them properly) that my original instance is unchanged and if I want to change it, I can use ref or assign a copy's values to it.
It depends on how big it is, what it contains, and how you plan on using it.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: I slightly disagree with Leppie on this one.
What disagreement? Ok, it's ever so slight.
I think a good rule of thumb is to use structs only for small immutable types (the OP's is mutable, and hence can fall into the 'modification' trap).
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: ever so slight
It's a good rule of thumb but one that can be ignored (carefuly) if the structure is only using integral types (as in the OP's) or other structs that only contain integral types. Take the Size struct as an example. It's not immutable, but a struct makes perfect sense and using it within your own struct would be good too.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: Take the Size struct as an example. It's not immutable, but a struct makes perfect sense and using it within your own struct would be good too.
The Size struct is not a very good example, just because it's mutable.
If you need a type that is mutable, you should use a class, not a struct. It's so easy to accidentally change a copy of the struct instead of the struct.
As I am sure that you know, to safely change a property in a struct in an array you would have to:
NodeModuleLevelStruct temp;<br />
temp = theArray[42];<br />
temp.IsActive = true;<br />
theArray[42] = temp;
With a class, you can just do:
theArray[42].IsActive = true
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah - and that's exactly why I like to use them - only when appropriate of course.
I can work on the copy, make any changes I like and then just forget the whole thing if I don't want/need to commit them. If it's a class, to have that flexibility you have to implement some sort of cloning method and work on the clone, then you still have to remember to reassign.
I know where you're coming from, and agree to a point, but the blanket statement that if it's mutatble you should use a class, whilst it may prevent errors, isn't strictly true IMHO.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|