Solved

Display Taskbar Icon in Dialog without WS_CAPTION & WS_SYSMENU

Posted on 2001-08-26
23
704 Views
Last Modified: 2013-12-03
Hi,

In my application I have several popup dialogs with custom skins.  The skins means that the dialogs cannot have a border. However, I would still like to display icons for the dialog in their taskbar captions.  I've tried everything I can think of without success and so would be grateful if anyone can suggest a solution.

Thanks in advance,

Steve.
0
Comment
Question by:sjhl
  • 6
  • 6
  • 5
  • +3
23 Comments
 
LVL 5

Expert Comment

by:robpitt
ID: 6429427
I'm afraid the only way to get icons on the taskbar is to give the top level window the appropriate window style (WS_SYSMENU if I recall correctly).
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6429430
... in other words I don't think its possible.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6429431
Do you want each pop-up dialog to appear in the taskbar, with an icon, or are you saying that your dialog already appears in the taskbar, but without an icon, and you want to fix that?

-=- James.
0
 
LVL 1

Author Comment

by:sjhl
ID: 6429476
James,

The dialog already appears in the taskbar but without an icon. If it's any help the dialogs are created with the desktop as their parent.  If there's no other way to do it, and if it works I could create a hidden dialog with WS_CAPTION and WS_SYSMENU to use as their parent window, but I was hoping for a quicker solution.

Thanks,

Steve.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6429660
The way you mention is referenced in an MSDN article (I think, it sounds familiar).

I wanted to know if you have explicitly set a large and small icon for the dialog window?

-=- James.
0
 
LVL 1

Author Comment

by:sjhl
ID: 6429704
Yeah, I've set the large and small icons.  The ALT-TAB icon is shown, but not the caption bar icon.

Regards,

Steve.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6429756
You have just crossed out of my area of expertise.  Sorry I cannot help you further.

-=- James.
0
 
LVL 1

Author Comment

by:sjhl
ID: 6429763
Thanks anyway!
0
 

Expert Comment

by:dandycheung
ID: 6435672
WM_SETICON
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6436731
> WM_SETICON

   But the OP already said (in a response):

> > Yeah, I've set the large and small icons.  

???

-=- James.
0
 
LVL 2

Expert Comment

by:egsemsem
ID: 6436776
There must be a way to do this, I have seen a program did it before (System Mechanic).
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 4

Expert Comment

by:jtwine100697
ID: 6436824
Just a thought, but could you set yourself up with a WS_CAPTION Style, and just handle painting of the caption yourself, perhaps painting it transparent?  Kludgy, I know, but just a thought...

-=- James.
0
 
LVL 1

Author Comment

by:sjhl
ID: 6438501
Nice idea if it's the only way. Do you have any idea how to handle this?  If it's possible I imagine it's by handling WM_NCPAINT and WM_NCACTIVATE, but how do you distinguish between the Dialog Caption and the Taskbar Caption?

Thanks,

Steve.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6438619
Yer right.  I was thinking of something else entirely when I wrote that.  Sorry about that.

-=- James.
0
 

Expert Comment

by:bighead1997
ID: 6448863
Some shell function can add icon to taskbar,but when user
click it ,I don't what would happen ,I'll check that book later.
0
 

Expert Comment

by:dandycheung
ID: 6449434
0
 

Expert Comment

by:dandycheung
ID: 6449436
0
 

Accepted Solution

by:
dandycheung earned 100 total points
ID: 6449439
0
 

Expert Comment

by:dandycheung
ID: 6449444
I can not post my answer because of some EE's system error, you can send me a email and I will give a demo application to you. I have solved your problem. my mail address: dandycheung@21cn.com
0
 
LVL 2

Expert Comment

by:egsemsem
ID: 6449979
dandycheung ... we want the answer too .. please try to contact EE support team.
0
 

Expert Comment

by:dandycheung
ID: 6450334
All steps:

1. Use Visual C++ 6.0 AppWizard create a new project which type is "Win32 Application".
2. Choose "A simple Win32 Application" in step 1, click finish.
3. Insert a new dialog(IDD_DLG_TEST).
4. Open the properties dislog of this dialog, choose "Styles" tab, remove the check of "Title bar".
5. Save this dialog to file test.rc
6. Open test.rc file and add WS_SYSMENU style to the dialog manually and save it.
7. Return to VC IDE, add test.tc to your project.
8. Clear your main .cpp file and paste these code below:

#include "stdafx.h"
#include "resource.h"

INT_PTR CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
      // TODO: Place code here.

     if(DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG_TEST), NULL, (DLGPROC)DlgProc) == IDOK)
     {
     }
     else
     {
     }

     return 0;
}

INT_PTR CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
     switch(uMsg)
     {
     case WM_INITDIALOG:
          {
               HICON hIcon = (HICON)LoadImage(NULL, "doc.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
               if(hIcon)
               {
                    SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
                    SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
               }
          }
          break;
     case WM_COMMAND:
          if(wParam == IDOK)
          {
               EndDialog(hwndDlg, IDOK);
               return TRUE;
          }
          break;
     }

     return FALSE;
}

9. Build your project.
10. Remember to place a icon file named doc.ico to the folder as same as the application file standing.
11. Run your application.
0
 
LVL 1

Author Comment

by:sjhl
ID: 6451384
I have solved it with

SetWindowLong(GWL_STYLE, WS_SYSMENU);

but your solution also works, so I'm happy to give you the points and thank you for your help.

Regards,

Steve.
0
 

Expert Comment

by:bighead1997
ID: 6457062
OK,i find it ;
first u create a button window,then subclass its winproc with you own;
then get a ITaskBarList interface pointer,use AddTab function to add the button to taskbar,
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now