Diamonddrake 397 Master Poster

you just aren't removing the item from the original collection.

this is what you need to do, modify the code that adds the new items to the listview to store a reference to the myObject instance in its Tag property. then on your code that removes the item from the istview, first remove the item stored in its tag from your List<myObject> collection.

Its really very simple. I don't undertand why you are having a problem. I am going to show you some example code, this code is NOT just paste in code for your application. I am just going to show you HOW its done with a different example.

//this method will add new item to both your listview and the datalist that holds the data to be saved
        public void addItem(ListView listViewToAddTo, List<someObject> listThatHoldsData, string Col1, string Col2)
        {
            //create the listview item to display it in the listview
            ListViewItem newItem = new ListViewItem(Col1);
            newItem.SubItems.Add(Col2);

            //create the dataobject that holds the information
            someObject newSomeObject = new someObject();
            newSomeObject.Column1 = Col1;
            newSomeObject.Column2 = Col2;

            //add the data object to the main list
            listThatHoldsData.Add(newSomeObject);

            //set the data object reference to the tag object of the lsitview item that way we can find it easy
            newItem.Tag = newSomeObject;

            //finally add that item to the listview
            listViewToAddTo.Items.Add(newItem);

        }

        public void removeItem(ListView listViewToRemoveFrom, List<someObject> listThatHoldsData)
        {
            //get the selected item
            ListViewItem selecteditem = listViewToRemoveFrom.SelectedItems[0];

            //get the original object, stored as a reference in the selecteditem's tag
            someObject selectedObject = (someObject)selecteditem.Tag; …
Diamonddrake 397 Master Poster

Typically a thread in a forum handles only one question. I can see how this might not be worth branching out a new thread. But I think you have hand more than enough help from the community to mark this thread as solved regardless if you have worked all the bugs out of your program.

Diamonddrake 397 Master Poster

you could mark this thread as solved using the mark as solved link above the quick reply box. That way I actually get credit for helping you.

Diamonddrake 397 Master Poster

Ok, the only problem was that you created the myObject class as an internal class of one of your forms. This made it not available to all the other classes in the application. I simple cut it and pasted it into a new class file, in the root of the namespace and it compiles fine.

Diamonddrake 397 Master Poster

why don't you just upload the code to daniweb, click advanced editor and click manage attachements. anyway, I'll haev a look

Diamonddrake 397 Master Poster

Apparently there are properties build into the open and save file dialog boxes for doing this.

// Add Pictures custom place using GUID.
    openFileDialog1.CustomPlaces.Add("33E28130-4E1E-4676-835A-98395C3BC3BB");

    // Add Links custom place using GUID
    openFileDialog1.CustomPlaces.Add(
        new FileDialogCustomPlace(
        new Guid("BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968")));

    // Add Windows custom place using file path.
    openFileDialog1.CustomPlaces.Add(@"c:\Windows");

    openFileDialog1.ShowDialog();

But for a more global approach you can modify the registry.

http://www.auxtools.com/placesbar.html

ddanbe commented: He, we should definitly meet in a bar someday ! +8
Diamonddrake 397 Master Poster

that was close enough for me to search and find the answer. Many people call it the sidebar, but its actually called the "Places bar" Thanks Danny.

Diamonddrake 397 Master Poster

At the top of the class file that contains the XMLSaver there should be using directives for the serialization of xml using System.Xml.Serialization; but if you just copied the entire file, then the namespace declaration just below that probably still has the old project namespace.

just change namespace WinFormsApplicatin1.Utilities //or whatever it is

to namespace Utilities should work then

Diamonddrake 397 Master Poster

I can't seem to remember what it's called, nor can I articulate a concise explanation to even begin searching the net. (I tried) Does anyone know what that list of Icons like my computer/mydocuments ect that appear to the left in windows XP open and save dialog boxes? I know that it can be edited. Visual Studio on xp does it for its own dialogs. and I seem to remember that you can globally edit it too.

Does anyone remember its name, or even better know any good links to modifying it in C#. Ultimately what I would like to do is have my application set a directory to that shortcut bar globally in XP and to the treeview favorites in vista and 7 So that when you are working in other applications that use the standard open/save dialogs that it's easy to find the project directory you are working in.

Ideas?, comments? links? the proper name of those icons would be nice too.

Diamonddrake 397 Master Poster

did you make sure to create a myObject class in your other project.

They are based on a class that represents the myObject object. It is defined at the end of the main forms .cs file

Diamonddrake 397 Master Poster

OK, This is definitely homework. No doubt about it. If you are really serious about programming then something this simple should really be figured out on your own through research on the web.

if you studied the XML classes in the .net framework you wouldn't have any problem with this. But personally I feel that manually creating a xml document is ridiculous. So I use XML serialization.

After all the help that the rest of the community here as provided, you should have been able to at lest hack up something that worked. But i have edited your project making minimal changes as possible, commenting all the changes, but still making the application work well. hopefully you will read through it and take the time to understand all the changes that I made. With programming there is NEVER only one way to do something. 100 programmers are likely to come up with 150 different ways to do the same thing.

If you have any questions about how or why just post back.

Diamonddrake 397 Master Poster

monotouch is it. and that still requires mac os x

There is no way to write iphone/ipod/ipad software on a windows pc.

Diamonddrake 397 Master Poster

There may be leading or trailing whitespace in the textboxes, that would mean that the string passed to the ToInt32 method could be "3546 "; this would cause an error.

try using Convert.ToInt32(textbox.Text.[B]Trim()[/B]); this will make sure there is no whitespace, also ddanbe has a pretty good code snippet in the code snippet library of a textbox control that only accepts digits and decimals, so it would guarantee no parse errors.

Diamonddrake 397 Master Poster

I think its the concept your are struggling with, its just as important to know how code works, as it is to know how to use it. Before you jump into something complicated it helps to write some pseudo code showing the steps involved in a process before you ever write any real code.

Also, for small controls, like a textbox, its fine to use the control to store the data like a string. and not save it anywhere else. But when you are working with a good amount of data that you need to manipulate. It helps to create a List of objects and just use the listview control to display that data. not keep track of it.

basic pseudo:
onLoad
- Create a List<myObject> to hold your working data.
- check for a saved file, and populate that List with data from it.
- populate a listview with the data from your List.

onItemAdded
- add the item to the List.
- add the item to the listview.

onClose
- save the List to a file

It's a good practice to write support methods, like a method that takes an List<t> and populate a listview the way you like it. and of course methods that load and save the data, like earlier ones in this thread. I personally like XMLSerialization, but plain text is faster. Its just more complicated and it doesn't save your data as …

Diamonddrake 397 Master Poster

Its more likely that you have an assembly loaded that relies on the older version of that dll. Don't forget that your project references are important, but many dlls make references of their own that you don't see.

Diamonddrake 397 Master Poster

the substring is an instance method of type string that takes an indexed start int and returns that character in the string to the end.

so, if string line = "size=2699309";
then line.SubString(5) would count to the index of 5 or the the 6th character in the string and return that character til the end of the string.

s(0)i(1)z(2)e(3)=(4)2(5)699309

since the 2 in 2699309 is in the Index position of 5. the 2 til the end of the string is return as a new string 2699309

MasterGberry commented: Perfect explanation +1
Diamonddrake 397 Master Poster

I needed a very simple multi-line label control for a project I was working on, It had very simple requirements. It needed to draw text in any font, in any color, on multiple lines with vertical and horizontal alignment control.

So I hacked up this little class. Just as easy to use as a standard label control.

kvprajapati commented: Cool code. +11
ddanbe commented: Cool code indeed! +8
Diamonddrake 397 Master Poster

either decompile it and add its classes to the exe project, or extract it and late bind it. It is possible to late bind to it from memory but it requires that you use a windows api to register a filepath to a memory location. Its not a good idea either way.

Diamonddrake 397 Master Poster

Here is a partial example of the concept, this isn't too advanced so you'll probably get a lot out of the experience of figuring it out. In this example I load the data from 1 XML file, and populate listbox 1 with toplevel xml as tables and listbox 2 with child elements of each as columns, the xml is loaded from the textbox on the form.

Give it a shot and adapt it to your purpose. Good luck.

Diamonddrake 397 Master Poster

Take a look at the dataset class. It has load/save xml methods that will automatically create a datatable containing the data in your XML document.

you can then use standard databinding if you are they type to use it, or you could navigate the datatable and select all the rows(sub elements) of each column(top elements) and add them to the listbox.

Diamonddrake 397 Master Poster

if all you need is a simple hotkey combination, why even go the route of a low level keyboard hook? Windows has a HotKey api for this very situation.

Here is a simple but usable rewrite of some code I hacked up for one of my projects

//API Imports
        [DllImport("user32.dll", SetLastError = true)]
        public static extern bool RegisterHotKey(
            IntPtr hWnd, // handle to window    
            int id, // hot key identifier    
            KeyModifiers fsModifiers, // key-modifier options    
            Keys vk    // virtual-key code    
            );

        [DllImport("user32.dll", SetLastError = true)]
        public static extern bool UnregisterHotKey(
            IntPtr hWnd, // handle to window    
            int id      // hot key identifier    
            );

        const int HOTKEY_ID = 31197; //Any number to use to identify the hotkey instance

        public enum KeyModifiers        //enum to call 3rd parameter of RegisterHotKey easily
        {
            None = 0,
            Alt = 1,
            Control = 2,
            Shift = 4,
            Windows = 8
        }
        
        public bool setHotKey(KeyModifiers Kmds, Keys key)
        {
            return RegisterHotKey(this.Handle, HOTKEY_ID, Kmds, key);
        }

        public bool unSetHotKey()
        {
            return UnregisterHotKey(this.Handle, HOTKEY_ID);
        }

        const int WM_HOTKEY = 0x0312;//magic hotkey message identifier

        protected override void WndProc(ref Message message)
        {
            switch (message.Msg)
            {
                case WM_HOTKEY:
                    Keys key = (Keys)(((int)message.LParam >> 16) & 0xFFFF);
                    KeyModifiers modifier = (KeyModifiers)((int)message.LParam & 0xFFFF);

                    //put your on hotkey code here
                    MessageBox.Show("HotKey Pressed :" + modifier.ToString() + " " + key.ToString());
                    //end hotkey code

                    break;

            }
            base.WndProc(ref message);
        }

        //put this code in the onload method of your form
           setHotKey(KeyModifiers.Alt | KeyModifiers.Shift, Keys.S);

        //and set up a form closed event and call
            unSetHotKey();
kvprajapati commented: Perfect! +11
Diamonddrake 397 Master Poster

you need the full virtual path to your properties folder (assuming thats where they are uploaded too) and then append the file name.

Diamonddrake 397 Master Poster

Ok, The Main method must be static because it needs to exist without first being instantiated.

Static member functions shouldn't use objects in a class that need to be instantiated because they may or may not exist yet when the static function is called.

"but we can access static functions through the classname itself"
I assume would refer to that calling a static function you use the classname to reference the function, where as non static functions you would use the instance name to reference the function.

Diamonddrake 397 Master Poster

The image url shouldn't be and absolute path, it should be a virtual path, ex "http://www.daniweb.com/images/myimage.jpg"

so you shouldn't be using Server.MapPath()

Diamonddrake 397 Master Poster

well, nowhere in your posted code do you attempt to show them.

Diamonddrake 397 Master Poster

I am using IrrKlang.net for playing asynchronous sounds, and it supports recording audio to a byte buffer, but it uses the default system recording device which is usually a microphone, the user can set the recording device to a loopback device in the windows control panel, and then it will work, (I still have to encode the audio to a file but that's not the issue)

I have found a few working examples of recording audio by selecting the enumerated device. But that assumes that the sound device supports stereo mix loopback (which almost all do) but more complicated, that it is enabled. on vista and win 7 they are default disabled and most people don't know how to enable it.


I need to find a way to programmatically enable the stereo mix recording device and select it. Or a way to just capture audio from a single application.

Diamonddrake 397 Master Poster

I am working on an application that lets you play drum sounds using a rockband drum kit. Current version available here I am wanting to add a recording function but all I can think of is loop back recording. That's manageable but in Vista and Windows 7 by default the stereo mix recording source is disabled.

Does anyone know how to loopback record without it enable, or how to programmatically enable it? I know screen cap apps do it somehow, but I cant find any concrete examples of how to accomplish this.

kvprajapati commented: Have you tried any open source lib? +11
Diamonddrake 397 Master Poster

Firstly, this is an asp.net question, it should be in the asp.net forum. But since the code here is in C# I can understand why you posted it here.

There should be some img1.ImageUrl = dr[6]; ect ect

Diamonddrake 397 Master Poster

If app A is not running prior to clicking the button in app B, then simply create a command line argument that is of type int, and set up the app to check for it, and select the menu item based on that command line argument.

Then in app B, instead of just using

System.Diagnostics.Process.Start("A.exe");

instead use something like

public void startAwithMenu(int menuNumber)
        {
            System.Diagnostics.Process appA = new Process();
            appA.StartInfo.FileName = "A.exe";
            appA.StartInfo.Arguments = menuNumber.ToString();
            appA.Start();
        }
Diamonddrake 397 Master Poster

Have you tried DataSet.ReadXml(); ? It will automatically create a dataset with a datable that you can use to databind to a control, or just enumerate, search, edit, and of course it has a matching SaveXml() method that creates an XML.

Diamonddrake 397 Master Poster

You can get the type of an object by passing that object to they typeof method.

Type t = typeof(MyClass);

but if the type is not available to the namespace you are in, then it won't work. you need to expose that type to your other dll, and if you can't, then you need to define that type again so that it is available.

Diamonddrake 397 Master Poster

That is an odd example Mitja, you only need 2 lines of code for this, you defiantly don't want to separate all the strings into a generic list like that. And its unnecessary to handle the request and response like that. Just use your framework classes.

// Create web client.
        WebClient client = new WebClient();

        // Download string.
        string value = client.DownloadString("http://www.daniweb.com/");
Diamonddrake 397 Master Poster

http://msdn.microsoft.com/en-us/library/781fwaz8.aspx

According to the 2 little lines you posted. it looks fine, this link is the usage, and that works fine on my machine. Must be something else. feel free to post more code.

Diamonddrake 397 Master Poster

That last post was about Internet Explorer, That's not what you want.

There are 2 ways to do what you are talking about. The best and most difficult way is to create a com object that catches Windows Explorer.exe's request to create the shell context menu and insert your item there.

The simple way is to create a registry entry for a file type or types in the HKCR. This is probably the way to go for such a small project but you will certainly have to create your application in the singleton pattern and forward comandline arguments to the original instance of your app to get the functionality you are after.

an example to get your started would be http://www.codeproject.com/KB/cs/appendmenu.aspx

Diamonddrake 397 Master Poster

try this snippet of mine from a few months ago. http://www.daniweb.com/code/snippet231466.html

Diamonddrake 397 Master Poster

The simplest solution would be to just call sort on the array, and if necessary reverse it as posted above, but there becomes a sorting issues between logical and natural order. if the decimals are not padded with zeros, it could get out of order. as in 10,1,2,3...9 instead of 1,2,3...9,10 because of that logical something before nothing clause.

this is simply overcome by using a numericcomparer class

NumericComparer ns = new NumericComparer();
Array.Sort(arraytosort, ns);
arraytosort.Reverse();
Diamonddrake 397 Master Poster

that's the idea, for every different piece of information you need to send simultaneously. you need a new connection on a different port.

Diamonddrake 397 Master Poster

There is no reason why you can't, but it depends on the accessibility you need for the enum. If the namespace directly contains the enum than any object in that namespace has access to the enum. When its contained in a class, depending on its access modifier it may or may not be available to all the objects in that namespace.

Typically you would put the enum inside the class if the class encapsulates the extent of the usage of the enum. If the enum has common items to the application that don't explicitly require the use of the class then its up to the developer to make the call.

Diamonddrake 397 Master Poster

That low level input hook is some tasty stuff, But if you are new to writing applications outside of forms and want simple, that example is far from simple.

The hardest part of writing a good gui free application is that the .net framework won't manually create an event loop for you, so you'll have to create one yourself. That's a bit tricky and unnecessary. You can use a hidden blank form to host the event loop for your application in which case you can use the very simple registerHotKey windows API to handle all your key presses, if you don't want to use a blank form, you can use it as a debug form with a hotkey to show it for app variable information, or as an about box so you can easily tell the version number and list all the shortcuts in the event there are many.

its just an alternate idea, But I would also like to note that the low level system hook described in adatapost's link is a good solid way to handle this as well, it can just get tricky.

kvprajapati commented: To the point. Very good explanation! +11
Diamonddrake 397 Master Poster

I learned C# with a free online copy of sams teach yourself C# in 24 hours. That got me the knowledge of the syntax and practice of starting a project. Then to really get down and dirty with it you have to decided on a program that you want to write, not impossible, something simple like a notepad clone for instance. Then start searching for information on your project, for example how to save the form's position to the registry, and xml file, or preferable using the .net project settings. Then implement it. Keep going until you have a full featured application that you understand everything about because you pieced it together from nothing.

Once you finish that, and feel up to a bigger challenge try something harder, always staring with an empty project don't start with some one else's project and change it.

Good Luck!

Diamonddrake 397 Master Poster

I wasn't really even aware you could put a textbox inside of a listbox. I'm not sure if the listboxitem object has a tabstop property, but if it does you could try setting it to false so that the tabs would skip the section behind the textbox. But that's just a guess.

I don't play much with WPF. I hope that this suggestion works out for you.

Diamonddrake 397 Master Poster

It should work, assuming that your array is of type TextBox or Control.
you could try something like

Control tb_tofocus = myTextBox[3] as Control;
tb_tofocus.Focus();

But not seeing the code is hard to tell whats going on, because in theory it should work as is.

Diamonddrake 397 Master Poster

I have been working closely with libvlc the core library that plays videos in VLC player. I wrote my own wrapper because its actually a well written library and all the wrappers I have found are more complicated than libvlc itsself. So 5 little classes give me all the power i need. its not perfect, but its not the problem.

somehow in testing applications I build with this, installing and uninstalling, building and moving, I somehow broke the ability for libvlc to work. I have dug through the registry to no avail, I just don't know what happend. VLC player still works fine, but all the applications built around my lib, no matter where they are, crash when opening a specific file type ".flv" it worked before, then it just stopped. It wasn't a changed to the wrapper (because I didn't make any) and its not just my wrapper. i downloaded nVLC from codeproject and it has the same problem, crash on opening flv files.

If I compile my application, and install it on a different computer, it works fine. In fact, there is a completely working application based on libvlc 1.1.2 and my wrapper released on my website, and installed on all my machines that works wonderfully. But something happened to my main machine that's keeping it from working.

If anyone has any ideas, any at all I'm willing to try them. I just DON'T want to reinstall windows, and for some reason I don't remember …

Diamonddrake 397 Master Poster

One of the applications I was having a problem with used the Managed DirectX.dll for joystick functionality. Building it as x86 made it work in 64-bit. Thanks!

I believe working with the other apps I might find the same solution. Thanks for all the help!

Diamonddrake 397 Master Poster

I'm not privy to much information involving 64-bit. So let me clarify.

If I compile as x86 exclusive, it will still run on 64-bit?

Diamonddrake 397 Master Poster

I imagine if I attempted to debug them on a x64 computer it would show me what's going wrong? or not?

Diamonddrake 397 Master Poster

I have written a couple applications that Work great on 32-bit but crash on open in 64-bit. They are all compiled against "any CPU" but even when I compile them for 64-bit they still crash on 64-bit windows.

both of these applications rely on 3rd party Dlls, some native dlls and some .net dlls.

I don't have a 64 bit system to develop on, but I have a friend with a 64 bit system that tests my applications for me.

Does a 64 bit application need to be compiled on a 64 bit system? or is it problems with my code or its dlls that is breaking the apps?

Any ideas, I've never really worked with 64-bit programming before.

Diamonddrake 397 Master Poster

That's cool, I still prefer an emulator, But now I can play when I'm not on my own computer. Thanks for the find

Diamonddrake 397 Master Poster

I'm Rickey, I'm 23, and I'm a Windows Programmer. Check out some of my apps at http://www.DiamondDrake.com

Diamonddrake 397 Master Poster

official beta release on my website at http://www.diamonddrake.com/software.aspx?title=RockBand%20Drum-Kit.

New version now supports the wireless PS2/3 drumkit. New Interface changes including a slide up about box.