|
hi.
i create an application that user can save a file with .mnm extension.
now i want to when user double click on this file, my application run and show the file content.
such as a .txt file , that user double click on it, "note pad" run and show the content.
my problem is that user click on a file can not get file's path.
how can get file path ?
tanks
|
|
|
|
|
If you have set up an association with a particular file type for your application, Windows will pass the file name to it as a command line argument when a file is selected.
In the static void main(string[] args) method for your application, the file name can be referenced using args[0] .
If you need to set up the file association programmatically, there is an article here on CodeProject[^] that explains how to do it.
Paul Marfleet
|
|
|
|
|
|
Hi,
I am trying to print my Outlook contacts to a checkelistbox I am trying to get only the Fullname and the phonenumber fields. The code below pops up a message box and give s me the nubmer of the contacts I have.
try
{
Outlook.Application oApp = new Outlook.Application();
// Get the NameSpace information.
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// Log on by using a dialog box to choose the profile.
oNS.Logon(System.Reflection.Missing.Value, System.Reflection.Missing.Value, true, true);
// Get the default Contacts folder.
Outlook.MAPIFolder oContacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
// Get the Items collection from the folder.
Outlook.Items oItems = (Outlook.Items)oContacts.Items;
// Get the first contact item in the Items collection.
//Outlook.ContactItem oCt = (Outlook.ContactItem)oItems.GetLast();
Outlook.MAPIFolder foldercontacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Items searchFolder = foldercontacts.Items;
int counter = 0;
foreach (Outlook.ContactItem foundContact in searchFolder)
{
counter = counter + 1;
//foundContact.FullName.ToString();
}
MessageBox.Show("You have" + counter + "contacts" );
Any help, to print the contacts to a listBox..
Thanks
|
|
|
|
|
s3rro wrote: Any help, to print the contacts to a listBox..
Maybe I don't understand what you mean. From what I think you are trying to say, can't you just do a listBox.Items.add(youritem); ?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hy,
I have 3 pictures in a project resource, a picturebox and a button.
I want when I press the button to change dynamic the pictures from picturebox.
Can anybody help me?
thx
|
|
|
|
|
Sure, we woyld love to help. Where are you at on the task right now? Where are you stuck at?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
It's not a task is for my knowledge.
I want to place random image from the project resource to my picturebox.that's it
|
|
|
|
|
Create an array, and put the images from the project resource in it.
Image[] images = new Image[5]; Then create an object of type System.Random:
Random ran = new Random();
^ These two must be defined outside a method.
Then do the following in your button event handler:
images[0] = Properties.Resources.Image1;
images[1] = Properties.Resources.Image2;
images[2] = Properties.Resources.Image3;
images[3] = Properties.Resources.Image4;
images[4] = Properties.Resources.Image5;
int pic = ran.Next(5);
pictureBox1.Image = images[pic];
And that should do the trick.
Edit: Perhaps it would be better to fill up the array in the form's constructor (usually public Form1() ):
public Form1()
{
InitializeComponent();
images[0] = Properties.Resources.Image1;
images[1] = Properties.Resources.Image2;
}
Virtual1ty "Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
I'm trying to find out how the config file works.
This is how my config file looks like now.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Settingstest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Settingstest.Properties.Settings>
<setting name="SampleText" serializeAs="String">
<value>foo</value>
</setting>
</Settingstest.Properties.Settings>
</userSettings>
</configuration>
The Sampletext is connected to a textbox and the default value shows.
But how do I make if i want to write a new text and save it for the user, and next time I run the program the new value should show up in the textbox?
I've tried with ConfigurationManager to store the new value, but I only get System.NullReferenceException so I do something wrong.
-- modified at 13:11 Monday 15th October, 2007
|
|
|
|
|
|
Right click on your project and properties then goto settings. you can create a string there. It's a configuration property. These values are saved to your EXE' exe.config file. you can set to this string you created by doing a
your.projects.namespace.Properties.Settings.Default.YourSettingName = m_YourVariable;
Then to get the value of the settings you created you can do
m_YourVariable = your.projects.namespace.Properties.Settings.Default.YourSettingName;
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
I am attempting to make a new RichTextBox class (called RTBE) which inherits from RichTextBox. One of the things I want to implement is selection graying, so setting the HideSelection property to false makes selections get a gray BackColor on loss of focus. Because I have to restore the original BackColor in the text, I am wondering if there is a faster way to get/set the SelectionBackColor property so I don't have to go through each character in the selection and obtain the color for that character (through the GUI) using RTB.Select(start, 1) followed by calling RTB.SelectionBackColor. Basically, I am hoping there is a Win API call that can get the backcolor of the text in a RTB without changing the selection. Anyone have some insight? Thanks,
Jeff
|
|
|
|
|
Take a look at the EM_GETCHARFORMAT and EM_SETCHARFORMAT message as well as the CHARFORMAT2 struct. They can be used with the RTB to enable some more functionality than what the built-in RTB gives you.
Nevertheless, these messages also work on the current selection.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I think what I will end up doing is overriding the OnPaint method, and only call the base.OnPaint when I am not figuring out what the current highlighting is. That way, my RTB doesn't flicker. Am I correct in assuming that the WinAPI calls are faster than those exposed by the RTB? If so, I may still use the SendMessage / PostMessage duo in place of the methods exposed on the control as you suggested. Thanks,
Jeff
|
|
|
|
|
I have a legacy DLL written in unmanaged C++ that I need to use in a C# application. I can use it ok, but testing shows we don't get the string information when we catch any exceptions it throws.
It throws a simple TCHAR string exception. example:
throw(_T("My Exception Message."))
We can catch it in C# with the System.Exception class, but the string message is lost. (The Message member is empty.) We tried using a RuntimeWrappedException but that did not catch it.
I can not change the code in the DLL. How can I catch these exceptions and get the string info they contain?
|
|
|
|
|
Not Knuth wrote: I can not change the code in the DLL.
But you can create a C++/CLI assembly that can 1) catch the native exception, 2) Create a managed exception and marshal the message into it 3) throw the managed exception.
|
|
|
|
|
True. And thanks for your suggestion. But I hope there is a more direct way to accomplish the same thing. Surely the designers of the framework made some provision to catch unmanged exceptions AND get the data they may contain. (Unlike the RuntimeWrappedException.)
|
|
|
|
|
Not Knuth wrote: But I hope there is a more direct way to accomplish the same thing.
I prefer to count on C++ rather than hope, but proceed as you like.
|
|
|
|
|
I prefer to use the best method available. I am not yet convinced that yours is the best method. It will work, but it is very inefficient.
|
|
|
|
|
Not Knuth wrote: but it is very inefficient.
Compared to what? It is currently your only known solution so it is the most efficient solution.
|
|
|
|
|
Following that logic, it is also the most inefficient solution!
It might turn out to be the best option. But perhaps there is another one that neither of us know. That is why I posted my question here.
|
|
|
|
|
What does the innerexception property show?
I have no blog...
|
|
|
|
|
Liam O`Hagan wrote: What does the innerexception property show?
The inner exception is null.
|
|
|
|
|
Not Knuth wrote: I can not change the code in the DLL. How can I catch these (C++) exceptions and get the string info they contain?
I have recently encountered a similar situation. After a good bit of research and testing I can tell you that the best approach is to wrap the DLL in a managed assembly where you catch the C++ exception and then throw a managed exception in its place. (As described previously in the reply from led mike.)
You can grab the string out of the C++ exception and insert it in one of the exception classes defined in the framework or in your own derived from one of them. The framework doesn't provide any method to automatically marshal the string message in a C++ exception to a managed object.
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|