|
ye,i declared it :
[ComImport,InterfaceType(ComInterfaceType.InterfaceIsIUnknown),Guid("00000109-0000-0000-C000-000000000046")]
|
|
|
|
|
This time i tried IPersistStreamInit Interface,and get convertion form webbrowser to IPersistStreamInit,i think maybe the axWebBrowser1 implement IPersistStreamInit not IPersistStream.MSDN said:This interface is not derived from IPersistStream; it is mutually exclusive with IPersistStream. An object chooses to support only one of the two interfaces, based on whether it requires the InitNew method.
|
|
|
|
|
Yes, that does seem to be correct. It's been a while since I had to do this in our product, and I do realize that IPersistStream and IPersistStreamInit have no relation to each other.
Good find.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Now,the webborwser implement the IPersistStreamInit(has declared) by:
IPersistStreamInit file = (IPersistStreamInit)axWebBrowser1.Document;
and have get the memorystream by:
Stream myStream=new MemoryStream();
richTextBox1.SaveFile(myStream,RichTextBoxStreamType.UnicodePlainText);
this time,can load file by file.Load(UCOMIStream pr);
But now problem is :Load mothod need UCOMIStream as a parameter,but now we just have myStream,how can i do? thank you very much!
|
|
|
|
|
As I mentioned before, you'll need to implement UCOMIStream in your own Stream derivative (or, really, any class). That class should take a reference to another Stream and basically wrap the methods. It's really not too difficult, even though the way in which data is read and written is a little different and because UCOMIStream has some methods that won't easily map (like Stat ), but you could probably just ignore any specific implementation for those particular methods (I did some time back and it worked fine).
Of course, if you encapsulate a Stream derivative like FileStream , you could encapsulate every method of UCOMIStream , but that is pretty limiting. You could always do some type checking on the Stream that your implementation references, but if you're doing this for a specific purpose and don't plan on using it for anything else in your project, I wouldn't bother.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need to either send a Ctrl + K or Alt key combos to walk through the menu of a Citrix Application. Sendkeys does not work. Keybd_event does not work. I can't get SendInput to work at all.
Using Keybd_event I created a app that sent a alt key with no Keyup. I can open any program and it responds as if I have the alt key deppressed except Citrix apps. I can press the Alt key on the keyboard and it works fine.
Will SendInput solve my problem? If so what am I doing wrong?
namespace SendInputTest
{
public struct INPUT
{
public int type;
public KEYBDINPUT ki;
}
public struct KEYBDINPUT
{
public ushort wVK;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
public class Form1 : System.Windows.Forms.Form
{
[DllImport("User32")]
private static extern int SetForegroundWindow(int hwnd);
[DllImport("User32")]
private static extern int FindWindow(string ipClass, string ipWindowName);
[ DllImport("user32.dll") ]
static extern int GetForegroundWindow();
[ DllImport("user32.dll") ]
static extern int GetWindowText(int hWnd, StringBuilder text, int count);
const int nChars = 256;
[ DllImport("user32.dll", SetLastError=true) ]
public static extern int SendInput(int nInputs, ref INPUT[] pInputs, int cbSize);
[ DllImport("user32.dll") ]
public static extern int GetMessageExtraInfo();
[ DllImport("user32.dll", SetLastError=true) ]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo );
const int KEYEVENTF_KEYUP = 0x0002;
const int KEYEVENTF_SCANCODE = 0x0008;
const int INPUT_KEYBOARD = 1;
private void button1_Click(object sender, System.EventArgs e)
{
int hWND = 0;
int handle =0;
hWND = FindWindow(null,@"Untitled - Notepad");
do
{
handle = GetForegroundWindow();
SetForegroundWindow(hWND);
}while (hWND != handle);
unsafe
{
int rs = 0;
INPUT[] input = new INPUT[1];
input[0].type = INPUT_KEYBOARD;
input[0].ki.wVK = 0x41;
input[0].ki.wScan = 0;
input[0].ki.dwFlags = 0;
input[0].ki.time = 0;
input[0].ki.dwExtraInfo = IntPtr.Zero;
System.Threading.Thread.Sleep(2000);
rs = SendInput(1, ref input, sizeof(INPUT));
input[0].ki.dwFlags = KEYEVENTF_KEYUP;
rs = SendInput(1, ref input, sizeof(INPUT));
}
}
}
|
|
|
|
|
First off, you don't need to declare an unsafe context (forces unverifiable code, leading to additional code access security constraints) if you just use the Marshal.SizeOf method; or - better yet - just hard-code it in (it's not like it changes often).
Are you actually getting the HWND (as an IntPtr ) for Citrix WinFrame? Also, are you actually trying to pass this through WinFrame to a remote application? You should consult the Citrix developer API documentation. Citrix may hook keyboard and mouse operations in order to forward them to the remote host. Simply sending messages or input directly may not work (depending on how they handle keyboard and mouse input). This would seem to be the case even more so since you've mentioned that your example code works for other applications that would be running locally (instead of inside a virtual frame buffer).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the suggestion. The HWND is the actuall Citrix WinFram. I can send text to it using sendkeys and keybd_event but not Alt and Ctrl. I've been reading "In Search of the Lost Win32 API" (because as my code reflects I know very little about Win32 API) and I think I'm going to try postmessage() API. I found a reference to this on the citrix website also.
|
|
|
|
|
I just noticed that all you're doing is sending 'A' (0x41). Have you tried OR'ing it with Shift (0x10) or Ctrl (0x11)? This is the most common approach. You can also use and cast the Keys enumeration defined in .NET to do this, since - for good reason - it uses the same values as the VK_ constants:
byte b = (byte)(Keys.Control | Keys.A);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Before I got to the complicated stuff I just wanted to send a simple 'A' to notepad. I can not get SendInput() to work or PostMessage() using WM_KeyDown and WM_Keyup to work. I used Spy++ and nothing is being sent. I did however figure out PostMessage using WM_MenuSelect with WM_Command which allows me to just select the menu item instead of sending keystrokes but, this will not pass through Citrix either. I looked at the Citrix COM and it is just interfaces and no code. I setup the keyboard interface with the Citrix COM but still no luck because with the interface you still have to define keyup and keydown.
This is my solution as ragtag as it may be. I have a small app runing through Citrix used as a relay. On the local side when a barcode is scanned it activates the local app which relays the barcode info to the app running through Citrix this way when the remote app activates it sends all the commands to the (very expensive but disfunctionally hard to use Medical Record program)(After all we are talking about doctors here) on the server side and everything works. I must say there is some good stuff in the Win32 API.
|
|
|
|
|
As I mentioned before, any messages you send or post to the Citrix WinFrame is only sending it to the host application. What that application does with them is a different story (and it obviously doesn't pass them on). That's why I mentioned looking at their developer APIs (if available). It may use a keyboard and mouse hook to intercept and transfer input, but posting and sending messages that do the same thing may not.
Surely there must be a developer forum (web-based, newsgroups, mail lists, etc.) somewhere for Citrix WinFrame (either official or unofficial). That would definitely be a good place to start; otherwise, such a "ragtag" workaround may be your only bet.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I finally got it. PostMessage works with WM_Keydown and WM_Keyup but you must make wParam and lParam type UIntPtr. Thanks for your help. No "ragtag" required!
|
|
|
|
|
Just a quick question,
Is there any way in the Framework that my application can get an event when Windows jumps into and out of full screen mode (EG, a full screen DX or OpenGL application starts/ends)? And if not, is there anything in Win32 to achieve this?
I am aware of the notification in Shell32 for Application Desktop Toolbars, however, that would mean creating a Desktop Toolbar?? Is there any other way?
Thanks!
--
Rob Hutchinson.
|
|
|
|
|
Going into full-screen mode is really two different operations. One is optional, and requires changing the screen resolution (for which you can handle the SystemEvents.DisplaySettingsChanged event). The other is simple creating a dialog with certain window styles set and does not generate any such events. The event I mentioned above (which fires in response to the WM_DISPLAYCHANGE system notification message) is really about the only change you have beside possibly hooking certain APIs based on the graphics engine used. Even if a particular runtime would provide such notification, I really can't help you there.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hy everyone!
I do want to add an item to Outlooks contextmenu. It should be like this:
When rightclicking in Outlook the contextmenu should contain my item to start my programm.
If possible this should only happen when rightclicking Outlook contacts (meaning in the contactitem contextmenu).
When selecting my item my programm should be started. If possible it should also be sent the data of the selected contact, but this isn't a must have but if it is possible it would be wonderfull.
I had a look in the MSDN, I had a look in the web and found some pages concerning (context) menues, but so far there hasn't been any for solving my problem.
So if anyone of you knew a page where to look for it would help a lot.
Or if anyone had a sample of a similar program this would help me too.
Thanks!
Stephan.
|
|
|
|
|
You should start by reading Outlook 2003 Technical Articles[^]. You use the DTE (design-time environment) plus the Office interop assemblies (with Office 2003, these come with Professional and larger; for Office XP the official PIAs can be downloaded from http://msdn.microsoft.com[^]) to extend the UI with context menus.
This is for COM-like behavior, though. It's a poor design to just start your application and expect to pass data to it. The command line is pretty much out, unless you want to pass a moniker to the Contact in Outlook with your application then uses. That wouldn't be an easy task, however. DDE is out-dated. The best way is to expose your .NET application as a COM server and do it the right way - the same way as other interoperable applications do with Office (in fact, it's how you're using the Office APIs in .NET or any other environment).
There's lots of documentation in MSDN[^] about all this. Search for articles about extending Office with .NET. While you may not find any specifically for Outlook, there are a lot for Word and Excel that are very similar in nature.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
well we are still using Office 2000 on those machines we do code on.
Well there are different versions available on the machine around us and our aim is to make our proggy work no matter which version of Office might be used, but well, maybe our aim is far too complex.
But anyways: Thanks for the hints. I will look them up and I guess there will also be some kind of "general solution" for all versions of Office.
Stephan.
|
|
|
|
|
And the Office typelibs are backward compatible, which means if you create the interop assemblies yourself (using tlbimp.exe or VS.NET's Add Reference to a COM library) for an older Office, almost all functionality from that older typelib will work in newer Office systems. This is fundamental to COM when written correctly (and Microsoft most often does; only some interfaces may be deprecated when necessary). So, just create interop assemblies from Office 2000 (the PIAs - Primary Interop Assemblies - from Office XP may in fact work, so long as any CLSIDs didn't changed; IIRC, only new COM objects had new CLSIDs) and use those. They will work with newer Office builds.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Just ran across An Introduction to Programming Outlook 2003 Using C#[^] today on MSDN - something I read daily (as every serious developer should). You should find it helpful.
Don't forget to read Exposing .NET Framework Components to COM[^] in the .NET Framework SDK to know how to correctly expose your .NET components as COM controls, like always declaring a GuidAttribute for classes and interfaces, never changing a published interface (inherit from it), and never using auto-generated class interfaces (.NET is tolerant of this, but COM is not).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Using the code written by Georgi Atanasov in his article
Customizingthe header control in a ListView[^]
if you use the XP theme by calling:
Application.EnableVisualStyles();
the header control is re-set to the orriginal size rather than being increased. Has anyone found a way to keep the custom header height with the XP theme switched on?
|
|
|
|
|
If you have a question or comment above a specific article, post it on the article's message board at the bottom.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Using the code written by Georgi Atanasov in his article
Customizingthe header control in a ListView[^]
if you use the XP theme by calling:
Application.EnableVisualStyles();
the header control is re-set to the orriginal size rather than being increased. Has anyone found a way to keep the custom header height with the XP theme switched on?
|
|
|
|
|
I have a control wich im trying to draw using its Graphics object in another method , but the control remains blank (just the background color)?
|
|
|
|
|
One problem can be coordinates.
All controls GDI+ drawing is relative to the control not the parent. control.Bounds is in parent coordinates while control.Clientrect is control coordinates (i.e. it will have (0,0) as the top left).
If you make the control bigger, do you see the drawing you were expecting?
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|
|
Hi there,
first excuse the bad title but i don't know how to call me problem else *g*
I think everybody knows Outlook - if you click on anything there like "calander" it will appears in the right part of the window.
i need something like that. I've got the Outlookbar on my left site, but how can I realize it? I mean can I predefine (VS.net) where my buttons, checkboxes, ect. should appear when the user clicks on something in my left bar?
Or have I to programm it fully by hand in my code? That wouldn't be could, because I would have to test every position by hand *grrr*
Thx!!
-bb
|
|
|
|