Click here to Skip to main content
15,893,663 members
Home / Discussions / C#
   

C#

 
GeneralRe: which is preferable Pin
Dave Kreskowiak11-Jun-09 3:49
mveDave Kreskowiak11-Jun-09 3:49 
AnswerRe: which is preferable Pin
Luc Pattyn11-Jun-09 2:57
sitebuilderLuc Pattyn11-Jun-09 2:57 
AnswerRe: which is preferable Pin
Vasudevan Deepak Kumar11-Jun-09 4:40
Vasudevan Deepak Kumar11-Jun-09 4:40 
GeneralRe: which is preferable Pin
Vijjuuu.11-Jun-09 19:46
Vijjuuu.11-Jun-09 19:46 
Question[Message Deleted] Pin
hkjghkj110-Jun-09 22:59
hkjghkj110-Jun-09 22:59 
AnswerRe: midi player Pin
Christian Graus10-Jun-09 23:07
protectorChristian Graus10-Jun-09 23:07 
AnswerRe: midi player Pin
DaveyM6911-Jun-09 0:34
professionalDaveyM6911-Jun-09 0:34 
AnswerRe: midi player Pin
DaveyM6911-Jun-09 1:00
professionalDaveyM6911-Jun-09 1:00 
I've created a new boilerplate project, pasted and ammended your code.

This works - and loops:
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Shown += new EventHandler(Form1_Shown);
        }

        void Form1_Shown(object sender, EventArgs e)
        {
            DoPlay();
        }

        private const int MM_MCINOTIFY = 0x3B9;

        [DllImport("winmm.dll")]
        private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, uint uReturnLength, IntPtr hwndCallback);

        public bool PlayMidiFile(string midiFile) 
        { 
            if (File.Exists(midiFile)) 
            { 
                mciSendString("stop midi", string.Empty, 0, IntPtr.Zero);
                mciSendString("close midi", string.Empty, 0, IntPtr.Zero);
                mciSendString("open sequencer!" + midiFile + " alias midi", string.Empty, 0, IntPtr.Zero);
                int rtn = mciSendString("play midi notify", string.Empty, 0, this.Handle);
                return (rtn == 0);
            } 
            else 
                return false;
        }

        void DoPlay()
        {
            PlayMidiFile(@"C:\Windows\Media\town.mid");
        }

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == MM_MCINOTIFY)
                DoPlay();
        }
    }
}


Dave
BTW, 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)
Why are you using VB6? Do you hate yourself? (Christian Graus)

Questionhow to save image into sql server ? Pin
xingselex10-Jun-09 22:22
xingselex10-Jun-09 22:22 
AnswerRe: how to save image into sql server ? Pin
Leonscape10-Jun-09 22:58
Leonscape10-Jun-09 22:58 
Questionbreakpoints to all the functions inside a .cs file Pin
LiYS10-Jun-09 21:51
LiYS10-Jun-09 21:51 
AnswerRe: breakpoints to all the functions inside a .cs file Pin
Manas Bhardwaj10-Jun-09 22:00
professionalManas Bhardwaj10-Jun-09 22:00 
AnswerRe: breakpoints to all the functions inside a .cs file Pin
Rob Philpott10-Jun-09 22:13
Rob Philpott10-Jun-09 22:13 
AnswerRe: breakpoints to all the functions inside a .cs file [modified] Pin
DaveyM6910-Jun-09 22:33
professionalDaveyM6910-Jun-09 22:33 
AnswerRe: breakpoints to all the functions inside a .cs file Pin
S. Senthil Kumar10-Jun-09 23:27
S. Senthil Kumar10-Jun-09 23:27 
GeneralRe: breakpoints to all the functions inside a .cs file Pin
LiYS10-Jun-09 23:47
LiYS10-Jun-09 23:47 
QuestionProblem in setup and deployment Pin
vijaylumar10-Jun-09 21:46
vijaylumar10-Jun-09 21:46 
AnswerRe: Problem in setup and deployment Pin
Manas Bhardwaj10-Jun-09 22:02
professionalManas Bhardwaj10-Jun-09 22:02 
GeneralRe: Problem in setup and deployment Pin
vijaylumar10-Jun-09 23:05
vijaylumar10-Jun-09 23:05 
GeneralRe: Problem in setup and deployment Pin
Manas Bhardwaj10-Jun-09 23:43
professionalManas Bhardwaj10-Jun-09 23:43 
GeneralRe: Problem in setup and deployment Pin
vijaylumar14-Jun-09 19:18
vijaylumar14-Jun-09 19:18 
QuestionGetting serial ports names problem [modified] Pin
enginço10-Jun-09 21:01
enginço10-Jun-09 21:01 
AnswerRe: Getting serial ports names problem Pin
Eddy Vluggen10-Jun-09 22:38
professionalEddy Vluggen10-Jun-09 22:38 
GeneralRe: Getting serial ports names problem Pin
enginço11-Jun-09 0:29
enginço11-Jun-09 0:29 
GeneralRe: Getting serial ports names problem Pin
Eddy Vluggen11-Jun-09 2:35
professionalEddy Vluggen11-Jun-09 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.