How to start a doc view app in hidden mode
Hi all of you. From some time I struggle to start an MDI app in hidden mode (with an icon in system tray), but seem to appear an flicker in taskbar on application startup ...
What I have tried ? All the solution from here:
https://stackoverflow.com/questions/...cation-hidden/
An important notice: there is an VS2008/VS2010 MDI project (the same behavior with VS2008 or VS2010.
Has anyone did solved this task ? Can you help me ?
Re: How to start a doc view app in hidden mode
Read this It will help you.https://msdn.microsoft.com/en-us/library/ms973874.aspx
If you like my answer,do rate it.:d
Re: How to start a doc view app in hidden mode
Quote:
Originally Posted by
A_Singh
How does that help the specific problem?
Re: How to start a doc view app in hidden mode
By reading that, one can gain more knowledge about the while topic, thus having easiness in solving the probelem, an internet search about this topic even provides some helping code snippets,
Re: How to start a doc view app in hidden mode
Quote:
Originally Posted by
A_Singh
By reading that, one can gain more knowledge about the while topic, thus having easiness in solving the probelem, an internet search about this topic even provides some helping code snippets,
That article references .net, whilst the question concerned c++. :confused:
Re: How to start a doc view app in hidden mode
Re: How to start a doc view app in hidden mode
Quote:
Originally Posted by
A_Singh
That link is broken. Error 404 not found.
Re: How to start a doc view app in hidden mode
Quote:
Originally Posted by
2kaud
That link is broken. Error 404 not found.
That and the OP isn't asking for an MDI doc/view overview. He's asking specifically how to stop the task bar flickering when the app starts up hidden.
Re: How to start a doc view app in hidden mode
So, please go ahead and give your solutions.
Re: How to start a doc view app in hidden mode
Quote:
Originally Posted by
ioancalator
Has anyone did solved this task ? Can you help me ?
As you might understand to the moment, the trouble part is MFC standard behavior. In fact, you tried to bend what initially designed to be straight, and by no means this is a sort of common practice obliged to have a standard solution.
So, in case you need to get a real help with this, you have to provide here a simplistic project (or projects, as solution essence may depend on particular MFC version) that clearly demonstrates the issue.
Dealing with explicit code is going to be much more productive by not making us guess about what 'this task' really is and what you already tried to do with that.
1 Attachment(s)
Re: How to start a doc view app in hidden mode
Kindly thank you for your interest.
Yes, I have made an test app (in VS2008), MDI, that reveal the behavior from the first post.
What I have tried by now ?
Code:
BOOL CTestApp::InitInstance()
{
.....
EnableLoadWindowPlacement(FALSE);
.....
m_nCmdShow = SW_HIDE;
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (! ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
started this test app, you will notice an flicker in taskbar (tested in Win10 64bit). The test app will automatically close after 3 seconds, in order to make easy to test it.
That is why, you can start multiple instances (in this way, you will spot the taskbar flicker very easy), and they will clean up their self.
I have saw that overriding
Code:
CWinAppEx::LoadState(LPCTSTR lpszSectionName /*=NULL*/, CFrameImpl* pFrameImpl /*= NULL*/)
in such a way:
Code:
// Test.h
virtual BOOL LoadState(LPCTSTR lpszSectionName = NULL, CFrameImpl* pFrameImpl = NULL){return TRUE;}
the problem is solved, but I cannot do this because there is handled a lot of useful things.
I will appreciate any help !
Thank you.
Re: How to start a doc view app in hidden mode
So far I can see that Test.exe built as is with VS2012 runs with no flicker in Win 7 SP1. Will give it a try with VS2010, when I find a VM with the one. Sorry, have no Win10 at hand, and have no time to install that.
Re: How to start a doc view app in hidden mode
Quote:
Originally Posted by
Igor Vartanov
So far I can see that Test.exe built as is with VS2012 runs with no flicker in Win 7 SP1. Will give it a try with VS2010, when I find a VM with the one.
Thank you Igor. I guess the flicker is present on Win10 as OS, rather than project VS. And this flicker are noticeable when you run the Test.exe on an not so fast PC, or, starting multiple instances from Windows Explorer (and they will automatically stop, one by one), by simply keeping Enter key on Test.exe ... in this way you easily see the taskbar flicker.
Re: How to start a doc view app in hidden mode
Also, I have tried:
Code:
BOOL CTestApp::InitInstance()
{
CSettingsStoreSP::SetRuntimeClass(NULL);
.....
}
no effect ...
Re: How to start a doc view app in hidden mode
Okay, there is an update. 32-bit Test.exe built with VS2010 runs with no flicker in Win7 x64 SP1 (Aero Theme).
The same exe time to time (but rare) produces some flicker in a virtual machine running with extremely low resources (2 CPU cores, 2GB RAM) for Win7 x64 SP1 (Windows Classic scheme).
So it's hardly about OS version or VS version, but just hardware resources or window manager maybe.
Re: How to start a doc view app in hidden mode
Quote:
Originally Posted by
Igor Vartanov
BTW, taskbar button appears for top-level windows having WS_EX_APPWINDOW style and never does for WS_EX_TOOLWINDOW. So maybe an explicit juggling with the styles is required.
Yes Igor, this could be a solution ... but is there possible to change this style flag, at runtime ? Because, at some point, this app should be visible ...
In fact, while I am thinking, this flag should be setup as WS_EX_TOOLWINDOW only at startup, right after, I could switch back this flag as WS_EX_APPWINDOW ...
Re: How to start a doc view app in hidden mode
Afraid WS_EX_APPWINDOW style cannot be (un)set at runtime. Documentation says nothing about that, so you have to do some experiments.
You may try to play with ITaskbarList shell interface to explicitly control the button visibility (which originally is window manager responsibility), but I suspect there must be some race between calling CreateWindowEx and button show-up, otherwise you have to force MFC to not set the style somehow.
Well, as I said before, you're trying to interfere with standard window manager behavior and MFC routine execution. Typically, window manager does its work just fine, but under condition of heavyweight window tasks coming in a row there inevitably comes a lag. Not because of your code, but because of the limited performance of the Windows core component.
You might live with that.
Or you might radically refactor your app startup. Like, start with invisible tool window serving your tray icon needs, but create a MDI frame window only when instructed to go visible. Good knowledge of MFC is a must, as you are to change the standard way of launching MDI frame and doc-view part if you have one.
Or even more radically, like splitting your functionality to a server part sitting in the tray and client GUI launched on demand. The server process may be hosted in interactive session or may be a Windows system service. And in the latter case you get three application executables (GUI client, tray icon agent, service) and installer package. You're going to have a lot of fun on this way.
Everything has its price. Even fighting a little flicker in task bar does. :)
Re: How to start a doc view app in hidden mode
Hi Igor, and thank you for your research.
I have tried to solve this issue by using ITaskbarList and seem to work, but this puzzle the code (I have remove the app icon from taskbar, but I have to ensure that I put this icon back, and clean up, etc.) ... is no worth it.
And second solution is more complicate, and again, is no worth it ... I guess I should live with that. Thank you again !