BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Displaying a form without parent

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Brian .
Guest





PostPosted: Thu Oct 23, 2003 1:37 pm    Post subject: Displaying a form without parent Reply with quote




hi,

i've created a custom message box for my project. then i've called
it as below:

with TMyMsgBox.Create(nil) do
begin
try
// Set some settings
ShowModal();
finally
Free();
end;
end;

that's ok. but i want to get the same result as this message box
command:

MessageBox(0, '...', '...', MB_ICONSTOP);

what i want is that TMyMsgBox should be displayed without any
parents as same as the above message box.

as you see i don't set its parent in its constructor (it is set to
nil), but it seems that its parent is already set to application!

also please note that its border style is set to bsDialog. will it
cause any changes?

how can i simulate the above MessageBox?

thanks for your replies,
Brian

Back to top
Peter Below (TeamB)
Guest





PostPosted: Thu Oct 23, 2003 7:50 pm    Post subject: Re: Displaying a form without parent Reply with quote



In article <3f97d987$1 (AT) newsgroups (DOT) borland.com>, wrote:
Quote:
i've created a custom message box for my project. then i've called
it as below:

with TMyMsgBox.Create(nil) do
begin
try
// Set some settings
ShowModal();
finally
Free();
end;
end;

that's ok. but i want to get the same result as this message box
command:

MessageBox(0, '...', '...', MB_ICONSTOP);

what i want is that TMyMsgBox should be displayed without any
parents as same as the above message box.

as you see i don't set its parent in its constructor (it is set to
nil), but it seems that its parent is already set to application!

You are confusing owner and parent. Or owner in the VCL sense with
owner in the Windows API sense, which are not the same.

What you need to do is to override the CreateParams method in your
custom dialog class.

procedure TMyMsgBox.CreateParams( var params: TCreateParams );
//override
begin
inherited;
params.WndParent := GetDesktopWindow;
end;

The VCL sets params.WndParent to Application.Handle by default.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Brian .
Guest





PostPosted: Thu Oct 23, 2003 9:20 pm    Post subject: Re: Displaying a form without parent Reply with quote




"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Quote:
What you need to do is to override the CreateParams method in
your custom dialog class.

thanks, now the problem has been solved.

but now i have two other questions:

1)
as i said in my previous post, the dialog border is set to
bsDialog. so after overriding the CreateParams method, whenever
the dialog is displayed the taskbar button contains the
application icon.
how can i get rid of this behavior either by removing the icon
or removing the taskbar button?
by changing the border style to bsToolWindow, the problem will
be solved but i want to use a dialog style border.

2)
my application is a standard project, but because i want to
simulate a service the application should not be listed in the
Applications part of the task manager. everything is ok, but
when the custom message box is displayed, the application will
be listed there and won't be removed until it is stopped.
please note that when i use MessageBox(0, ...) the above
problem won't be raised any longer, so there is no problem
related to the code that i've used for simulating a service.
what should i do to change the behavior of the custom message
box to the standard message box?

rgrds,
Brian

Back to top
Peter Below (TeamB)
Guest





PostPosted: Fri Oct 24, 2003 6:42 pm    Post subject: Re: Displaying a form without parent Reply with quote

In article <3f984630$1 (AT) newsgroups (DOT) borland.com>, wrote:
Quote:
but now i have two other questions:

1)
as i said in my previous post, the dialog border is set to
bsDialog. so after overriding the CreateParams method, whenever
the dialog is displayed the taskbar button contains the
application icon.
how can i get rid of this behavior either by removing the icon
or removing the taskbar button?
by changing the border style to bsToolWindow, the problem will
be solved but i want to use a dialog style border.

Windows shows a taskbar button if a window has the WS_EX_APPWINDOW
extended window style (which yours does not have) or if a window has no
API owner, which you wanted to have. You can try

Params.Exstyle := Params.Exstyle OR WS_EX_TOOLWINDOW;

but that probably has the same effect as setting the Borderstyle to
bsToolWindow.

If you load an icon into the forms Icon property it should display on
the taskbar button, by the way.
Quote:

2)
my application is a standard project, but because i want to
simulate a service the application should not be listed in the
Applications part of the task manager. everything is ok, but
when the custom message box is displayed, the application will
be listed there and won't be removed until it is stopped.
please note that when i use MessageBox(0, ...) the above
problem won't be raised any longer, so there is no problem
related to the code that i've used for simulating a service.
what should i do to change the behavior of the custom message
box to the standard message box?

Mh, try to do a

Params.Style := Params.Style OR WS_POPUP;

in the CreateParams method.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Brian .
Guest





PostPosted: Fri Oct 24, 2003 8:54 pm    Post subject: Re: Displaying a form without parent Reply with quote


"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Quote:
If you load an icon into the forms Icon property it should
display on the taskbar button, by the way.

thanks, but please note that this way doesn't work for bsDialog
i forced to change the border style to bsSingle.

Quote:
Mh, try to do a

Params.Style := Params.Style OR WS_POPUP;

no, it didn't work! let me tell a new aspect of my problem:

when the custom message box is displayed, it will be listed in
the task manager. so when the user clicks on endtask button,
my application will be terminated too. but i don't want this
behavior. in the other words, i want to display the custom msg
box as a separate process (i'm not sure about that, but it may
help me!) how can i do that?

rgrds,
Brian

Back to top
Peter Below (TeamB)
Guest





PostPosted: Sat Oct 25, 2003 9:41 am    Post subject: Re: Displaying a form without parent Reply with quote

In article <3f99919c$1 (AT) newsgroups (DOT) borland.com>, wrote:

Quote:
when the custom message box is displayed, it will be listed in
the task manager. so when the user clicks on endtask button,
my application will be terminated too. but i don't want this
behavior. in the other words, i want to display the custom msg
box as a separate process (i'm not sure about that, but it may
help me!) how can i do that?

Just write a little Delphi app that shows its command-line in a message
box and start it from your pseudo-service. Enclose the message you pass
as parameter in double quotes.

program ShowMessage;

uses Windows;

begin
if ParamCount > 0 then
MessageBox(
0,
Pchar(Paramstr(1)),
'Danger, Will Robinson! Danger!',
MF_OK or MF_ICONSTOP);
end.

Untested!

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Brian .
Guest





PostPosted: Sat Oct 25, 2003 11:03 am    Post subject: Re: Displaying a form without parent Reply with quote


"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Quote:
in the other words, i want to display the custom msg
box as a separate process (i'm not sure about that, but it
may help me!) how can i do that?

Just write a little Delphi app that shows its command-line in
a message box and start it from your pseudo-service. Enclose
the message you pass as parameter in double quotes.

thanks, but i want to use a single executable file. is it
possible to show the dialog as a separate process without the
use of any external files? (APIs such as CreateProcess may be
usefule here, but i've not used them yet)

rgrds,
Brian

Back to top
Peter Below (TeamB)
Guest





PostPosted: Sat Oct 25, 2003 3:50 pm    Post subject: Re: Displaying a form without parent Reply with quote

In article <3f9a5866$1 (AT) newsgroups (DOT) borland.com>, wrote:
Quote:
thanks, but i want to use a single executable file.

At some point you have to make a decision: do you want to get this to
work or not? <g>.


Quote:
is it
possible to show the dialog as a separate process without the
use of any external files?

This is a contradiction in terms. A separate process *is* a separate
executable, or a second instance of your first executable.


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Brian .
Guest





PostPosted: Mon Oct 27, 2003 1:21 pm    Post subject: Re: Displaying a form without parent Reply with quote

"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Quote:
thanks, but i want to use a single executable file.
At some point you have to make a decision: do you want to get
this to work or not? <g>.

do you mean that i should add something about 300K to my
project? <g>

please don't loose the main point of my question. i really need
the custom message box to work only in a single executable file
not anything else. perhaps a new process is not what i need, so
what should i do?

thanks,
Brian

Back to top
Peter Below (TeamB)
Guest





PostPosted: Mon Oct 27, 2003 6:45 pm    Post subject: Re: Displaying a form without parent Reply with quote

In article <3f9d29d8$1 (AT) newsgroups (DOT) borland.com>, wrote:
Quote:
"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
thanks, but i want to use a single executable file.
At some point you have to make a decision: do you want to get
this to work or not? <g>.

do you mean that i should add something about 300K to my
project? <g

Who is talking about 300K? The little applet i gave you will compile to
less than 30KB of code. If you do not use forms and other VCL stuff
Delphi can create quite tiny apps.

Quote:
please don't loose the main point of my question. i really need
the custom message box to work only in a single executable file
not anything else. perhaps a new process is not what i need, so
what should i do?

I don't know, you are fighting Windows here and in that situation my
bet is on Windows, sorry everything you want to have without using a second process as
auxillary.


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Brian .
Guest





PostPosted: Tue Oct 28, 2003 6:11 am    Post subject: Re: Displaying a form without parent Reply with quote

"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Quote:
do you mean that i should add something about 300K to my
project? <g
Who is talking about 300K? The little applet i gave you will
compile to less than 30KB of code. If you do not use forms
and other VCL stuff Delphi can create quite tiny apps.

as you remember, i wrote in my first post that i want to
display a custom message box and i asked you about its border
style. so i'ved used a form and some other standard components
such as image, label and button. we all know that including
forms to the uses clause of an app adds something about 300K
to the exe file.

if i was able to create an executable file that is less than
50K, as you said, then i had no problem with a new executable
file. but in the current situation, using a new project just
for displaying a custom dialog is not the best way. plz note that i don't like to use KOL to create smaller files,
because in that case, some parts of the dialog won't have the
system default appearance. also using APIs to do so, is really
cumbersome and annoying. is there any other ways?!

thanks,
Brian

Back to top
Peter Below (TeamB)
Guest





PostPosted: Tue Oct 28, 2003 8:13 pm    Post subject: Re: Displaying a form without parent Reply with quote

In article <3f9e16a5$1 (AT) newsgroups (DOT) borland.com>, wrote:
Quote:
as you remember,

Newsgroup messages only go into short term memory and are then deleted,
so in fact i didn't remember <g>.

Quote:
is there any other ways?!

I don't think so.


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.