|
leppie wrote:
Although thats NOT the solution, is that not just the same as Monitor or using the lock command?
Yes. Your callback being C code, I thought of suggesting WIN32 CriticalSections.
leppie wrote:
Could it be that .NET is moving function addresses around?
From watching sscli code, the only "good" reason for addresses to be rebased on-the-fly would be appdomain switch, but that sounds odd enough.
|
|
|
|
|
.S.Rod. wrote:
From watching sscli code, the only "good" reason for addresses to be rebased on-the-fly would be appdomain switch, but that sounds odd enough.
Too odd But thanks for the info.
I have made and implemetation of the callback and it works flawlessly in a "static" context. O well, I can just internally do that and pass it onto an instance delegate and let consumers of the assembly register that delegate. Maybe an event perhaps...
Cheers
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Here is some info I got from the author:
"Yep, callbacks need to be static member functions. There is no "this" pointer in static functions though, so you should pass "this" as the user parameter in the BASS_RecordStart call. This applies to C++ anyway, but I guess C# too?"
Now it appears that C++ callbacks can be instance delegates, but C callbacks has to be static. Any idea how I could pass this as an int into the start method or will marshalling do its own thing?
Cheers
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
leppie wrote:
Now it appears that C++ callbacks can be instance delegates, but C callbacks has to be static. Any idea how I could pass this as an int into the start method or will marshalling do its own thing?
"this" is on the call stack. (the meaning of all ldarg.0 code ops before each function call).
|
|
|
|
|
.S.Rod. wrote:
"this" is on the call stack. (the meaning of all ldarg.0 code ops before each function call).
English? Is it possible to convert an object to an int? Or do I need to reference something else, like a handle so I can recreate the object in the static function?
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I tried to compile the following pattern to match the filename from a complete file path:
(?!.*\\\\).*
Example:
"C:\My Programs\Office\Word.exe" - match result : "Word.exe"
This works fine when I create an instance of System.Text.RegularExpressions.Regex.
However, in the compiled form the pattern above would always result in:
"C:\My Programs\Office\Word.exe"
Does anybody know what the reason is? Or do you have a better pattern to use?
Thanks!
|
|
|
|
|
Try this one:
.*\\([^\\]*)
Don't forget to duplicate the \ if in C#.
You'll have two matches, the second one is the file name.
It is a bit slower, because it has to do some backtracking, but may work in your case.
I see dumb people
|
|
|
|
|
Thanks for the tip Dan,
I tried the pattern and here's the result:
--------------------
.*\\([^\\]*)
C:\My Documents\foo.doc
Matching: C:\My Documents\foo.doc
0 => C:\My Documents\foo.doc
1 => foo.doc
--------------------
Is there an option I could set so that the first match gives me the intended result right away?
thanks again
|
|
|
|
|
Investigate the Path class for this, instead of using regular expressions. There's a method in there made for what you are trying to do.
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
If the file name is in the middle of a text, the System.IO classes won't help him, e.g., for highlighting paths and URLS on e-mails.
I see dumb people
|
|
|
|
|
I've got a treeview/listview pair in a backup program that acts similar to windows explorer, enumerating all drives,folders and files on a PC. I've set it up so there are checkboxes for entries in both controls, so you can select entire folders or just individual files...
I'm wanting to save all the checked items to a "job" file so the backup component can read the job file and perform the backup according to the selections.
Do I have to build this information dynamically (using an array or collection), or do the treeview/lisview controls keep this info around for me?
thanks.
|
|
|
|
|
The .NET treeview has no built-in serialization feature. For more info[^].
|
|
|
|
|
I am trying to redistribute a program that requires both the .net framework and MDAC version 2.6 or higher. I am trying to use microsofts examples of how to create one setup program that will install these components, but i want to use both together. I can implement both seperately but the moethods they give both create a new exe file that test for either MDAC 2.x or the presence of the .net framwork, installs as needed and then continues with my MSI program. the examples check for one OR the other, and the problem is both programs link to the MSI from my application, and I would like to have one setup that does a MDAC search, then goes to the .net search then installs my apps MSI file. anyone know how to do this?
thanks in advance
dan
|
|
|
|
|
A few hints :
First, use only merge modules (*.msm files) provided by MS.
Second, checking the installed MDAC version does not require a thorough procedure. If you use the MS COM Checker (provided in the MDAC MS portal), it's a total mess and quite honestly for most needs this represents 10x times too much overhead. My hint is to check out the dll file version (xx.xx2.yy.yy2 = major, minor, build major, build minor) of one the dlls which happens to be upgraded with all MDAC version : for instance msado15.dll. You've got a MS online article which tells the public version of that dll for each major MDAC release.
Here is the mapping table I use (C code):
typedef struct _MDACVERSION
{
int nMinor;
int nBuildMajor;
char *szPublicName;
} MDACVERSION;
MDACVERSION tabMDAC[] = {
{ 50, 4403, "2.5 RTM" },
{ 51, 5303, "2.5 SP1" },
{ 52, 6019, "2.5 SP2" },
{ 53, 6200, "2.5 SP3" },
{ 60, 6526, "2.6 RTM" },
{ 61, 7326, "2.6 SP1" },
{ 62, 7926, "2.6 SP2" },
{ 62, 7400, "2.6 SP2 Refresh" },
{ 70, 7713, "2.7 RTM" },
{ 70, 9001, "2.7 RTM Refresh" },
{ 71, 9030, "2.7 SP1" },
{ 0 , 0 , "" }
};
|
|
|
|
|
Owner-Draw TreeView with SetStyle(ControlStyles.AllPaintingInWmPaint|ControlStyles.DoubleBuffer|ControlStyles.UserPaint,true);
Problem with the overriden OnPaint methode:
I added two nodes. When the control appears the first time, the OnPaint() methode panits only the first node!? When I move the mouse over the invisible second node then OnPaint draw the second node(but goes through OnPaint twice!?). So the nodes ar only painted when I move the mouse over the nodes. Refresh() or Invalidate() changes nothing.
What could that be? Any suggestions that the TreeView paints its nodes the first time?
|
|
|
|
|
You cannot be using OwnerDrawn support and "ControlStyles.AllPaintingInWmPaint|ControlStyles.DoubleBuffer|ControlStyles.UserPaint" because they are two different, mutually exclusive things.
In Windows you usually can paint a control in three ways:
1- OwnerDraw which is when you handle the OnDrawItema and OnMeasureItem messages. In this situation the control ask you to do the drawing of a particular item at right time. Some of the oldest controls support this techinque: menus, combo box, etc.
2- Custom draw. This is a more fine grained version of the OwnerDraw version, here you have the oportunity to draw just part of the item instead of assumming full resposabilty for the whole drawing. Some of the more sophisticated common controls support this technique: TreeView, ListView.
3-. User Paint: You do the whole drawing yourself. In this case you don't have any help but you have full control as to what to paint. This is what you need to use when you are going to write a control from scratch. This is by far the best technique to write powerful controls because you have totally control of the painting.
One last thing: how are you using OwnerDraw techinque for the TreeView control? As far as I known the TreeView control does not support OnMeasureItem or OnDrawItem methods. You could use CustomDraw but only if you hack the support yourselve using the fact that the .NET TreeView is just a wrapper for the native TreeView control in the Common Control library.
Regards,
Carlos H. Perez
|
|
|
|
|
Thank you very much for answer!
I found now a Sample Solution which seams to be good.
So I will try it with CustomDraw with WndProc(..). But I fear that it will flicker.
It's really a problem that .NET not supplies OnDrawItem and OnMeasureItem for TreeView; that's why I have problems to solve it. I cannot understand this. OwnerDraw is - as I mean - often used; so why these Microsoft Programmers didn't implement it for us?
One question: to do TreeView OwnerDraw with OnPaint(...); how could I do this?
It would be very usefull because I can set the DoubleBuffer Flag and paintings are without flicker. I've tried but there were unlogical things happening; just the first item was painted. The rest of the items were only drawn when I moved the mouse over the other items? Strange.
Can you help me?
Thanks
Stefan
|
|
|
|
|
I use "CustomDraw" on my sample article TreeView control and flickering is almost non existing due in part to some technique that I use to draw the node in a double buffer that I passed to the tree control itself. I don't know what you are looking for but my article show pretty well how to CustomDraw the items.
Regards,
Carlos.
|
|
|
|
|
I've downloaded your article. I had some problems to make it to draw as I like. I could not really understand the following code:
// Set the text and background text color to the window bakcground
// text so that we don't see the text being painted
tvcd.clrText = ColorUtil.RGB(ForegroundColor);
tvcd.clrTextBk = ColorUtil.RGB(BackgroundColor);
But now it works.
Thanks Carlos!
Stefan
|
|
|
|
|
Little problem: I copied your code and made my own TreeNodePainting. When I startup my application I want to select the first node; the first node is selected but not painted in the Focused Colors. When I click into the TreeView (where no nodes are) then the first node is selected. Can you help me what that could be and how to resolve this problem?
Thanks
Stefan
|
|
|
|
|
Hello,
I am trying to use a context menu on a tree view control in my application. The problem is when I right click on an item in the tree view I want my Selection change event of the tree view to fire before the context menu is fired. What is happening is the user is right clicking on a tree node, it is highlighting what they select BUT, the treeview.selectednode was the preivous node they selected! It seems to be many ppl would want to selection change event to fire first?! how can i get around this? thanks alot
S
|
|
|
|
|
Maybe, and I do mean maybe, you could put an Application.DoEvents() at the top of your menus Popup handler, allowing the SelectionChange event to trigger before continuing.
If that doesn't work on its own (because the SelectionChange event doesn't trigger quickly enough) then add a private bool variable, set it in the SelectionChange event, loop through Application.DoEvents() until it's set and then clear it again in Popup.
Just a couple of ideas, I don't know if either will work.
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
Anonymous wrote:
The problem is when I right click on an item in the tree view I want my Selection change event of the tree view to fire before the context menu is fired. What is happening is the user is right clicking on a tree node, it is highlighting what they select BUT, the treeview.selectednode was the preivous node they selected!
This is the expected behavior: try it out in Explorer, if you right click a node it does not select it (it will appear selected, but once the context menu disappears the original node will remain selected).
Rather than relying on the selected node property, you can use the treeview.GetNodeAt method to get the node that was right-clicked on. You can get the current position of the mouse from the MouseEventArgs passed into the MouseDown event handler.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Does anybody knows where to get code for a flicker-free and ownerdraw Treeview?
Thanks
Stefan
|
|
|
|
|
is there anyway i can turn a string (whithout knowing what the string will be)into a exception of that string (for exsample x is System.Exception) how can i perform this case ? any ideas? or would i have to involve something like a foreach statement and i would need to parse though all of the classes within the namespace to compare it to a string.... i have no clue... all help would be much appreciated.
Jesse M
|
|
|
|