|
|
As far as I can tell that returns a read-only collection of stylesheet - if the page had a stylesheet to begin with I could possibly alter it, but not add to them
I did manage a sort-of work around using the createStyleSheet method of msthml.HTMLDocumentClass. It does mean having to have the stylesheet in a file rather than generate it, but it does what I need it to.
|
|
|
|
|
Just to let you know, Microsoft.mshtml.dll comes with VS.NET, IIRC, which is far better to use than creating your own since it's the PIA (primary interop assembly) produced by Microsoft. I think it also comes with Office, but I'm honestly not sure.
Just letting you know.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks, I will keep that in mind the next time a similar question is asked here.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi all!
Here is my problem:
I am developing a Windows service written in C#. The work of this service is to send an alert by mail when the total memory of the OS is too high for example. I'm using the System.Web.Mail namespace to send a mail and everything is ok. I put this piece of code in a thread to make my application more reliable, like that:
' the code for sending mail is in the ThreadLoop method of the Job class
Thread jobThread = new Thread(new ThreadStart(current_job.ThreadLoop));
jobThread.Start();
' wait until the job is done or the timeout is reached
bool noTimeout = current_job.Mre.WaitOne(30*1000, false);
' stop the thread...
jobThread.Abort();
Ok. My problem occured when there is a big file attached to the mail, and the timeout is reached. The method Abort() does not quit the thread until the entire mail is sent...
And I cannot add a timeout to the System.Web.Mail.SmtpMail.Send method, then I am stuck.
Is there a way to force the termination of a thread?
Thanks.
|
|
|
|
|
I need a component that I can drag around the form at run time. The component must have multiple text sections. And the user should be allowed to drag and drop buttons anywhere on the component. The component should be able to be stored, in other words if the program is closed and re-opened the component should be rebuilt with the same text and buttons in the same place
Basically this is what I need:
Text text text text text text text text text text text text text text
text text text text text text text text text text text text
text text text text text text
text text text text text text text text text
text text text text text text
text text text text text text text text text text text text
<<Button1>>
text text text text text text text text text text text text
text text text text text text
text text text text text text text text text
<<Button1>>
|
|
|
|
|
You should try searching for one, then. The C# forum is for specific problems with the C# language and related .NET question (ASP.NET question - even if written in C# - belong in the ASP.NET forum specifically).
This web site includes many articles about document/view, runtime drag and drop, and serialization. MSDN[^] (the Microsoft Developer Network) has many other articles, and you can always google[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi all,
When i change an expandable property of an object from the property grid, the set method of that propertin is not being called, where as the set methods of its sub properties are being executed.
what may be the reason?
please help...
regards,
Pradeep
|
|
|
|
|
If this is a property you're developing, you should implement your own TypeConverter [^] (for an expandable object, extend ExpandableObjectConverter [^] if you like). You'll want to override and implenent the GetCreateInstanceSupported and CreateInstance methods. You should read the documentation for these in the .NET Framework SDK, which includes examples.
This will create a new object to be serialized to your source code file, which the designer will handle automatically.
Another good section of the .NET Framework SDK to read is Enhancing Design-Time Support[^], which covers a lot of design-time topics.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks stewert.. It works fine.
|
|
|
|
|
Hi All,
Does any one know how to retrive a datagrid cell color?
I am using a datagrid which uses multiple colors? I required to print that datagrid. While printing I need to retain the cell colors. As of now I know only to get the header color of a datagrid.
I will appreciate if someone can help me in solving the problem.
Thanks,
Jo
|
|
|
|
|
hi,
Here in this article i am trying to assign and update colors of rows, cells etc. You can use this to know how to change the color of cells
DataGridTableStyle
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi Sreejith,
That article is nice. I am interested in getting the color of a given datagrid cell.
thanks,
Jo
|
|
|
|
|
DataGrid.Items[0].Cells[0].BackColor;
|
|
|
|
|
Hi Mark,
I am using DataGrid in Windows forms. I couldn't find anything like
DataGrid.Item[0]
regards
Jo
|
|
|
|
|
OPC defines two main components(COM) registered in opcserver category : OpcServer & OpcGroup. I have written two coresponing classes as follows that implement the required Interfaces as defined by OPC.
[Guid( "926EFA52-C020-4259-B879-203512901EAF" )]
[ProgId("FAHM OPC Server 1")]
[ComVisible( true )]
public class OpcServer: IOPCServer, IOPCCommon, IOPCItemProperties, IOPCBrowseServerAddressSpace
{}
[Guid( "075A7104-076F-481f-8CCF-11BA9AE375EB" )]
[ProgId("FAHM OPC Group 1")]
[ClassInterface(ClassInterfaceType.None)]
public class OpcGroup: IOPCItemMgt, IOPCAsyncIO2, IOPCSyncIO, IOPCGroupStateMgt
{}
I can in a not managed programming language such as delphi or c++ create an instance of them and call all methods of both of them and QueryInterface them to all implemented Interfaces and see they are working by showing just a messagebox for test.
The problem is that the IOPCServer Interface defines a method AddGroup as follows that returns an instance of OPCGroup and has following signature in c++ and c#:
c++:
virtual HRESULT STDMETHODCALLTYPE AddGroup(
/* [string][in] */ LPCWSTR szName,
/* [in] */ BOOL bActive,
/* [in] */ DWORD dwRequestedUpdateRate,
/* [in] */ OPCHANDLE hClientGroup,
/* [in][unique] */ LONG __RPC_FAR *pTimeBias,
/* [in][unique] */ FLOAT __RPC_FAR *pPercentDeadband,
/* [in] */ DWORD dwLCID,
/* [out] */ OPCHANDLE __RPC_FAR *phServerGroup,
/* [out] */ DWORD __RPC_FAR *pRevisedUpdateRate,
/* [in] */ REFIID riid,
/* [iid_is][out] */ LPUNKNOWN __RPC_FAR *ppUnk) = 0;
c# :
void AddGroup(
[In, MarshalAs(UnmanagedType.LPWStr)] string szName,
[In, MarshalAs(UnmanagedType.Bool)] bool bActive,
[In] int dwRequestedUpdateRate,
[In] int hClientGroup,
[In] ref int pTimeBias,
[In] ref float pPercentDeadband,
[In] int dwLCID,
[Out] out int phServerGroup,
[Out] out int pRevisedUpdateRate,
[In] ref Guid riid,
[Out, MarshalAs(UnmanagedType.IUnknown)] out object ppUnk);
When in the unmanged code call this method of IOPCServer, it seems to be ok, but the returned object in ppUnk that supposed to be a IOPCItemMgt fails to execute any of its methods and raises an memory exception. I tried following implementation for OPCSerevr.AddGroup but all of them have the same wrong result:
impl. 1:
Type typeofGroup = Type.GetTypeFromProgID( "FAHM OPC Group 1" );
if( typeofGroup == null )
throw new Exception("OPC Server Not Found");
object grp = Activator.CreateInstance( typeofGroup );
IntPtr pRes = IntPtr.Zero;
IntPtr pUnk = Marshal.GetIUnknownForObject(obj);
Marshal.QueryInterface(pUnk, ref riid, out pRes);
Marshal.Release(pUnk);
Marshal.Release(pUnk);
if (!pRes.Equals(IntPtr.Zero))
ppUnk = pRes;
else
Marshal.ThrowExceptionForHR(HResult.E_NOINTERFACE);
impl. 2:
object grp = new OpcGroup();
ppUnk = IntPtr.Zero;
ppUnk = Marshal.GetComInterfaceForObject(grp, typeof(IOPCItemMgt));
impl. 3:
object grp = new OpcGroup();
ppUnk = grp;
impl. 4:
object grp = new OpcGroup();
ppUnk = (IOPCItemMgt)grp;
And for each of mentioned lines in above implementaions I surrounded it with a try-catch block and showed messageboxes after each successfull or failed block, and it seems that none of them fails, but I don't know why the returned IOPCItemMgt is incorrect. Can anyone help me?
Special Regards
Umed Kurdistan
|
|
|
|
|
A few things: first, please learn to format your code for use on CodeProject. You can use <pre></pre> tags for blocks of code, and <code></code> for inline code. This also helps separate your code from your paragraphs making it much easier to read.
Also, why two calls to Marshal.Release ? Marshal.GetIUnknownForObject increments the ref count only once and I see no other code that AddRef's pUnk . This might be causing your COM server to unload if the ref count is zero and no more objects are running.
Also, I'm not sure I understand your code correctly (i.e., what you're trying to do; not COM interop which I understand very well) but you need to use Activator.CreatecomInstanceFrom if the group is actually a COM object that you've created an RCW (runtime callable wrapper) for. Just creating the Type for an RCW won't work; it needs to instantiate the COM object through its class factory.
Finally, PROGIDs should be in the forum of Library.Object.Version. It's not a hard and fast rule, but is consistent with just about every object COM object. If you want friendly names, you declare these in your IDL for native COM servers, or use the ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute to additionally (class registration you still get for free from regasm.exe) register the title of the COM object using the Registry and RegistryKey classes in the Microsoft.Win32 namespace.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for your reply.
Both OPCServer & OPCGroups are defined in c# but they are regitered as COM because the OPC protocol defines so and others can be able to create instances of them.
I removed one/both Marshal.Release but it doesn't solve the problem. The problem in readable & formatted style is:
OPC (OLE for Process Control) is a protocol as an interface between
applications and industry hardware drivers. It defines two main components (COM)
registered in opcserver category : OpcServer & OpcGroup.
I have written two corresponding classes as follows that implement the required
Interfaces as defined by OPC.
-----------------------
[Guid( "926EFA52-C020-4259-B879-203512901EAF" )]
[ProgId("FAHM OPC Server 1")]
[ComVisible( true )]
public class OpcServer: IOPCServer, IOPCCommon, IOPCItemProperties,
IOPCBrowseServerAddressSpace
{
//Implementd inteface methods
}
[Guid( "075A7104-076F-481f-8CCF-11BA9AE375EB" )]
[ProgId("FAHM OPC Group 1")]
[ClassInterface(ClassInterfaceType.None)]
public class OpcGroup: IOPCItemMgt, IOPCAsyncIO2, IOPCSyncIO, IOPCGroupStateMgt
{
//Implementd inteface methods
}
I can in a not managed programming language such as delphi or c++ create an
instance of them and call all methods of both of them and QueryInterface them to
all implemented Interfaces and see they are working by showing just a messagebox
for test.
The problem is that the IOPCServer Interface defines a method AddGroup as
follows that returns an instance of OPCGroup and has following signature in c++
and c#:
c++:
virtual HRESULT STDMETHODCALLTYPE AddGroup(
/* [string][in] */ LPCWSTR szName,
/* [in] */ BOOL bActive,
/* [in] */ DWORD
dwRequestedUpdateRate,
/* [in] */ OPCHANDLE hClientGroup,
/* [in][unique] */ LONG __RPC_FAR *pTimeBias,
/* [in][unique] */ FLOAT __RPC_FAR *pPercentDeadband,
/* [in] */ DWORD dwLCID,
/* [out] */ OPCHANDLE __RPC_FAR *phServerGroup,
/* [out] */ DWORD __RPC_FAR *pRevisedUpdateRate,
/* [in] */ REFIID riid,
/* [iid_is][out] */ LPUNKNOWN __RPC_FAR
*ppUnk) = 0;
c# :
void AddGroup(
[In, MarshalAs(UnmanagedType.LPWStr)]
string szName,
[In, MarshalAs(UnmanagedType.Bool)]
bool bActive,
[In] int dwRequestedUpdateRate,
[In] int hClientGroup,
[In] ref int pTimeBias,
[In] ref float pPercentDeadband,
[In] int dwLCID,
[Out] out int phServerGroup,
[Out] out int pRevisedUpdateRate,
[In] ref Guid riid,
[Out,
MarshalAs(UnmanagedType.IUnknown)] out object ppUnk);
When in the unmanged code call this method of IOPCServer, it seems to be ok, but
the returned object in ppUnk that supposed to be a IOPCItemMgt fails to execute
any of its methods and raises an memory exception.
I tried following implementation for OPCSerevr.AddGroup but all of them have the
same wrong result:
------------------------------------------
impl. 1:
Type typeofGroup = Type.GetTypeFromProgID( "FAHM OPC Group 1"
);
if( typeofGroup == null )
throw new Exception("OPC Server Not Found");
object grp = Activator.CreateInstance( typeofGroup );
IntPtr pRes = IntPtr.Zero;
IntPtr pUnk = Marshal.GetIUnknownForObject(obj);
Marshal.QueryInterface(pUnk, ref riid, out pRes);
Marshal.Release(pUnk);
if (!pRes.Equals(IntPtr.Zero))
ppUnk = pRes;
else
Marshal.ThrowExceptionForHR(HResult.E_NOINTERFACE);
------------------------------------------
impl. 2:
object grp = new OpcGroup();
ppUnk = IntPtr.Zero;
ppUnk = Marshal.GetComInterfaceForObject(grp,
typeof(IOPCItemMgt));
------------------------------------------
impl. 3:
object grp = new OpcGroup();
ppUnk = grp;
------------------------------------------
impl. 4:
object grp = new OpcGroup();
ppUnk = (IOPCItemMgt)grp;
And for each of mentioned lines in above implementaions I surrounded it with a
try-catch block and showed messageboxes after each successfull or failed block,
and it seems that none of them fails, but I don't know why the returned
IOPCItemMgt is incorrect.
Can anyone help me?
Special Regards
Umed Kurdistan
|
|
|
|
|
That's not really any better (I said use the <pre></pre> tags for fixed-width, block-level code), but wasn't necessary, either. I did manage to read your first post after scanning it several times.
Most of my remarks were about problems I found elsewhere in your code (like bad PROGIDs). In order to help you, I need more information.
I know that you're defining COM objects in C# (known as CCWs), but not being familiar with OPC I need to know if the groups you're trying to call are native COM components. If you're trying to activate a CCW, then you need to use Activator.CreateComInstanceFrom so that the class factory is used. Just instantiating the CCW itself isn't enough. There's a lot that goes on in the CLR.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
No, the groups aren't native COM components, they are COM compenents defined and implemented in c# and then regitered as COM.
The Problem:
unmanaged code :
1- Create an instance from OPCSerevr --> Is OK & can call all methods when
casted to any interface
2- Create an instance from OPCGroup --> Is OK & can call all methods when
casted to any interface
3- Call AddGroup method of OPCServer casted to IOPCServer that returns an
OPCGroup and casting it to any interface is OK, but when i call the
methods raises a memory error.
Thanks
Umed Ebdullahi
|
|
|
|
|
Without seeing all the source code, all I can do is make educates "stabs in the dark", but hopefully we can resolve this. Usually the questions are a little more simple.
Are these interfaces declared in unmanaged code (i.e., in an IDL file and registered in HKCR\Interfaces )? If so, don't forget to attribute the re-declaration in managed code with ComImport . This ensures that the CLR performs a QueryInterface for the requested interface instead of just a cast.
If these interfaces are declared in managed code, IIRC they will not be registered in HKCR\Interfaces by regasm.exe. The easiest way to find out is to run regasm.exe /regfile:temp.reg Assembly.dll (replacing "Assembly.dll" with your assembly, of course). You could also generate a typelib and use oleview.exe Assembly.tlb for an IDL-like output, if you like.
If not registered, you can add a couple static parameterless methods and attribute them with the ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute . Keep in mind that these methods are called by regasm.exe in addition to registering your types normally. No need to do the same thing twice.
Also be sure that if you don't install your assembly into the GAC, you use the /codebase option with regasm.exe to register the fully-qualified path to your assembly so that mscoree.dll knows where to find it. Since you can create instances of your COM servers, this doesn't sound like a problem.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Yes these interfaces are declared in unmanged code, and I used ComImport with all interfaces and have installed my assembly into GAC.
I have emailed a copy of application source to your email, and any help will be appreciated greatly.
Special Regards.
|
|
|
|
|
Hello,
i am facing a problem,the main window of the program has picture boxes and tab control.
A certain menu item opens the main form's child form.
However picture boxes of the parent form remains on the top of the child form.I tried using for the child form the "bringtofront" method ,but still it wont work.The child form would be totally visible if it came in an area of the parent form with no controls.Otherwise part of the child form would be covered by the controls of the parent form.
I really need the help
Thanks a million
|
|
|
|
|
hi,
How you want to show the second from which is choosen by the user. If you don't mind. Is it possible to explaine a little bit more and clear.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I am currently trying out some things with Ben Houston's Exocortex.DSP Fourier functions to use with sound curves and I have a question: The FFT-function asks for a length, but I don't know what I should use as the length..... I tries the length of the float-array I use, but it keeps telling me that 'Index was outside the bounds of the array'..... can someone tell me what kind of variable I should use for it? Any help will be hugely appreciated.
greetings.
|
|
|
|
|