|
Hello, I have a WebBrowser Control in Windows Form and The following code is generating an error
for (; webBrowser1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE; )
{
// Tasks
}
Error :
Operator '!=' cannot be applied to operands of type 'System.Windows.Forms.WebBrowserReadyState' and 'SHDocVw.tagREADYSTATE'
Can you help me by giving me the clue please.
Thanks
Emran
|
|
|
|
|
Because they are of different types. Try this instead:
for (; webBrowser1.ReadyState != WebBrowserReadyState.Complete; )
{
// Tasks
}
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Thanks a loot. your code is working..
|
|
|
|
|
You are welcome
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Hi all,
I have created a resource file using a Resource Editor
this file consists of images for my fomrs,then
have added this resource file in my project and now i want to
insert the images from this resource file to the picturebox on the main MDI
form. but this gives me problem.
The code that i have written is as follows.
System.Reflection.Assembly assembly;
assembly = this.GetType().Assembly;
System.Resources.ResourceManager rm = new System.Resources.ResourceManager
("WebBlogGenerator.manage", assembly);
here WebBlogGenerator is the name of my project and manage is the resource file name.
now i get the image from the resource file
Image managedomainmouseover = (System.Drawing.Image)rm.GetObject
("managedomain");
and i get the error on this line saying that
An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure "WebBlogGenerator.manage.resources" was correctly embedded or linked into assembly "Web Blog Generator".
baseName: WebBlogGenerator.manage locationInfo: <null> resource file name: WebBlogGenerator.manage.resources assembly: Web Blog Generator, Version=1.0.2231.31335, Culture=neutral, PublicKeyToken=null
i had used the same code for a project earlier
but this is giving me an error
Can anyone help me out
or suggest me another way to create a resource file of the images that
i am using in my project.
Thanks and Regards,
Pramod
|
|
|
|
|
Hi,
I can show you the way I am using and it is working fine with me.
I added image files from "Add existing Items" Under Project Name of Solution Explorer.
then, I am using a method to poplulate a picture box from Resource.
fillPicBoxFromResource(ref picBoxGoHome, "Images.home1.gif"); // Images was the name of the Folder where I kept images under Project.
you can use this way too,
fillPicBoxFromResource(ref picBoxGoHome, "home1.gif"); // Images was the name of the
private void fillPicBoxFromResource(ref PictureBox pB, string resourcePath)
{
Stream imgStream = null;
// get a reference to the current assembly
Assembly a = Assembly.GetExecutingAssembly();
// get a list of resource names from the manifest
string[] resNames = a.GetManifestResourceNames();
foreach (string s in resNames)
{
if (s.EndsWith(resourcePath))
{
imgStream = a.GetManifestResourceStream(s);
if (!(null == imgStream))
{
pB.Image = Bitmap.FromStream(imgStream) as Bitmap;
imgStream.Close();
imgStream = null;
}
}
}
}
Another Alternative :
Select the picture box and Choose Picture you want to add to resource. Click Project Resource , ( not local resource). Then change the picture and keep on adding pictures in Project resource.
Now, this one liner will load the picture from resource to Picture box.
this.pictureBoxName.Image = global::ProjectName.Properties.Resources.pictureName;
pictureName will be easily found from Intellisense.
Hope this solution will help you.
EMRAN
-- modified at 7:16 Thursday 9th February, 2006
|
|
|
|
|
But will that work if i create a exe and execute it on another machine
without any problems.
Pramod
|
|
|
|
|
I dont see any reason why it wont work. The images you add in your project, you must choose the build option embedded resource ( for the first method I have shown ).
for the second method, you dont have to choose build option, as you will choose those images from picture box's "choose image" .
Let me know if you dont get those working..
|
|
|
|
|
i tried the first method but that is not working
the image is not displayed.
i did not get the second method
can u give any other way..
Thanks,
Pramod
|
|
|
|
|
Ok,
I am explaining the second method.
=>When you select the picture box in design mode, you see an black arrow on top of the control, right ? click that, you see the following options,
- Choose Image
- Size Mode
- Dock in parent Container.
=> Ok, so Choose Image.
=> Now you have 2 options,
- Local Resource,
- Project Resource File.
Click on Project Resource File Radio Button,
then Click Import,
Choose a picture and then click Ok.
Now, note that, the picture you added has been added in Project Resource file. Now if you click that black arrow again and choose another picture for the same picturebox, the previous image is not deleted from the project resource, it is still there.
Now, you do the same process again and again for all the pictures you want to add in your project resource.
When you are ready with all the pictures you wanted to add, you can use the code I gave you to load any picture from project resource. I am giving you the code again,
this.pictureBoxName.Image = global::projectName.Properties.Resources.original_picture_name; (without extension...) you dont need to type the name of the picture. When you follow the intellisence of the Visual C# Editor, you will see the picture name after typing
this.pictureBoxName.Image = global::projectName.Properties.Resources.
Ok, The picturebox you used to import all these picture in Project Resource is not the only picturebox who can load these resource images. Any other picture box will be able to load these images with the code I mentioned.
May be it is very inefficient way, but it is working for me very nice.
Let me know if still this method not working..
Emran
-- modified at 9:33 Thursday 9th February, 2006
|
|
|
|
|
sorry but i cant see any arrow on the picturebox
i am using VS.2003
Thanks,
Pramod
|
|
|
|
|
Oh I see.... I did not use VS 2003 and I am sorry about that. I thought you were using VS 2005. I am using VS 2005 Express which is free to download and way more rich. Anyway, if you use VS 2005, i hope my code will be helpful for you.
|
|
|
|
|
|
Hi everyone,
I used the sample bars project which in turn uses BandObjects to be used as an IE toolbar. The problem is that on some machines bandobjects library does nto work. The damned toolbar simply does nto get selected for display. I thought it was an IE problem until I installed Motley Fool toolbar (which is written in VC++) and it (Motley fool toolbar) worked. It actually showed up. However my toolbar using band objects still refuses to work on that machine.
Can anyone please help me? I would be very greatful.
- Aslam
|
|
|
|
|
Can i pass command line arguments to a running instance of my application??
|
|
|
|
|
Command line args can be passed to the application on startup (via the strings[] parameter to the app's Main() method). See this[^] article for more information.
Passing commands to a running application is a different matter altogether and may be accomplished in several ways.
Hope this helps,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I know how to pass arguments at startup but i wanted to pass them to a running instance.
|
|
|
|
|
Take a look at this article on MSDN[^].
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
i had look at the link but i couldne understand. Could you elaborate just a wee bit?
|
|
|
|
|
The idea is roughly the following:
1. When the application starts, a mutex is created to decide whether it's the first instance.
2a. If it's the first instance, the application is registered as a remoting server and it's URI is written into the registry.
2b. If it's not the first instance, the URI of the first instance is fetched from the registry and the command line arguments are used as arguments for calling a method on the first instance. Afterwards, the second instance quits.
This behaviour is packed inside an application framework which handles all the dirty details. You just have to attach an event handler for a StartupArguments event and handle the command line arguments you get there.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Is there a way within C# and .NET Framework to duplicate the "Safely Remove Hardware" functionality. I am using a USB Flash drive on a Windows XP system.
I want to be be able to ensure that the device is removed from the system without loss of data. So I would imagine that the would some driver uninstall or removal of the device from registry or other location. Does anyone know of code to achieve this?
I am currently using code to raise an event when the USB Flash device is added or removed. Based on the following:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21599899.html
Just to clarify, I cannot use the standard "Safely Remove Hardare" function that appears in the status bar as My application will not boot to the standard windows shell - so there will be no status bar.
|
|
|
|
|
You might be able to gleen something useful out of this[^]. It's a C++ app that will eject a device by
Drive letter: deveject -EjectDrive:E:
DeviceId: deveject "-EjectId:STORAGE\REMOVABLEMEDIA\7&20B2C23&0&RM"
Value Name: deveject "-EjectName:USB Mass Storage Device"
If you're really adventurous, you could convert the code into a utility class in C#. Get ready for some serious P/Invoking!
BTW: This is the ONLY code I've ever found that describes how to do this... And the comments are in German!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 13:31 Thursday 9th February, 2006
|
|
|
|
|
Hi all
If i create an excel range object (from a range of items e.g. A1 to C5)
this returns me a System.__ComObject
how do i turn this into a system array so i can then iterate through and strip out the individual cells.
I know i can do Range.Value2, which returns me a System.Object[,]
but then all i have access to is the values within the range so i cant grab additional cell data such as the number format information for working out the date.
any ideas?
|
|
|
|
|
just cast the return object into a Excel.Range object and you will be able to iterate through the cells that make up the range. Look for the correct methods, its easy.
You will not be able to turn it into a system array, because if you want to keep all information contained in each cell, ur better off just using directly excel's Range object which contains all the info of all the cells contained in it.
Bare in mind that excel does not have a 'Cell' class (which u would use to create ur system array). It only has the Range class and 1 unique cell is just a Range class object that spans 1 cell.
-- modified at 5:41 Thursday 9th February, 2006
|
|
|
|
|
Hello,
I was trying to force to stop a background worker's do event handler with cancelAsynch method, but it is not stopping the work. Is that possible to force to stop ?
Emran
|
|
|
|