472,780 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

Help or comments appreciated.

<Previously posted in microsoft.public.dotnet.framework.windowsforms>

Hi all. Any suggestions here would be appreciated. Thanks for reading.

I'm primarly a C++ developer but I've been trying to complete development on
a C# application with the following basic requirements:
- The app runs in the background is initially hidden from the user,
including the Windows Taskbar.
- The app needs to receive a registered Windows message
- The app needs to "register" its window handle with an unmanaged C++ dll so
that a WM_USER message can be sent back to the C# app's WndProc
- The app needs to display itself when receiving the WM_USER message, and
hide itself after being acted upon by the user.

I ran into some problems along the way and wondered if anyone could provide
some feedback or comments. Especially since I told my project guy this
should be trivial to do in C# (vs C++), and now I'm wondering if I made the
correct decision. I'm not looking good at this point.

1) In order to hide the app from the Taskbar, the main form's ShowInTaskbar
property would be set to "false", easy right? That action, however, (using
SPY++) removes the WS_EX_APPLICATION style bit and prevents the
application from receiving any registered Windows messages.

2) I initially call a C#-to-C++ wrapper function to give my ".Handle" to the
unmanaged dll. This works for the first time, but when I set the main form's
Visible property to false and minimize the form, "Handle" gets a new value.
Is there some other "handle" I should be using? I work around this by
"re-registering" with the unmanaged dll after minimizing but there have been
a couple of occasions where a zero has been logged. Using FindWindow() in
the unmanaged dll would be acceptable, is there a way to "register a unique
window class"? The window titlebar includes message specific data so the
title changes.

3) I have seen several instances where the main window was shown (Visible =
true), but with no controls on it. Using SPY++, I see the main window listed
with no child controls, and a "WindowsFormsParkingWindow" which contains all
the children for this form. The data on the controls is correct, but it's as
if they are just not on the right form.

4) I also intended for a Windows Service to start the application, which
works, but the application does not survive a user logoff. We have C++/MFC
applications which do a subclassing code trick to accomplish this but I've
not found an equivalent for C# apps.
http://support.microsoft.com/kb/q164166/

5) I have the main form's TopMost property set to true, and after 2 hrs. of
messing around, I discovered the tooltips are showing behind the form. This
is the case for XP as well as Win2k. This is not specific to my machine.

One unrelated thing:
1) Once in a while my VS.NET search function starts reporting something like
"no files found to search in". Strangely enough, when I press CTRL+SCROLL
LOCK it starts working again. Not a big deal once you know the trick.

I apologize if I've missed this information but I looked in the groups and
didn't see any real answers to these questions. I would greatly appreciate
any input as to whether some of this behavior falls in the category of
"that's just the way it is", or I'm not doing things correctly, or bugs to
be fixed, or need to look at workarounds. I'm using VS.NET 2003 and .NET
Framework v1.1 and the target OS is Win2k. Needless to say, I've been
frustrated to this point in creating what I "thought" to be a pretty simple
app. My fear (from a schedule standpoint) is that I have to start over in
C++. Thanks in advance for any comments or insults :- ).
- Brad Jones (not CodeGuru guy!)


Jul 21 '05 #1
4 1848
It appears that setting the ShowInTaskbar property during runtime causes the
window handle of the form to change. There may be other side effects.
"Brad Jones" <br**@uicnospam.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
<Previously posted in microsoft.public.dotnet.framework.windowsforms>

Hi all. Any suggestions here would be appreciated. Thanks for reading.

I'm primarly a C++ developer but I've been trying to complete development
on
a C# application with the following basic requirements:
- The app runs in the background is initially hidden from the user,
including the Windows Taskbar.
- The app needs to receive a registered Windows message
- The app needs to "register" its window handle with an unmanaged C++ dll
so
that a WM_USER message can be sent back to the C# app's WndProc
- The app needs to display itself when receiving the WM_USER message, and
hide itself after being acted upon by the user.

