[C++ Builder] Hide application from activities list

  • Follow


Hello,

I'm italian, sorry for my bad english :D

I'm using C++ builder 6 on Windows 7 64bit

I want that my application don't appears in activities list (that you can 
view with ALT+TAB)

I can't use bsToolWindow property beacause it must be bsNone.

I tried also:
Form1->BorderStyle = bsNone & bsToolWindow
and
Form1->BorderStyle = bsNone | bsToolWindow

But don't work.

Is there a way to do this?

Searching with google, I found this link: 
http://www.delphicorner.f9.co.uk/articles/apps3.htm

That show a solution for Delphi.

var
  ExtendedStyle : Integer;

begin
  Application.Initialize;

  //Get the Extended Styles of the Application, by passing its
  //handle to GetWindowLong
  ExtendedStyle := GetWindowLong(Application.Handle, GWL_EXSTYLE);

  //Now, set the Extended Style by doing a bit masking operation.
  //OR in the WS_EX_TOOLWINDOW bit, and AND out the WS_EXAPPWINDOW bit
  //This effectively converts the application from an App Windows to a
  //Tool Window.
  SetWindowLong(Application.Handle, GWL_EXSTYLE, ExtendedStyle OR
WS_EX_TOOLWINDOW
                                                 AND NOT WS_EX_APPWINDOW);
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.


I have adapted it for C++ builder in this way:

Between Application->Initialize() and 
Application->CreateForm(__classid(TForm1), &Form1):

int ExtendedStyle = GetWindowLong(Application->Handle, GWL_EXSTYLE);
SetWindowLong(Application->Handle, GWL_EXSTYLE, ExtendedStyle | 
WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);

But don't work!

Can you help me?

Thanks 
0
Reply Noixe 1/14/2010 9:38:53 AM

On 14 jan, 10:38, "Noixe" <no...@TOGLIMIemail.it> wrote:

> int ExtendedStyle = GetWindowLong(Application->Handle, GWL_EXSTYLE);
> SetWindowLong(Application->Handle, GWL_EXSTYLE, ExtendedStyle |
> WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);
> But don't work!

What doesn't work ?
If I do :

int ExtendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, ExtendedStyle | WS_EX_TOOLWINDOW &
~WS_EX_APPWINDOW);
SetWindowPos(hWnd, 0, 0, 0, 0, 0,  SWP_FRAMECHANGED | SWP_NOSIZE |
SWP_NOMOVE | SWP_NOZORDER);

