从C#托盘应用程序中显示消息框

从C#托盘应用程序中显示消息框

本文介绍了从C#托盘应用程序中显示消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我用C#开发了一个RESTful Windows托盘应用程序。我从javascript通过ajax调用http:// localhost:8888 / ....访问此应用程序的公共函数。



在托盘应用程序中,我引用了一个vb6 dll。



现在我的查询...

在应用程序的执行过程中,vb dll会显示一个消息框。由于我从Web浏览器调用该进程,因此浏览器后面会显示消息框。因此,用户必须按alt + tab才能看到消息,这需要花费大量时间。



我希望此消息框显示在所有消息之上应用程序始终。



托盘应用程序和vb6 dll中没有表单元素。



请帮我解决这个问题。



问候



我的尝试:



我尝试使用以下代码但没有用



private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);

private const UInt32 SWP_NOSIZE = 0x0001;

private const UInt32 SWP_NOMOVE = 0x0002;

private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;



[DllImport(user32.dll)]

[返回:MarshalAs(UnmanagedType.Bool)]

public static extern bool SetWindowPos(IntPtr hWnd,IntPtr hWndInsertAfter,int X,int Y,int cx,int cy,uint uFlags);

Hi,

I have developed a RESTful windows tray application in C#. I access the public functions of this application from javascript via ajax call to http://localhost:8888/....

In the tray application i have referenced to a vb6 dll.

Now my query...
During the application's execution process, the vb dll shows a message box. Since I am calling the process from web browser, the message box appears behind the browser. Hence, The user has to press alt+tab to see the message, which is costing lot of time.

I want this message box to show up on top of all application all the time.

There is no form element in the tray application and vb6 dll.

Please help me to solve this issue.

Regards

What I have tried:

I have tried using the following code but no use

private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
private const UInt32 SWP_NOSIZE = 0x0001;
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

推荐答案



这篇关于从C#托盘应用程序中显示消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 14:21