|
What??????????????????????????????
This doesn't make any sense whatsoever. What do you mean by "get all TimeZone" and "send it to Time Server"? What are you trying to do with this information? Are you trying to get a Time value from a server localized to your time zone?
And what's with the database?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi,
I've searched everywhere! Does anyone here know how to call a function from C# from an IntPtr? I know how to obtain the function pointer:
IntPtr ptr = (typeof(SOMECLASS).GetMethod("SomeMethodName").MethodHandle.GetFunctionPointer())
Now I just need a way to call it ..
The reason I need this is because in MSHTML, there is an interface called IHTMLElementRender, and the function 'DrawToDC' (useful for capturing HTML documents as an image) takes the argument HDC, but is implemented to take a reference variable of an unrelated structure. Therefore I need to call the function by the pointer, as in C++.
Thanks!
- Joe Esposito
|
|
|
|
|
You've run into one of the limitations of IDL: it was originally for describing structures to be marshalled across processes, but some things we'd like to describe in IDL - handles to GDI and USER objects - are process-relative and have no meaning in another process. So the IDL contains a fake definition.
I've browsed Google Groups for _RemotableHandle . The recommended answer is apparently to use ILDASM to generate IL code for the interface, change the declaration to take an IntPtr , then recompile it. Not nice.
I'd actually recommend using Managed C++ to wrap the interface as declared in mshtml.h.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Instead of wrapping this with an MC++ assembly as the first reply states, just interop the interface yourself. Such it's such a simple interface, it won't be hard:
[ComImport, Guid("3050f669-98b5-11cf-bb82-00aa00bdce0b"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IHTMLElementRender
{
void DrawToDc(IntPtr hdc);
void SetDocumentPrinter(
[MarshalAs(UnmanagedType.BStr)] string printerName, IntPtr hdc);
} You could then use Marshal.GetComInterfaceForObject to get a pointer to this interface. You then call Marshal.GetObjectForIUnknown and cast to the interface like so:
IntPtr ptr = Marshal.GetComInterfaceForObject(element,
typeof(IHTMLElementRender));
IHTMLElementRender render = (IHTMLElementRender)Marshal.GetObjectForIUnknown(
ptr);
render.DrawToDc(hdc);
Marshal.Release(ptr); Please note that this is untested but I've used similar code with different interfaces before with success.
I hope this helps.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks! That did exactly what I needed it to!
I did consider using this method, however all of my attempts failed and left me clueless.
It seems that this attribute really makes the difference:
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
Without it, the program simply crashes when you try to use it.
Also, I have been using type-casts where QueryInterface would be required. It also worked in this case:
IHTMLElementRender render = (IHTMLElementRender)element;
render.DrawToDc(hdc);
Thanks again for your reply
- Joe
|
|
|
|
|
When you perform a type-cast, the CLR performs a QI (QueryInterface ). In some cases, however, the compiler will complain if the object (if it's type is known) doesn't and never could implement that interface.
Glad it works for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
windows provides many win32 functions for error detection on system level.
is there a possibility to detect error on application level?
for example: while running an application, there comes out a warning dialog which might means error. Can i detect it timely ?
|
|
|
|
|
fu0 wrote:
there comes out a warning dialog which might means error. Can i detect it timely ?
Then don't write the code that displays the dialog.
I don't think this is the answer you expect, can you be more explicit in your question.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
I don't quite know what your asking for but try looking up 2 fatures of .Net.
Exception Handling / Throwing
Trace Switches and the debug class.
Can't really be more helpfull without knowing more about your problem.
Try searching on MSDN for the above subjects and see if that helps.
Kev Pearman MCP
|
|
|
|
|
my idea is this:
in a sample, an application(not my own) displays a messagebox which might means some error happened.
then my own application could know something happened by this event(messagebox's displaying). however, my application dont want to know any details about the error, it only write into a log like this: when, which application, something happened. And my application dont want to interfere with the application. it works like a shell.
could i realize it ?
|
|
|
|
|
So you want your application to run and if another application displays a MessageBox you want your application to do something, but you don't want your application to be tied into the other application at all?
If that is the case then i'm afraid i can't help you, i wouldn't even know where to start. If thats not the case then please say so.
Kev Pearman MCP
|
|
|
|
|
in my original idea, i dont want my application to be tied into other applcation.i thought it would interfere with other appliction's nomarl process.
from these words:but you don't want your application to be tied into the other application at all,i guess :
if my application is tied into other application,will it have the ablitiy to do the work ?
could you make a suggestion about your idea ?
|
|
|
|
|
Is the "Other Application" something that your developing? If it is you could tie the two together somehow, sending a message to your "Listening" application to prompt it to do something?
Without knowing the entire problem it's difficult to suggest anything specific.
Hope you are able to solve the problem.
Kev Pearman MCP
|
|
|
|
|
i think the real problem is: "The other applciation" is not my developing . So i want to find a way how to monitor other application 's status to comfirm whethere there occurs an error.
in my opinion, if i can recorgnize a messagebox's displaying i can guess there might be an error occured.
|
|
|
|
|
I don't know if it would even be possible, if the other application doesn't do anything more than display a MessageBox then i wouldn't know how to do it.
Maybe someone who knows a little more about how windows works will be able to help you but this is a bit above me i'm afraid.
Hope you resolve your problem.
Kev Pearman MCP
|
|
|
|
|
Hi..
In my form, I have three combo boxes, one Add button one Save button
and a listview.
Step 1:The comboboxes is being populated by a dataset.
Step 2: On clicking the add button, the listview should get populated with the contents of the combobox.text.
I can repeat Step2 a number of times, each time selecting a different value in the comboBox and adding in the ListView
Step 3: on clicking the Save button, all the data in the listview should be saved in a database.
How will I accomplish this the task? How do i save the Columns and fields of the ListView into a dataset
plz help with code or explanation
Thanks
Breath dot net
|
|
|
|
|
orpus wrote:
How will I accomplish this the task? How do i save the Columns and fields of the ListView into a dataset
The ListView does not support data-binding like this. You must enumerate ListView.Items and for each row enumerate ListViewItem.SubItems . Each ListViewItem represents a separate DataRow which can be inserted into your DataTable (within a DataSet ) in many different ways, which would be obvious if you read the class documentation[^] for the DataTable class in the .NET Framework SDK.
There are several methods that work a little different, from simply adding the row to updating an existing row (by key) or adding if the key doesn't exist. It's not worth discussing here because it's all documented in the .NET Framework SDK, which I've linked above.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have developed a windows form application in C#. The plateform i used is Windows XP. When i run my application it does not provide WindowsXP look and feel. How can i add an XP Look and Feel to my application, even if it is running on the Non-XP platform.
I know a little bit that i have to create a menifest file. but i dont know how.
Thanks in advance,
Omar Rehman
|
|
|
|
|
if your app is not running on an XP machine, creating a manifest won't help. If you are running XP, just add the following 2 lines to your app's Main function:
Application.EnableVisualStyles();
Application.DoEvents();
|
|
|
|
|
You are right writing the said two lines work on XP Machine. But is there any why to have an XP Like Look on a non XP Machine? If there is please tell me,
Thanks in Advance
Omar Rehman
|
|
|
|
|
Not without installing a bunch of Windows .DLL's that only come with Windows XP...
On top of that, they will only work on Windows XP.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
HI,
You mean there is no way to add XP Look for an application Running on a Non XP machine.
Omar Rehman
|
|
|
|
|
There are many articles about owner-drawing buttons and other controls both here on CodeProject and around the 'net. Try searching this site or using google.
This isn't XP themes, however. The theming API is only available in Windows XP and newer, and the common controls library that supports themes is only available for Windows XP and newer. This is covered in the Theme API documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hai there,
what is the status of Microsoft ObjectSpaces technology ?
********************
Sreejith S S Nair
Bangalore - India
91-0-9886501765
********************
|
|
|
|