I ran into some problems along the way and wondered if anyone could
provide
some feedback or comments. Especially since I told my project guy this
should be trivial to do in C# (vs C++), and now I'm wondering if I made
the
correct decision. I'm not looking good at this point.

1) In order to hide the app from the Taskbar, the main form's
ShowInTaskbar
property would be set to "false", easy right? That action, however, (using
SPY++) removes the WS_EX_APPLICATION style bit and prevents the
application from receiving any registered Windows messages.

2) I initially call a C#-to-C++ wrapper function to give my ".Handle" to
the
unmanaged dll. This works for the first time, but when I set the main
form's
Visible property to false and minimize the form, "Handle" gets a new
value.
Is there some other "handle" I should be using? I work around this by
"re-registering" with the unmanaged dll after minimizing but there have
been
a couple of occasions where a zero has been logged. Using FindWindow() in
the unmanaged dll would be acceptable, is there a way to "register a
unique
window class"? The window titlebar includes message specific data so the
title changes.

3) I have seen several instances where the main window was shown (Visible
=
true), but with no controls on it. Using SPY++, I see the main window
listed
with no child controls, and a "WindowsFormsParkingWindow" which contains
all
the children for this form. The data on the controls is correct, but it's
as
if they are just not on the right form.

4) I also intended for a Windows Service to start the application, which
works, but the application does not survive a user logoff. We have C++/MFC
applications which do a subclassing code trick to accomplish this but I've
not found an equivalent for C# apps.
http://support.microsoft.com/kb/q164166/

5) I have the main form's TopMost property set to true, and after 2 hrs.
of
messing around, I discovered the tooltips are showing behind the form.
This
is the case for XP as well as Win2k. This is not specific to my machine.

One unrelated thing:
1) Once in a while my VS.NET search function starts reporting something
like
"no files found to search in". Strangely enough, when I press CTRL+SCROLL
LOCK it starts working again. Not a big deal once you know the trick.

I apologize if I've missed this information but I looked in the groups and
didn't see any real answers to these questions. I would greatly appreciate
any input as to whether some of this behavior falls in the category of
"that's just the way it is", or I'm not doing things correctly, or bugs to
be fixed, or need to look at workarounds. I'm using VS.NET 2003 and .NET
Framework v1.1 and the target OS is Win2k. Needless to say, I've been
frustrated to this point in creating what I "thought" to be a pretty
simple
app. My fear (from a schedule standpoint) is that I have to start over in
C++. Thanks in advance for any comments or insults :- ).
- Brad Jones (not CodeGuru guy!)

Jul 21 '05 #2
It appears that setting the ShowInTaskbar property during runtime causes the
window handle of the form to change. There may be other side effects.

"Brad Jones" <br**@uicnospam.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
<Previously posted in microsoft.public.dotnet.framework.windowsforms>

Hi all. Any suggestions here would be appreciated. Thanks for reading.

I'm primarly a C++ developer but I've been trying to complete development
on
a C# application with the following basic requirements:
- The app runs in the background is initially hidden from the user,
including the Windows Taskbar.
- The app needs to receive a registered Windows message
- The app needs to "register" its window handle with an unmanaged C++ dll
so
that a WM_USER message can be sent back to the C# app's WndProc
- The app needs to display itself when receiving the WM_USER message, and
hide itself after being acted upon by the user.

I ran into some problems along the way and wondered if anyone could
provide
some feedback or comments. Especially since I told my project guy this
should be trivial to do in C# (vs C++), and now I'm wondering if I made
the
correct decision. I'm not looking good at this point.

1) In order to hide the app from the Taskbar, the main form's
ShowInTaskbar
property would be set to "false", easy right? That action, however, (using
SPY++) removes the WS_EX_APPLICATION style bit and prevents the
application from receiving any registered Windows messages.

2) I initially call a C#-to-C++ wrapper function to give my ".Handle" to
the
unmanaged dll. This works for the first time, but when I set the main
form's
Visible property to false and minimize the form, "Handle" gets a new
value.
Is there some other "handle" I should be using? I work around this by
"re-registering" with the unmanaged dll after minimizing but there have
been
a couple of occasions where a zero has been logged. Using FindWindow() in
the unmanaged dll would be acceptable, is there a way to "register a
unique
window class"? The window titlebar includes message specific data so the
title changes.