it works.
(Owned windows also don't appear on Alt-Tab...)
0
Reply Christian 1/14/2010 6:02:36 PM


"Christian ASTOR" <castorix@club-internet.fr> ha scritto:

> What doesn't work ?
> If I do :
>
> int ExtendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
> SetWindowLong(hWnd, GWL_EXSTYLE, ExtendedStyle | WS_EX_TOOLWINDOW &
> ~WS_EX_APPWINDOW);
> SetWindowPos(hWnd, 0, 0, 0, 0, 0,  SWP_FRAMECHANGED | SWP_NOSIZE |
> SWP_NOMOVE | SWP_NOZORDER);
>
> it works.
> (Owned windows also don't appear on Alt-Tab...)

I use Application->Handle, not hWnd. However this code don't work:

int ExtendedStyle = GetWindowLong(Application->Handle, GWL_EXSTYLE);
SetWindowLong(Application->Handle, GWL_EXSTYLE, ExtendedStyle | 
WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);
SetWindowPos(Application->Handle, 0, 0, 0, 0, 0,  SWP_FRAMECHANGED | 
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);

I see application in alt+tab list

Have you used C++ builder 6?
My operating system is windows 7 64bit 

0
Reply Noixe 1/14/2010 8:11:21 PM

Hi!

Am Thu, 14 Jan 2010 21:11:21 +0100 schrieb Noixe:

> "Christian ASTOR" <castorix@club-internet.fr> ha scritto:
> 
>> What doesn't work ?
>> If I do :
>>
>> int ExtendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
>> SetWindowLong(hWnd, GWL_EXSTYLE, ExtendedStyle | WS_EX_TOOLWINDOW &
>> ~WS_EX_APPWINDOW);
>> SetWindowPos(hWnd, 0, 0, 0, 0, 0,  SWP_FRAMECHANGED | SWP_NOSIZE |
>> SWP_NOMOVE | SWP_NOZORDER);
>>
>> it works.
>> (Owned windows also don't appear on Alt-Tab...)
> 
> I use Application->Handle, not hWnd. However this code don't work:

> int ExtendedStyle = GetWindowLong(Application->Handle, GWL_EXSTYLE);
> SetWindowLong(Application->Handle, GWL_EXSTYLE, ExtendedStyle | 
> WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);
> SetWindowPos(Application->Handle, 0, 0, 0, 0, 0,  SWP_FRAMECHANGED | 
> SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
> 
> I see application in alt+tab list
> 
> Have you used C++ builder 6?

It is important to use the handle of the main *window*.
In a C++ Builder main form TAppForm method you can use simply Handle.
E.g.:
__fastcall TSDIAppForm::TSDIAppForm(TComponent *AOwner)
	: TForm(AOwner)
{

 int ExtendedStyle = GetWindowLong(Handle, GWL_EXSTYLE);
 SetWindowLong(Handle, GWL_EXSTYLE, ExtendedStyle | 
 WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);
 SetWindowPos(Handle, 0, 0, 0, 0, 0,  SWP_FRAMECHANGED | 
 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);

}

Note that the style of a window is not like a C++ Builder property;
changing it is without effect, until the window is updated in some way.
Therefore Christian added SetWindowPos to the code.

hth,
 Friedel
0
Reply Friedel 1/15/2010 6:53:24 AM

"Friedel Jantzen" <nospam_plz@freenet.de> ha scritto:
 
> It is important to use the handle of the main *window*.
> In a C++ Builder main form TAppForm method you can use simply Handle.
> E.g.:
> __fastcall TSDIAppForm::TSDIAppForm(TComponent *AOwner)
> : TForm(AOwner)
> {
> 
> int ExtendedStyle = GetWindowLong(Handle, GWL_EXSTYLE);
> SetWindowLong(Handle, GWL_EXSTYLE, ExtendedStyle | 
> WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);
> SetWindowPos(Handle, 0, 0, 0, 0, 0,  SWP_FRAMECHANGED | 
> SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
> 
> }
> 
> Note that the style of a window is not like a C++ Builder property;
> changing it is without effect, until the window is updated in some way.
> Therefore Christian added SetWindowPos to the code.

I can't find SDIAppForm Event.
Where is it? 
0
Reply Noixe 1/15/2010 9:54:17 AM

I inserted this two type of code in OnFormCreate event:

1.
SetWindowLong((Application->Handle, GWL_EXSTYLE,
                GetWindowLong(Application->Handle, GWL_EXSTYLE) | 
WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);

2. (the difference is only the first parameter of SetWindowLong
SetWindowLong((Form1->Handle, GWL_EXSTYLE,
                GetWindowLong(Application->Handle, GWL_EXSTYLE) | 
WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);


In the first case, the program appears in ALT+TAB list but don't appears in 
taskbar.
In the second case, the program's icon  appears in taskbar but don't appears 
in ALT+TAB list

I want both result, it must disappears from ALT+TAB list and taskbar.

Note that the first parameter of GetWindowLong can be Application->Handle or 
Form1->Handle, the result is the same. 

0
Reply Noixe 1/15/2010 10:37:55 AM

"Noixe" <noixe@TOGLIMIemail.it> ha scritto nel messaggio 
news:4b504583$0$1111$4fafbaef@reader4.news.tin.it...

> I inserted this two type of code in OnFormCreate event:

Using both type of code seems work!

Thanks 

0
Reply Noixe 1/15/2010 11:28:45 AM

Hi!

Am Fri, 15 Jan 2010 12:28:45 +0100 schrieb Noixe:

> "Noixe" <noixe@TOGLIMIemail.it> ha scritto nel messaggio 
> news:4b504583$0$1111$4fafbaef@reader4.news.tin.it...
> 
>> I inserted this two type of code in OnFormCreate event:
> 
> Using both type of code seems work!
> 
> Thanks

It often is a mess to do something extra when using a RAD system like BCB.
I even had problems with German Umlaute (���...) in menus.
There are special newsgroups for BCB: borland.public.bccbuilder.*
Perhaps there is someone who knows a better way to do it.

Regards,
 Friedel
0
Reply Friedel 1/15/2010 2:21:38 PM

"Friedel Jantzen" <nospam_plz@freenet.de> ha scritto:

> It often is a mess to do something extra when using a RAD system like BCB.
> I even had problems with German Umlaute (���...) in menus.
> There are special newsgroups for BCB: borland.public.bccbuilder.*
> Perhaps there is someone who knows a better way to do it.

In those newsgroup I haven't found nobody 

0
Reply Noixe 1/15/2010 3:57:10 PM

8 Replies
519 Views

(page loaded in 0.035 seconds)

Similiar Articles:













7/22/2012 2:03:11 AM


Reply: