[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 760
  • Last Modified:

Display Taskbar Icon in Dialog without WS_CAPTION & WS_SYSMENU

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
sjhl
Asked:
sjhl
  • 6
  • 6
  • 5
  • +3
1 Solution
 
robpittCommented:
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
 
robpittCommented:
... in other words I don't think its possible.
0
 
jtwine100697Commented:
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
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
sjhlAuthor Commented:
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
 
jtwine100697Commented:
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
 
sjhlAuthor Commented:
Yeah, I've set the large and small icons.  The ALT-TAB icon is shown, but not the caption bar icon.

Regards,

Steve.
0
 
jtwine100697Commented:
You have just crossed out of my area of expertise.  Sorry I cannot help you further.

-=- James.
0
 
sjhlAuthor Commented:
Thanks anyway!
0
 
dandycheungCommented:
WM_SETICON
0
 
jtwine100697Commented:
> WM_SETICON

   But the OP already said (in a response):

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

???

-=- James.
0
 
egsemsemCommented:
There must be a way to do this, I have seen a program did it before (System Mechanic).
0
 
jtwine100697Commented:
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
 
sjhlAuthor Commented:
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
 
jtwine100697Commented:
Yer right.  I was thinking of something else entirely when I wrote that.  Sorry about that.

-=- James.
0
 
bighead1997Commented:
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
 
dandycheungCommented:
0
 
dandycheungCommented:
0
 
dandycheungCommented:
0
 
dandycheungCommented:
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
 
egsemsemCommented:
dandycheung ... we want the answer too .. please try to contact EE support team.
0
 
dandycheungCommented:
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
 
sjhlAuthor Commented:
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
 
bighead1997Commented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 6
  • 5
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now