3) I have seen several instances where the main window was shown (Visible
=
true), but with no controls on it. Using SPY++, I see the main window
listed
with no child controls, and a "WindowsFormsParkingWindow" which contains
all
the children for this form. The data on the controls is correct, but it's
as
if they are just not on the right form.

4) I also intended for a Windows Service to start the application, which
works, but the application does not survive a user logoff. We have C++/MFC
applications which do a subclassing code trick to accomplish this but I've
not found an equivalent for C# apps.
http://support.microsoft.com/kb/q164166/

5) I have the main form's TopMost property set to true, and after 2 hrs.
of
messing around, I discovered the tooltips are showing behind the form.
This
is the case for XP as well as Win2k. This is not specific to my machine.

One unrelated thing:
1) Once in a while my VS.NET search function starts reporting something
like
"no files found to search in". Strangely enough, when I press CTRL+SCROLL
LOCK it starts working again. Not a big deal once you know the trick.

I apologize if I've missed this information but I looked in the groups and
didn't see any real answers to these questions. I would greatly appreciate
any input as to whether some of this behavior falls in the category of
"that's just the way it is", or I'm not doing things correctly, or bugs to
be fixed, or need to look at workarounds. I'm using VS.NET 2003 and .NET
Framework v1.1 and the target OS is Win2k. Needless to say, I've been
frustrated to this point in creating what I "thought" to be a pretty
simple
app. My fear (from a schedule standpoint) is that I have to start over in
C++. Thanks in advance for any comments or insults :- ).
- Brad Jones (not CodeGuru guy!)

Jul 21 '05 #3
Brad,
I remember from my VB6 days that you could not set the .ShowInTaskbar
property on a form at runtime. This had to do with style bits being set at
the creation of the window. .NET gets around this limitation by destroying
and re-creating your window when the .ShowInTaskbar property changes.
That's why your window handle changes.

I see two options.
1) Re-register with the DLL each time the window handle changes. (You might
need to create a fast-firing timer to monitor the property to ensure the
correct value at all times).

2) Create a new window class from NativeWindow.

Either option seems to hold peril. I hope you get it.

-dw

"Brad Jones" <br**@uicnospam.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
<Previously posted in microsoft.public.dotnet.framework.windowsforms>

Hi all. Any suggestions here would be appreciated. Thanks for reading.

I'm primarly a C++ developer but I've been trying to complete development
on
a C# application with the following basic requirements:
- The app runs in the background is initially hidden from the user,
including the Windows Taskbar.
- The app needs to receive a registered Windows message
- The app needs to "register" its window handle with an unmanaged C++ dll
so
that a WM_USER message can be sent back to the C# app's WndProc
- The app needs to display itself when receiving the WM_USER message, and
hide itself after being acted upon by the user.

I ran into some problems along the way and wondered if anyone could
provide
some feedback or comments. Especially since I told my project guy this
should be trivial to do in C# (vs C++), and now I'm wondering if I made
the
correct decision. I'm not looking good at this point.

1) In order to hide the app from the Taskbar, the main form's
ShowInTaskbar
property would be set to "false", easy right? That action, however, (using
SPY++) removes the WS_EX_APPLICATION style bit and prevents the
application from receiving any registered Windows messages.

2) I initially call a C#-to-C++ wrapper function to give my ".Handle" to
the
unmanaged dll. This works for the first time, but when I set the main
form's
Visible property to false and minimize the form, "Handle" gets a new
value.
Is there some other "handle" I should be using? I work around this by
"re-registering" with the unmanaged dll after minimizing but there have
been
a couple of occasions where a zero has been logged. Using FindWindow() in
the unmanaged dll would be acceptable, is there a way to "register a
unique
window class"? The window titlebar includes message specific data so the
title changes.

