PawelPepe 1 Posted May 16 Hey, I am trying to write simple application that works with Windows Clipboard (capture Clipboard changes (WM_CLIPBOARDUPDATE) and do some actions. Application uses TTrayIcon component. So, I can hide main window in notification area. If user press Print Screen button or copy text into Clipboard my application do some actions. One of the features is to show user a message (with some description text, icon etc) when application is hidden in tray. I do not use TTrayIcon Balloon hint (it is not good for me). Instead, I created second form and display it when clipboard change its content. It works fine, when application main window is visible (on screen). I set some options in form OnShow event and do some animation (to slide from right screen corner) in OnActivate event. It is OK. When application main window is hidded there is a big problem! What I do: Form2.Show; -> OnShow And OnActivate events are fired. BUT, if I show form2 again (second, third time), only OnShow event is fired - OnActivate event is not working! WHY? I hide mainform to Tray: Application.ShowMainForm := False; MainFrm.Hide; ShowWindow(Application.Handle, SW_HIDE); And I show it using: MainFrm.Show; Application.ShowMainForm := True; ShowWindow(Application.Handle, SW_SHOW); Application.BringToFront(); -Pawel Share this post Link to post
Remy Lebeau 1394 Posted May 16 3 hours ago, PawelPepe said: When application main window is hidded there is a big problem! What I do: Form2.Show; -> OnShow And OnActivate events are fired. BUT, if I show form2 again (second, third time), only OnShow event is fired - OnActivate event is not working! WHY? Are you merely hiding and reshowing Form2 on each message? Or are you fully destroying and recreating it? 3 hours ago, PawelPepe said: I hide mainform to Tray: Application.ShowMainForm := False; MainFrm.Hide; ShowWindow(Application.Handle, SW_HIDE); And I show it using: MainFrm.Show; Application.ShowMainForm := True; ShowWindow(Application.Handle, SW_SHOW); Application.BringToFront(); FYI, Application.ShowMainForm only affects the startup of Application.Run(), so once the app is up and running then setting ShowMainForm has no effect. Also, hiding/showing the Application.Handle is only useful in this case if Application.MainFormOnTaskbar is false, which is not the default in modern Delphi projects. Share this post Link to post
PawelPepe 1 Posted May 16 (edited) I am hiding and reshowing Form2 on each message. Quote Application.ShowMainForm only affects the startup of Application.Run() You are right! Quote Also, hiding/showing the Application.Handle is only useful in this case if Application.MainFormOnTaskbar is false, which is not the default in modern Delphi projects. Again, you are right (I use default - Application.MainFormOnTaskbar := True). So, now it looks like this. Hiding: MainFrm.Hide; Showing: MainFrm.Show; Application.BringToFront(); Unfortunatelly, nothing has changed. Maybe I will prepare example test app to show what I have and what I want to achieve? I also tried to dynamically create Form2 and destroy it on each message (but I failed with my "animation" and modal window). -Pawel Edited May 16 by PawelPepe Share this post Link to post
PawelPepe 1 Posted May 16 (edited) Thanks for help. I think I got it working now. I decided to create form and destroy it each time clipboard is updated. Relying on onShow and onActivate events was not good idea. -Pawel Edited May 17 by PawelPepe Share this post Link to post