diff options
-rw-r--r-- | win/tkWinWm.c | 30 | ||||
-rw-r--r-- | win/winMain.c | 6 |
2 files changed, 19 insertions, 17 deletions
diff --git a/win/tkWinWm.c b/win/tkWinWm.c index c92d488..4008836 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -3858,17 +3858,13 @@ WmIconbadgeCmd( char photoname[4096]; LPCWSTR string; ITaskbarList3 *ptbl; - UINT TaskbarButtonCreatedMessageId; - /* Establish a COM interface to the ITaskBarList3 API. */ - hr = CoInitialize(0); - TaskbarButtonCreatedMessageId = RegisterWindowMessage("TaskbarButtonCreated"); + hr = CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, &ptbl); if (hr == S_OK) { - CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, &ptbl); - ptbl->lpVtbl->HrInit(ptbl); + ptbl->lpVtbl->HrInit(ptbl); } else { - Tcl_SetResult(interp, "Unable to initialize taskbar icon", TCL_VOLATILE); - return TCL_ERROR; + Tcl_SetResult(interp, "Unable to initialize taskbar icon", TCL_VOLATILE); + return TCL_ERROR; } if (objc < 4) { @@ -3876,24 +3872,24 @@ WmIconbadgeCmd( return TCL_ERROR; } - hwnd = Tk_GetHWND(winPtr -> window); + hwnd = Tk_GetHWND(winPtr->window); badgestring = Tcl_GetString(objv[3]); string = L"Alert"; badgenumber = atoi(badgestring); if (badgenumber > 9) { - strcpy(photoname, "::tk::icons::9plus-badge"); + strcpy(photoname, "::tk::icons::9plus-badge"); } else { - strcpy(photoname , "::tk::icons::"); - strcat(photoname, badgestring); - strcat(photoname, "-badge"); + strcpy(photoname, "::tk::icons::"); + strcat(photoname, badgestring); + strcat(photoname, "-badge"); } /* Get image. If NULL, remove badge icon. */ photo = Tk_FindPhoto(interp, photoname); if (photo == NULL) { - ptbl->lpVtbl->SetOverlayIcon(ptbl, hwnd, NULL, NULL); - return TCL_OK; + ptbl->lpVtbl->SetOverlayIcon(ptbl, hwnd, NULL, NULL); + return TCL_OK; } /* We have found the image. Convert to icon. */ @@ -3902,8 +3898,8 @@ WmIconbadgeCmd( overlayicon = CreateIcoFromPhoto(width, height, block); if (overlayicon == NULL) { - Tcl_SetResult(interp, "Failed to create icon photo", TCL_VOLATILE); - return TCL_ERROR; + Tcl_SetResult(interp, "Failed to create icon photo", TCL_VOLATILE); + return TCL_ERROR; } /* Place overlay icon on taskbar icon. */ diff --git a/win/winMain.c b/win/winMain.c index 9c23037..0231200 100644 --- a/win/winMain.c +++ b/win/winMain.c @@ -134,6 +134,10 @@ _tWinMain( (void)lpszCmdLine; (void)nCmdShow; + + /* Load COM library for icon overlay. */ + CoInitialize(NULL); + /* * Create the console channels and install them as the standard channels. * All I/O will be discarded until Tk_CreateConsoleWindow is called to @@ -178,6 +182,8 @@ _tWinMain( #endif Tk_Main(argc, argv, TK_LOCAL_APPINIT); + /* COM library cleanup. */ + CoUninitialize(); return 0; /* Needed only to prevent compiler warning. */ } |