3) I have seen several instances where the main window was shown (Visible
=
true), but with no controls on it. Using SPY++, I see the main window
listed
with no child controls, and a "WindowsFormsParkingWindow" which contains
all
the children for this form. The data on the controls is correct, but it's
as
if they are just not on the right form.

4) I also intended for a Windows Service to start the application, which
works, but the application does not survive a user logoff. We have C++/MFC
applications which do a subclassing code trick to accomplish this but I've
not found an equivalent for C# apps.
http://support.microsoft.com/kb/q164166/

5) I have the main form's TopMost property set to true, and after 2 hrs.
of
messing around, I discovered the tooltips are showing behind the form.
This
is the case for XP as well as Win2k. This is not specific to my machine.

One unrelated thing:
1) Once in a while my VS.NET search function starts reporting something
like
"no files found to search in". Strangely enough, when I press CTRL+SCROLL
LOCK it starts working again. Not a big deal once you know the trick.

I apologize if I've missed this information but I looked in the groups and
didn't see any real answers to these questions. I would greatly appreciate
any input as to whether some of this behavior falls in the category of
"that's just the way it is", or I'm not doing things correctly, or bugs to
be fixed, or need to look at workarounds. I'm using VS.NET 2003 and .NET
Framework v1.1 and the target OS is Win2k. Needless to say, I've been
frustrated to this point in creating what I "thought" to be a pretty
simple
app. My fear (from a schedule standpoint) is that I have to start over in
C++. Thanks in advance for any comments or insults :- ).
- Brad Jones (not CodeGuru guy!)

Jul 21 '05 #4
Thanks for the reply Dan,
I agree, the options you mention are bound to give me problems. I've
done a fair share of VB myself but I guess I've never stumbled onto
that particular limitation. I have a sneaking suspicion that setting this
property at runtime is also at the root of the WindowsFormsParking thing.
My guess is it's kind of like when I was growing up and my parents would
threaten to send me to the babysitter and move away while I was gone : )

Here's what I ended up doing that seems to give me the desired behavior.
- Set the form (in the designer!) to defaults.
- ShowInTaskbar = true (so I can get the registered message)
- TopMost = false
- In the "Load" event, call SetTopLevel(false), the keeps the form
hidden until the processes I depend on are done initializing and
send me the registered message telling me that.
- Then I register my .Handle with the unmanaged dll and wait for the
WM_USER message I need to respond to.
- When I get that, I call SetTopLevel(true), this brings the window to
the
top and shows it in the taskbar, which is what is desired so it can
be
minimized if needed.
- After the user is done, SetTopLevel(false) is called and all seems
well.

An added benefit is that my tooltips are no longer popping up behind the
form (yaaaay!).
"[eterra] Dan" <dw*****@myeterra.com> wrote in message
news:uZ**************@TK2MSFTNGP15.phx.gbl...
Brad,
I remember from my VB6 days that you could not set the .ShowInTaskbar
property on a form at runtime. This had to do with style bits being set
at
the creation of the window. .NET gets around this limitation by
destroying
and re-creating your window when the .ShowInTaskbar property changes.
That's why your window handle changes.

I see two options.
1) Re-register with the DLL each time the window handle changes. (You
might
need to create a fast-firing timer to monitor the property to ensure the
correct value at all times).

2) Create a new window class from NativeWindow.

Either option seems to hold peril. I hope you get it.

-dw

"Brad Jones" <br**@uicnospam.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
<Previously posted in microsoft.public.dotnet.framework.windowsforms>

Hi all. Any suggestions here would be appreciated. Thanks for reading.

I'm primarly a C++ developer but I've been trying to complete development
on
a C# application with the following basic requirements:
- The app runs in the background is initially hidden from the user,
including the Windows Taskbar.
- The app needs to receive a registered Windows message
- The app needs to "register" its window handle with an unmanaged C++ dll
so
that a WM_USER message can be sent back to the C# app's WndProc
- The app needs to display itself when receiving the WM_USER message, and
hide itself after being acted upon by the user.

