-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "sample_task_dialog_sys" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies.windows-sys] | ||
path = "../../../libs/sys" | ||
features = [ | ||
"Win32_UI_Controls", | ||
"Win32_UI_WindowsAndMessaging", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
if std::env::var("CARGO_CFG_TARGET_ENV").unwrap() == "msvc" { | ||
println!("cargo:rerun-if-changed=manifest.xml"); | ||
println!("cargo:rustc-link-arg-bins=/MANIFEST:EMBED"); | ||
|
||
println!( | ||
"cargo:rustc-link-arg-bins=/MANIFESTINPUT:{}", | ||
std::path::Path::new("manifest.xml") | ||
.canonicalize() | ||
.unwrap() | ||
.display() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> | ||
<asmv3:application> | ||
<asmv3:windowsSettings> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | ||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> | ||
</asmv3:windowsSettings> | ||
</asmv3:application> | ||
<dependency> | ||
<dependentAssembly> | ||
<assemblyIdentity | ||
type="win32" | ||
name="Microsoft.Windows.Common-Controls" | ||
version="6.0.0.0" | ||
processorArchitecture="*" | ||
publicKeyToken="6595b64144ccf1df" | ||
language="*"/> | ||
</dependentAssembly> | ||
</dependency> | ||
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use windows_sys::{core::*, Win32::Foundation::*, Win32::UI::Controls::*}; | ||
|
||
fn main() { | ||
unsafe { | ||
let mut config = TASKDIALOGCONFIG { | ||
cbSize: std::mem::size_of::<TASKDIALOGCONFIG>() as _, | ||
..std::mem::zeroed() | ||
}; | ||
|
||
let buttons = [TASKDIALOG_BUTTON { | ||
nButtonID: 123, | ||
pszButtonText: w!("Let's do it"), | ||
}]; | ||
|
||
config.pszWindowTitle = w!("Window title"); | ||
config.pszMainInstruction = w!("Main instruction"); | ||
config.pszContent = w!("Content"); | ||
config.pButtons = buttons.as_ptr(); | ||
config.cButtons = buttons.len() as _; | ||
config.pfCallback = Some(callback); | ||
config.dwFlags = TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION; | ||
|
||
let mut selection = 0; | ||
|
||
TaskDialogIndirect( | ||
&config, | ||
&mut selection, | ||
std::ptr::null_mut(), | ||
std::ptr::null_mut(), | ||
); | ||
|
||
if selection == buttons[0].nButtonID { | ||
println!("custom button"); | ||
}; | ||
} | ||
} | ||
|
||
extern "system" fn callback(_: HWND, notification: u32, _: WPARAM, _: LPARAM, _: isize) -> HRESULT { | ||
if notification == TDN_BUTTON_CLICKED as _ { | ||
println!("button clicked"); | ||
} | ||
|
||
0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "sample_task_dialog" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies.windows] | ||
path = "../../../libs/windows" | ||
features = [ | ||
"Win32_UI_Controls", | ||
"Win32_UI_WindowsAndMessaging", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
if std::env::var("CARGO_CFG_TARGET_ENV").unwrap() == "msvc" { | ||
println!("cargo:rerun-if-changed=manifest.xml"); | ||
println!("cargo:rustc-link-arg-bins=/MANIFEST:EMBED"); | ||
|
||
println!( | ||
"cargo:rustc-link-arg-bins=/MANIFESTINPUT:{}", | ||
std::path::Path::new("manifest.xml") | ||
.canonicalize() | ||
.unwrap() | ||
.display() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> | ||
<asmv3:application> | ||
<asmv3:windowsSettings> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | ||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> | ||
</asmv3:windowsSettings> | ||
</asmv3:application> | ||
<dependency> | ||
<dependentAssembly> | ||
<assemblyIdentity | ||
type="win32" | ||
name="Microsoft.Windows.Common-Controls" | ||
version="6.0.0.0" | ||
processorArchitecture="*" | ||
publicKeyToken="6595b64144ccf1df" | ||
language="*"/> | ||
</dependentAssembly> | ||
</dependency> | ||
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use windows::{core::*, Win32::Foundation::*, Win32::UI::Controls::*}; | ||
|
||
fn main() -> Result<()> { | ||
unsafe { | ||
let mut config = TASKDIALOGCONFIG { | ||
cbSize: std::mem::size_of::<TASKDIALOGCONFIG>() as _, | ||
..Default::default() | ||
}; | ||
|
||
let buttons = [TASKDIALOG_BUTTON { | ||
nButtonID: 123, | ||
pszButtonText: w!("Let's do it"), | ||
}]; | ||
|
||
config.pszWindowTitle = w!("Window title"); | ||
config.pszMainInstruction = w!("Main instruction"); | ||
config.pszContent = w!("Content"); | ||
config.pButtons = buttons.as_ptr(); | ||
config.cButtons = buttons.len() as _; | ||
config.pfCallback = Some(callback); | ||
|
||
config.dwFlags = | ||
TASKDIALOG_FLAGS(TDF_USE_COMMAND_LINKS.0 | TDF_ALLOW_DIALOG_CANCELLATION.0); | ||
|
||
let mut selection = 0; | ||
|
||
TaskDialogIndirect(&config, Some(&mut selection), None, None)?; | ||
|
||
if selection == buttons[0].nButtonID { | ||
println!("custom button"); | ||
}; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
extern "system" fn callback(_: HWND, notification: u32, _: WPARAM, _: LPARAM, _: isize) -> HRESULT { | ||
if notification == TDN_BUTTON_CLICKED.0 as _ { | ||
println!("button clicked"); | ||
} | ||
|
||
HRESULT(0) | ||
} |