我不是一名职业程序员(我所拥有的任何 Java 知识都来自 Hard Knocks 学院)。请原谅我提出的愚蠢问题,并妥善回答。
我正在开发的一个 Java 应用程序使用了非常有缺陷的与平台无关的通知(例如文件已成功下载时)。我想使用平台感知通知。在 Linux 上发出通知的代码非常简单:
import org.gnome.gtk.Gtk;
import org.gnome.notify.Notify;
import org.gnome.notify.Notification;
public class HelloWorld
{
public static void main(String[] args) {
Gtk.init(args);
Notify.init("Hello world");
Notification Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information");
Hello.show();
}
}
Run Code Online (Sandbox Code Playgroud)
在 Mac 上,它有点复杂,但仍然可行:
interface NsUserNotificationsBridge extends Library {
NsUserNotificationsBridge instance = (NsUserNotificationsBridge)
Native.loadLibrary("/usr/local/lib/NsUserNotificationsBridge.dylib", NsUserNotificationsBridge.class);
public int sendNotification(String title, String subtitle, String text, int timeoffset);
}
Run Code Online (Sandbox Code Playgroud)
它需要从这个 github 存储库获取 dylib:https://github.com/petesh/OSxNotificationCenter
Windows方式是这样的:
import java.awt.*;
import java.awt.TrayIcon.MessageType; …Run Code Online (Sandbox Code Playgroud) 我想通过用鼠标左键单击文本“退出”来退出此系统托盘程序。当我悬停时,鼠标会显示一个旋转的蓝色图标,并且单击不会执行任何操作。剧本有什么问题?
# a systray program, that should be exited (but it doesn't)
# 2023-03-18
$iconPath = "H:\Dropbox\400 - Scriptprogrammierung\Powershell\Taskleiste mit Wochentag\icons\ico\Logo.ico" # icon path
Write-Host -ForegroundColor Yellow $iconPath
$tooltip = "This is a text."
# NotifyIcon-object
$notifyIcon = New-Object System.Windows.Forms.NotifyIcon
$notifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($iconPath)
$notifyIcon.Text = $tooltip
########################
# Here seems to be the problem...
$contextMenu = New-Object System.Windows.Forms.ContextMenuStrip
$menuItemExit = New-Object System.Windows.Forms.ToolStripMenuItem
$menuItemExit.Text = "Quit."
$contextMenu.Items.Add($menuItemExit)
$notifyIcon.ContextMenuStrip = $contextMenu
$menuItemExit.add_Click({ $notifyIcon.Dispose(); exit })
########################
# Show icon in systray
$notifyIcon.Visible …Run Code Online (Sandbox Code Playgroud) 嘿,我正在尝试制作一个程序,将程序最小化到系统托盘而不是通常最小化它.这可能吗?我一直在寻找谷歌,但无法找到任何东西.
我有一个程序,它不会启动最小化,并在dekstop上显示一个非常小的窗口.
图片:http://i.imgur.com/j8xus.jpg
码:
程序:
program Project4;
uses
Forms,
Unit4 in 'Unit4.pas' {Form4};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := false;
Application.ShowMainForm:=false;
Application.CreateForm(TForm4, Form4);
Application.Run;
end.
Run Code Online (Sandbox Code Playgroud)
单元:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AppEvnts, ExtCtrls, Menus;
type
TForm4 = class(TForm)
TrayIcon1: TTrayIcon;
ApplicationEvents1: TApplicationEvents;
PopupMenu1: TPopupMenu;
Exit1: TMenuItem;
procedure TrayIcon1DblClick(Sender: TObject);
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure ApplicationEvents1Restore(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure Exit1Click(Sender: TObject);
private
{ Private …Run Code Online (Sandbox Code Playgroud) 我遇到了一些我认为很容易的问题...我无法让我的NotifyIcon显示气球提示.基本代码是:
public void ShowSystrayBubble(string msg, int ms)
{
sysTrayIcon.Visible = true;
sysTrayIcon.ShowBalloonTip(20, "Title", "Text", ToolTipIcon.None);
}
Run Code Online (Sandbox Code Playgroud)
执行此代码时没有任何反应.我读到超时arg可能是几秒或几毫秒,不能说,所以我试过两个都没有用.
我正在使用WinXP,.NET 3.5.
我需要创建/设计QT系统弹出窗口,我正在考虑创建源自QDialog的自定义窗口,所以它看起来比普通的"信息,警告,关键样式"更好
我的问题是如何才能检测到的位置桌面系统,所以如何给弹出窗口提供系统弹出窗口
的外观和感觉
我想最小化一个Delphi应用程序到系统托盘而不是任务栏.
必要的步骤似乎如下:
而已.对?
如何在Delphi中实现这一点?
我发现了以下代码,但我不知道为什么会这样.它不遵循我上面描述的步骤......
unit uMinimizeToTray;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellApi;
const WM_NOTIFYICON = WM_USER+333;
type
TMinimizeToTray = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CMClickIcon(var msg: TMessage); message WM_NOTIFYICON;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
MinimizeToTray: TMinimizeToTray;
implementation
{$R *.dfm}
procedure TMinimizeToTray.CMClickIcon(var msg: TMessage);
begin
if msg.lparam = …Run Code Online (Sandbox Code Playgroud) systray ×7
c# ×2
delphi ×2
.net ×1
click ×1
exit ×1
forms ×1
hide ×1
java ×1
notifyicon ×1
popupwindow ×1
powershell ×1
qt ×1
system-tray ×1
taskbar ×1
windows ×1
winforms ×1