I ran into some problems along the way and wondered if anyone could
provide
some feedback or comments. Especially since I told my project guy this
should be trivial to do in C# (vs C++), and now I'm wondering if I made
the
correct decision. I'm not looking good at this point.

1) In order to hide the app from the Taskbar, the main form's
ShowInTaskbar
property would be set to "false", easy right? That action, however,
(using
SPY++) removes the WS_EX_APPLICATION style bit and prevents the
application from receiving any registered Windows messages.

2) I initially call a C#-to-C++ wrapper function to give my ".Handle" to
the
unmanaged dll. This works for the first time, but when I set the main
form's
Visible property to false and minimize the form, "Handle" gets a new
value.
Is there some other "handle" I should be using? I work around this by
"re-registering" with the unmanaged dll after minimizing but there have
been
a couple of occasions where a zero has been logged. Using FindWindow() in
the unmanaged dll would be acceptable, is there a way to "register a
unique
window class"? The window titlebar includes message specific data so the
title changes.

3) I have seen several instances where the main window was shown (Visible
=
true), but with no controls on it. Using SPY++, I see the main window
listed
with no child controls, and a "WindowsFormsParkingWindow" which contains
all
the children for this form. The data on the controls is correct, but it's
as
if they are just not on the right form.

4) I also intended for a Windows Service to start the application, which
works, but the application does not survive a user logoff. We have
C++/MFC
applications which do a subclassing code trick to accomplish this but
I've
not found an equivalent for C# apps.
http://support.microsoft.com/kb/q164166/

5) I have the main form's TopMost property set to true, and after 2 hrs.
of
messing around, I discovered the tooltips are showing behind the form.
This
is the case for XP as well as Win2k. This is not specific to my machine.

One unrelated thing:
1) Once in a while my VS.NET search function starts reporting something
like
"no files found to search in". Strangely enough, when I press CTRL+SCROLL
LOCK it starts working again. Not a big deal once you know the trick.

I apologize if I've missed this information but I looked in the groups
and
didn't see any real answers to these questions. I would greatly
appreciate
any input as to whether some of this behavior falls in the category of
"that's just the way it is", or I'm not doing things correctly, or bugs
to
be fixed, or need to look at workarounds. I'm using VS.NET 2003 and .NET
Framework v1.1 and the target OS is Win2k. Needless to say, I've been
frustrated to this point in creating what I "thought" to be a pretty
simple
app. My fear (from a schedule standpoint) is that I have to start over in
C++. Thanks in advance for any comments or insults :- ).
- Brad Jones (not CodeGuru guy!)


Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: windandwaves | last post by:
Hi Folks I have just completed a project for an accommodation finder in New Zealand - much with your help - thank you again. I would appreciate any constructive or deconstructive comments. ...
9
by: hope | last post by:
Hi Access 97 I'm lost on this code please can you help ================================= Below is some simple code that will concatenate a single field's value from multiple records into a...
4
by: Ron | last post by:
Hi All I've got 2 files, transactions and comments, linked by a clientID as a FK in the clients file and as a FK in the comments file (PK in the 'client' file of course). The comments don't...
39
by: Timex | last post by:
I want to delete all comments in .c file. Size of .c file is very big. Any good idea to do this? Please show me example code.
4
by: Brad Jones | last post by:
<Previously posted in microsoft.public.dotnet.framework.windowsforms> Hi all. Any suggestions here would be appreciated. Thanks for reading. I'm primarly a C++ developer but I've been trying to...
8
by: freemann | last post by:
Wow, this has been some trip. I'm learning some asp scripting to apply toward some online forms and they are working really good. However I do have this one problem that I can't seem to get to...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
by: thanawala27 | last post by:
Hi, I needed some help here. I have variable which has the following data var = "User:abc, <br>Date:06/15/07,<br>Comments: EVERYTHING IS FINE" i tried to put the value of 'var' in a text area...
1
by: atiq | last post by:
I want the thank page to be displayed for about second after the user has submit the form and then to go to another URL say, http://www.google.com. Below is the code: <?php // $mailto - set to...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.