Skip to content

Commit

Permalink
창 점멸하는 현상, 이모티콘창 안되고 그런 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
AquaRains committed Jul 23, 2024
1 parent 23bcd56 commit 4c02fb6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
9 changes: 4 additions & 5 deletions net8/KKADBlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<StartupObject>KKADBlow.Program</StartupObject>
<Platforms>AnyCPU;x64</Platforms>
Expand All @@ -11,6 +11,9 @@
<Authors>suwoo</Authors>
<Company>myhome</Company>
<ApplicationIcon>Check-04-WF.ico</ApplicationIcon>
<PublishAot>true</PublishAot>
<IsAotCompatible>true</IsAotCompatible>
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>
<PackageLicenseFile>README.md</PackageLicenseFile>
<NeutralLanguage>ko-KR</NeutralLanguage>
<SignAssembly>false</SignAssembly>
Expand All @@ -24,10 +27,6 @@

<ItemGroup>
<None Remove="Check-04-WF.ico" />
<None Include="README.md">
<Pack>True</Pack>
<PackagePath>./</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion net8/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Platform>x64</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
Expand Down
File renamed without changes.
9 changes: 2 additions & 7 deletions rust/src/gui/w32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn find_area_and_shrink(_: Option<Sender<Message>>, mut option: AppData) ->
let current_pid = TrayItem::get_window_thread_process_id(h);

//찾아낼 창의 클래스명
let (ad_class, ad_windowname, _) = option.target_ad_area.deconstruct();
let (ad_class, ad_window_name, _) = option.target_ad_area.deconstruct();

//내가 찾을 타겟의 프로세스를 확인
if parent_pid == current_pid {
Expand All @@ -80,7 +80,7 @@ pub fn find_area_and_shrink(_: Option<Sender<Message>>, mut option: AppData) ->


//광고부분일경우
if ad_class == current_class && current_window == ad_windowname {
if ad_class == current_class && current_window == ad_window_name {
ad_target_founded = {
//현재 창의 핸들로 child 핸들명도 찾아서 체크 해야 한다.
enumerate_child_windows(h, |h2| {
Expand Down Expand Up @@ -115,11 +115,6 @@ pub fn find_area_and_shrink(_: Option<Sender<Message>>, mut option: AppData) ->
Err(_) => { return false }
};
option.target_ad_area.window_area = Some(rect);
//여기까지 찾았으면 빼박이니까 제거, 제거하기전에 0으로 만들고 제거해버리자
match TrayItem::set_windows_position(h, HWND::default(), 0, 0, 0, 0) {
Ok(_) => { }
Err(_) => { }
}

match TrayItem::hide_item(h) {
Ok(_) => { true }
Expand Down
14 changes: 8 additions & 6 deletions rust/src/gui/w32/traits.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::mem;
use std::ops::BitOrAssign;
use windows::Win32::Foundation::{BOOL, HWND, LPARAM, RECT};
use windows::Win32::Graphics::Gdi::{RDW_ALLCHILDREN, RDW_ERASE, RDW_ERASENOW, RDW_INVALIDATE, RedrawWindow};
use windows::Win32::UI::Shell::{NIF_ICON, NIM_MODIFY, NOTIFYICONDATAW, Shell_NotifyIconW};
use windows::Win32::UI::WindowsAndMessaging::{EnumChildWindows, EnumWindows, FindWindowExW, FindWindowW, GetClassNameW, GetParent, GetWindowRect, GetWindowTextW, GetWindowThreadProcessId, HICON, IMAGE_ICON, InsertMenuItemW, LoadImageW, LR_DEFAULTCOLOR, MENUITEMINFOW, MFS_CHECKED, MFS_DISABLED, MFS_UNCHECKED, MFS_UNHILITE, MFT_SEPARATOR, MFT_STRING, MIIM_CHECKMARKS, MIIM_FTYPE, MIIM_ID, MIIM_STATE, MIIM_STRING, SetMenuItemInfoW, SetWindowPos, ShowWindow, SW_HIDE, SWP_NOMOVE, WNDENUMPROC};
use windows::Win32::UI::WindowsAndMessaging::{EnumChildWindows, EnumWindows, FindWindowExW, FindWindowW, GetClassNameW, GetParent, GetWindowRect, GetWindowTextW, GetWindowThreadProcessId, HICON, HWND_BOTTOM, IMAGE_ICON, InsertMenuItemW, LoadImageW, LR_DEFAULTCOLOR, MENUITEMINFOW, MFS_CHECKED, MFS_DISABLED, MFS_UNCHECKED, MFS_UNHILITE, MFT_SEPARATOR, MFT_STRING, MIIM_CHECKMARKS, MIIM_FTYPE, MIIM_ID, MIIM_STATE, MIIM_STRING, SetMenuItemInfoW, SetWindowPos, ShowWindow, SW_HIDE, SWP_ASYNCWINDOWPOS, SWP_HIDEWINDOW, SWP_NOACTIVATE, SWP_NOCOPYBITS, SWP_NOMOVE, SWP_NOREDRAW, SWP_NOSENDCHANGING, WNDENUMPROC};
use crate::err::ApplicationError;
use crate::gui::IconSource;
use crate::gui::w32::string_extensions::{ToPCWSTRWrapper, ToPWSTRWrapper};
Expand Down Expand Up @@ -340,11 +341,12 @@ impl MainFeature for TrayItem {

fn hide_item(handle_area: HWND) -> Result<(), ApplicationError> {
unsafe {
if ShowWindow(handle_area, SW_HIDE).as_bool() {
Ok(())
} else {
Err(ApplicationError::new("Cannot Hide Window."))
}
let handle_parent = GetParent(handle_area).unwrap_or_else(|_| { HWND_BOTTOM });

SetWindowPos(handle_area, handle_parent, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_ASYNCWINDOWPOS).unwrap_or_default();

_ = RedrawWindow(handle_area, None, None, RDW_ERASE | RDW_INVALIDATE | RDW_ERASENOW | RDW_ALLCHILDREN);
Ok(())
}
}

Expand Down
4 changes: 2 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ mod gui;
mod err;
mod memory_lock;
mod structs;
mod funcs;
mod func;

use std::sync::mpsc::Sender;
use crate::gui::{TrayApplication, IconSource};
use crate::gui::w32::traits::{Label, Menu, Separator};
use crate::structs::{AppData, ElapsedHandler, Message, TimerTrait};
pub use crate::funcs::options_from_console_args;
pub use crate::func::options_from_console_args;

use windows::core::{PCWSTR, w};
use crate::gui::w32::find_area_and_shrink;
Expand Down

0 comments on commit 4c02fb6

Please sign in to comment.