actually it is the same when it comes to managed but I found the answer. It turns out that when I add a new event I have to pass in the class that's calling the event: ... m_codeProject->MessageReceived += gcnew MessageReceivedEventHandler(this, &NS::MessageReceived_Message);
... thanks! Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
Rob Tomson
Posts
-
delegate trouble -
delegate troubleI can't get my delegate/event to work. It keeps giving me a compiler error of 'the specified function does not match the delegate type'. This is what I have: ...
public delegate void MessageReceivedEventHandler(MessageDetails^ Message);
...ref class CodeProject { public: event MessageReceivedEventHandler^ MessageReceived;
... ...CodeProject^ m_codeProject; m_codeProject->MessageReceived += gcnew MessageReceivedEventHandler(&NS::MessageReceived_Message);
...private: System::Void MessageReceived_Message(MessageDetails^ Message);
It seems that everything is fine but it won't compile. Please help. Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't. -
ListView row heightIs there a way to adjust the height of the rows in a listview? It seems that the function GetItemRect gets called when painting the control but it's not virtual so I can't override it. Will I have to do all the painting myself? Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
-
Combobox in listviewHow would I go about embedding a
combobox
in a cell of alistview
when set to details view? I've looked at this article ListViewEmbeddedControls[^] but unfortuatly thecombobox
height is bigger than the row height. Can I maybe overwrite the row height before drawing? Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't. -
Visual Studio style options dialogDoes anyone know of a control or method for creating an options dialog like that used by visual studio? Basically there's a treeview on the left side of the dialog and depending on what you select it displays the panel that's associated to that node. I tried to implement this with a tabcontrol in vs2005 but there's no way to hide the tabs at the top. Can I just override that pain event? Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
-
System.Web.Mail for error reportingthanks for the reply. what http commands would I use to send the mail? I tried quickly searching google but it was talking about ssh tunneling, is this what you're talking about? thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
-
Browser DetectThat worked. Thanks! I guess I should keep an eye on what scope the variables are in. Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
-
Making Menu Selections through Programhave you tried menuItem1.PerformClick() ? Rob -- There are 10 kinds of people. Those who understand binary and those who don't.
-
System.Web.Mail for error reportingI know how to use the
System.Web.Mail
class to send mail through smtp but I want to use this for error reporting for one of my programs and I don't have a public smtp server. Are there free smtp servers that I can relay this through or is there a better way to report errors to me? Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't. -
Browser DetectI've never done javascript before but I need to be able to detect which browser the user is running. I've searched the net and copied some code to do this. It's simple and I understand what it does but I can't get the .html page to display different text per browser. This is what I have in my html:
<!-- if(BrowserDetect()!="Internet Explorer") { document.write('Other'); } else { document.write('Internet Explorer'); } // -->
and this is the code that I found on the internet:function BrowserDetect() { var detect = navigator.userAgent.toLowerCase(); var OS,browser,version,total,thestring; if (checkIt('konqueror')) { browser = "Konqueror"; OS = "Linux"; } else if (checkIt('safari')) browser = "Safari" else if (checkIt('omniweb')) browser = "OmniWeb" else if (checkIt('opera')) browser = "Opera" else if (checkIt('webtv')) browser = "WebTV"; else if (checkIt('icab')) browser = "iCab" else if (checkIt('msie')) browser = "Internet Explorer" else if (!checkIt('compatible')) { browser = "Compatible" version = detect.charAt(8); } else browser = "An unknown browser"; if (!version) version = detect.charAt(place + thestring.length); if (!OS) { if (checkIt('linux')) OS = "Linux"; else if (checkIt('x11')) OS = "Unix"; else if (checkIt('mac')) OS = "Mac" else if (checkIt('win')) OS = "Windows" else OS = "an unknown operating system"; } document.rs_browser=browser; document.rs_OS=OS; document.rs_version=version; return browser; } function checkIt(string) { place = detect.indexOf(string) + 1; thestring = string; return place; }
When I view my page in either FireFox or IE it doesn't generate any errors but it also doesn't display any sort of text. Please Help, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't. -
exception not catchingThank You! That worked like a charm. Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
-
exception not catchingOkay, I tried running my program on a couple different computers and they all had the same result; it would fatal error instead of using my error report. Does it matter that I am using an MDI form with child forms? Maybe it's crapping out because a child form is erroring but then that doesn't explain why it works in debug mode and not in release. Any suggestions? Rob -- There are 10 kinds of people. Those who understand binary and those who don't.
-
Show hidden formscan't you just use ShowDialog? that should make B be active even if you select A. Rob -- There are 10 kinds of people. Those who understand binary and those who don't.
-
exception not catchingI deliberatly try to set an int equal to a textbox string. And of course it throws 'Input string was not in a correct format.' When I do this in debug mode it catches the error, shows my dialog and everything is fine. But if I do the same proceedure in release mode I get the dafult .NET error dialog and it doesn't show my dialog. Rob -- There are 10 kinds of people. Those who understand binary and those who don't.
-
exception not catchingI've already tried that and it doesn't even hit the dialog. When I run it in 'release mode' it won't even hit the 'end of try' dialog. It just errors. This is what I had.
static void Main() { try { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.Run(new frmMDI()); System.Windows.Forms.MessageBox.Show("end of try"); } catch(System.Exception e) { System.Windows.Forms.MessageBox.Show("start of catch"); System.Windows.Forms.Application.Run(new frmErrorReport(e)); System.Windows.Forms.MessageBox.Show("end of catch"); //frmErrorReport frm = new frmErrorReport(e); //frm.ShowDialog(); } }
-- There are 10 kinds of people. Those who understand binary and those who don't. -
exception not catchingI'm trying to implement an error report in my program so that when it crashes it pops up a dialog that allows you to fill in some information and then send it along through email. The problem that I'm having is when I debug the program in VS it crashes gracefully, just like it's supposed to. But when I run it as a standalone .exe it just errors as if there is no
try/catch
statement. This is what I have for myMain
function. If there are any suggestions please let me know.static void Main() { try { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.Run(new frmMDI()); } catch(System.Exception e) { System.Windows.Forms.Application.Run(new frmErrorReport(e)); //frmErrorReport frm = new frmErrorReport(e); //frm.ShowDialog(); <----- I've also tried this but I get the same results } }
-- There are 10 kinds of people. Those who understand binary and those who don't. -
Read / Write an Image filewow, thank you very much. I didn't know something like this existed and it's very interesting. Looks like this is what I'm going to use. Thanks, Rob -- There are 10 kinds of people. Those who understand binary and those who don't.
-
Read / Write an Image fileThat sounds very interesting, thank you. What do you mean by 'use alternate data streams'? Does this mean I can embedd info in the file and still have other programs read the file? That would really helpful if I could do that instead. Any suggestions? Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
-
Reading ID3 tags with Shell32I came across this article http://www.codeproject.com/csharp/ShellID3TagReader.asp[^] and so I tried doing exactly as shown but it's not working. When the
folder.GetDetailsOf
function returns it's blank but I know for a fact that there this mp3 has an ID3 tag. Furthermore when I add the extra columns in Windows Explorer to see the mp3 info it doesn't display anything. Can myShell32
be broken somehow? Here's the code I have (even though it's the same in the article):MP3File mp3File = new MP3File(); string fileName = FilePath.Substring(FilePath.LastIndexOf("\\") + 1); string filePath = FilePath.Substring(0, FilePath.LastIndexOf("\\")); Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.NameSpace(filePath); Shell32.FolderItem folderItem = folder.ParseName(fileName); if(folderItem != null) { mp3File.FileName = fileName; mp3File.AlbumName = folder.GetDetailsOf(folderItem, 17); mp3File.ArtistName = folder.GetDetailsOf(folderItem, 16); mp3File.SongTitle = folder.GetDetailsOf(folderItem, 10); mp3File.TrackNumber = folder.GetDetailsOf(folderItem, 19); } folderItem = null; folder = null; shell = null; return mp3File;
I'm using XPpro SP2. Please Help, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't. -
Read / Write an Image fileHow would I go about doing that? Thanks, Rob -- There are 10 kinds of people. Those who understand binary and those who don't.