Add NotifyIcon example

This commit is contained in:
haru-s 2023-03-20 00:06:53 +09:00
parent 5c50f00721
commit e8487df076
10 changed files with 126 additions and 0 deletions

16
examples/notifyicon/.gitignore vendored Normal file
View file

@ -0,0 +1,16 @@
.dub
docs.json
__dummy.html
docs/
/hello_dfl
hello_dfl.so
hello_dfl.dylib
hello_dfl.dll
hello_dfl.a
hello_dfl.lib
hello_dfl-test-*
*.exe
*.pdb
*.o
*.obj
*.lst

13
examples/notifyicon/.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (Windows) notifyicon",
"type": "cppvsdbg",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "./bin/notifyicon_sample.exe",
"console": "internalConsole"
}
]
}

20
examples/notifyicon/.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,20 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "dub",
"run": false,
"cwd": ".",
"compiler": "$current",
"archType": "$current",
"buildType": "$current",
"configuration": "$current",
"problemMatcher": [
"$dmd"
],
"group": "build",
"label": "dub: Build notifyicon_sample",
"detail": "dub build --compiler=dmd.EXE -a=x86_64 -b=debug -c=application"
}
]
}

View file

@ -0,0 +1,2 @@
# Screen Shot
![screen shot](./image/screenshot.png "screen shot")

View file

@ -0,0 +1,16 @@
{
"authors": ["haru-s"],
"copyright": "Copyright (C) 2023 haru-s",
"description": "DFL sample code.",
"name": "notifyicon_sample",
"targetType": "executable",
"targetPath": "bin",
"dependencies": {
"dfl": {
"path": "../../../dfl"
}
},
"lflags-windows-x86_omf-dmd": ["/exet:nt/su:windows:6.0"],
"lflags-windows-x86_mscoff-dmd": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"],
"lflags-windows-x86_64-dmd": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View file

@ -0,0 +1,12 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"d.projectImportPaths": [
"..\\..\\..\\dfl\\source"
]
}
}

View file

@ -0,0 +1,3 @@
set dmd_path=c:\d\dmd2\windows
set dmc_path=c:\dmc\dm
cmd

View file

@ -0,0 +1,44 @@
import dfl;
version(Have_dfl) // For DUB.
{
}
else
{
pragma(lib, "dfl.lib");
}
class MainForm : Form
{
private NotifyIcon _notifyIcon;
public this()
{
this.text = "NotifyIcon example";
this.size = Size(300, 200);
MenuItem _menuItem1 = new MenuItem("Show");
_menuItem1.click ~= (MenuItem mi, EventArgs e) { msgBox("Hi!"); };
MenuItem _menuItem2 = new MenuItem("Close");
_menuItem2.click ~= (MenuItem mi, EventArgs e) { this.close(); };
_notifyIcon = new NotifyIcon;
_notifyIcon.icon = new Icon(r".\image\icon.ico");
_notifyIcon.text = "This is tooltip text";
_notifyIcon.contextMenu = new ContextMenu;
_notifyIcon.contextMenu.menuItems.add(_menuItem1);
_notifyIcon.contextMenu.menuItems.add(_menuItem2);
_notifyIcon.show();
}
}
static this()
{
Application.enableVisualStyles();
}
void main()
{
Application.run(new MainForm());
}