static VOID NcAreaInitializeImageList( _Inout_ PEDIT_CONTEXT Context ) { HBITMAP bitmapActive = NULL; HBITMAP bitmapInactive = NULL; Context->ImageWidth = 23; Context->ImageHeight = 20; Context->ImageList = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0); ImageList_SetBkColor(Context->ImageList, Context->BackgroundColorRef); ImageList_SetImageCount(Context->ImageList, 2); // Add the images to the imagelist if (bitmapActive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE))) { ImageList_Replace(Context->ImageList, 0, bitmapActive, NULL); DeleteObject(bitmapActive); } else { PhSetImageListBitmap(Context->ImageList, 0, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE_BMP)); } if (bitmapInactive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE))) { ImageList_Replace(Context->ImageList, 1, bitmapInactive, NULL); DeleteObject(bitmapInactive); } else { PhSetImageListBitmap(Context->ImageList, 1, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE_BMP)); } }
VOID NcAreaInitializeImageList( _Inout_ PEDIT_CONTEXT Context ) { HBITMAP bitmapActive = NULL; HBITMAP bitmapInactive = NULL; Context->ImageWidth = GetSystemMetrics(SM_CXSMICON) + 4; Context->ImageHeight = GetSystemMetrics(SM_CYSMICON) + 4; Context->ImageList = ImageList_Create(32, 32, ILC_COLOR32, 2, 2); ImageList_SetImageCount(Context->ImageList, 2); // Add the images to the imagelist if (bitmapActive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE))) { ImageList_Replace(Context->ImageList, 0, bitmapActive, NULL); DeleteObject(bitmapActive); } else { PhSetImageListBitmap(Context->ImageList, 0, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE_BMP)); } if (bitmapInactive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE))) { ImageList_Replace(Context->ImageList, 1, bitmapInactive, NULL); DeleteObject(bitmapInactive); } else { PhSetImageListBitmap(Context->ImageList, 1, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE_BMP)); } }
// Replaces a bitmap, optionally passing a mask bitmap. // Note that wxImageList creates new bitmaps, so you may delete // 'bitmap' and 'mask'. bool wxImageList::Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask) { HBITMAP hbmp; #if wxUSE_WXDIB && wxUSE_IMAGE // See the comment in Add() above. AutoHBITMAP hbmpRelease; if ( bitmap.HasAlpha() ) { hbmp = wxDIB(bitmap.ConvertToImage(), wxDIB::PixelFormat_NotPreMultiplied).Detach(); hbmpRelease.Init(hbmp); } else #endif // wxUSE_WXDIB && wxUSE_IMAGE hbmp = GetHbitmapOf(bitmap); AutoHBITMAP hbmpMask(GetMaskForImage(bitmap, mask)); if ( !ImageList_Replace(GetHImageList(), index, hbmp, hbmpMask) ) { wxLogLastError(wxT("ImageList_Replace()")); return false; } return true; }
BOOL MyTreeView::removeItem(HTREEITEM elem){ if ( elem ){ //rimuovo l'icona TVITEM item; item.hItem = elem; item.mask = TVIF_IMAGE; if ( SendMessage(this->hWnd,TVM_GETITEM,0,(LPARAM)&item) ){ //rimuovo l'immagine se c'è ImageList_Replace(this->imgList,item.iImage,NULL,NULL); return SendMessage(this->hWnd,TVM_DELETEITEM,0,(LPARAM)elem); } } return FALSE; }
static HRESULT drawImagePart(HRESULT hr, struct drawState *s) { uiTableValue *value; IWICBitmap *wb; HBITMAP b; RECT r; UINT fStyle; if (hr != S_OK) return hr; if (s->p->imageModelColumn == -1) return S_OK; value = uiprivTableModelCellValue(s->model, s->iItem, s->p->imageModelColumn); wb = uiprivImageAppropriateForDC(uiTableValueImage(value), s->dc); uiFreeTableValue(value); hr = uiprivWICToGDI(wb, s->dc, s->m->cxIcon, s->m->cyIcon, &b); if (hr != S_OK) return hr; // TODO rewrite this condition to make more sense; possibly swap the if and else blocks too // TODO proper cleanup if (ImageList_GetImageCount(s->t->imagelist) > 1) { if (ImageList_Replace(s->t->imagelist, 0, b, NULL) == 0) { logLastError(L"ImageList_Replace()"); return E_FAIL; } } else if (ImageList_Add(s->t->imagelist, b, NULL) == -1) { logLastError(L"ImageList_Add()"); return E_FAIL; } // TODO error check DeleteObject(b); r = s->m->subitemIcon; r.right = r.left + s->m->cxIcon; r.bottom = r.top + s->m->cyIcon; centerImageRect(&r, &(s->m->subitemIcon)); fStyle = ILD_NORMAL; if (s->m->selected) fStyle = ILD_SELECTED; if (ImageList_Draw(s->t->imagelist, 0, s->dc, r.left, r.top, fStyle) == 0) { logLastError(L"ImageList_Draw()"); return E_FAIL; } return S_OK; }
// Replaces a bitmap, optionally passing a mask bitmap. // Note that wxImageList creates new bitmaps, so you may delete // 'bitmap' and 'mask'. bool wxImageList::Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask) { HBITMAP hbmpMask = GetMaskForImage(bitmap, mask); bool ok = ImageList_Replace(GetHImageList(), index, GetHbitmapOf(bitmap), hbmpMask) != 0; if ( !ok ) { wxLogLastError(wxT("ImageList_Replace()")); } ::DeleteObject(hbmpMask); return ok; }
// Replaces a bitmap, optionally passing a mask bitmap. // Note that wxImageList creates new bitmaps, so you may delete // 'bitmap' and 'mask'. bool wxImageList::Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask) { HBITMAP hbmp; bool useMask; #if wxUSE_WXDIB && wxUSE_IMAGE // See the comment in Add() above. AutoHBITMAP hbmpRelease; if ( bitmap.HasAlpha() ) { wxImage img = bitmap.ConvertToImage(); if ( wxApp::GetComCtl32Version() < 600 ) { img.ClearAlpha(); useMask = true; } else { useMask = false; } hbmp = wxDIB(img, wxDIB::PixelFormat_NotPreMultiplied).Detach(); hbmpRelease.Init(hbmp); } else #endif // wxUSE_WXDIB && wxUSE_IMAGE { hbmp = GetHbitmapOf(bitmap); useMask = true; } AutoHBITMAP hbmpMask; if ( useMask ) hbmpMask.Init(GetMaskForImage(bitmap, mask)); if ( !ImageList_Replace(GetHImageList(), index, hbmp, hbmpMask) ) { wxLogLastError(wxT("ImageList_Replace()")); return false; } return true; }
VOID PhSetImageListBitmap( _In_ HIMAGELIST ImageList, _In_ INT Index, _In_ HINSTANCE InstanceHandle, _In_ LPCWSTR BitmapName ) { HBITMAP bitmap; bitmap = LoadImage(InstanceHandle, BitmapName, IMAGE_BITMAP, 0, 0, 0); if (bitmap) { ImageList_Replace(ImageList, Index, bitmap, NULL); DeleteObject(bitmap); } }
static VOID RebarLoadSettings( VOID ) { // Initialize the Toolbar Imagelist. if (EnableToolBar && !ToolBarImageList) { HBITMAP iconBitmap = NULL; // Create the toolbar imagelist ToolBarImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0); // Set the number of images ImageList_SetImageCount(ToolBarImageList, 8); // Add the images to the imagelist if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_ARROW_REFRESH))) { ImageList_Replace(ToolBarImageList, 0, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 0, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_ARROW_REFRESH_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_COG_EDIT))) { ImageList_Replace(ToolBarImageList, 1, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 1, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_COG_EDIT_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_FIND))) { ImageList_Replace(ToolBarImageList, 2, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 2, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_FIND_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_CHART_LINE))) { ImageList_Replace(ToolBarImageList, 3, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 3, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_CHART_LINE_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION))) { ImageList_Replace(ToolBarImageList, 4, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 4, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION_GO))) { ImageList_Replace(ToolBarImageList, 5, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 5, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_GO_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_CROSS))) { ImageList_Replace(ToolBarImageList, 6, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 6, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_CROSS_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION_GET))) { ImageList_Replace(ToolBarImageList, 7, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 7, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_GET_BMP)); } } // Initialize the Rebar and Toolbar controls. if (EnableToolBar && !RebarHandle) { REBARINFO rebarInfo = { sizeof(REBARINFO) }; ULONG toolbarButtonSize; // Create the ReBar window. RebarHandle = CreateWindowEx( WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NODIVIDER | CCS_TOP | RBS_VARHEIGHT | RBS_AUTOSIZE, // CCS_NOPARENTALIGN | RBS_FIXEDORDER CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, PhMainWndHandle, NULL, NULL, NULL ); // Set the toolbar info with no imagelist. SendMessage(RebarHandle, RB_SETBARINFO, 0, (LPARAM)&rebarInfo); // Create the ToolBar window. ToolBarHandle = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER | CCS_ADJUSTABLE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | TBSTYLE_AUTOSIZE, // TBSTYLE_ALTDRAG CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, RebarHandle, NULL, NULL, NULL ); // Manually add button strings via TB_ADDSTRING. // NOTE: The Toolbar will sometimes decide to free strings hard-coded via (INT_PTR)L"String" // in the ToolbarButtons array causing random crashes unless we manually add the strings // into the Toolbar string pool (this bug only affects 64bit Windows)... WTF??? ToolbarButtons[0].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Refresh"); ToolbarButtons[1].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Options"); ToolbarButtons[3].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Handles or DLLs"); ToolbarButtons[4].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"System Information"); ToolbarButtons[6].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Window"); ToolbarButtons[7].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Window and Thread"); ToolbarButtons[8].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Window and Kill"); ToolbarButtons[9].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Always on Top"); // Set the toolbar struct size. SendMessage(ToolBarHandle, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); // Set the toolbar extended toolbar styles. SendMessage(ToolBarHandle, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DOUBLEBUFFER | TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_HIDECLIPPEDBUTTONS); // Configure the toolbar imagelist. SendMessage(ToolBarHandle, TB_SETIMAGELIST, 0, (LPARAM)ToolBarImageList); // Add the buttons to the toolbar (also specifying the default number of items to display). SendMessage(ToolBarHandle, TB_ADDBUTTONS, MAX_DEFAULT_TOOLBAR_ITEMS, (LPARAM)ToolbarButtons); // Restore the toolbar settings (Note: This will invoke the TBN_ENDADJUST notification). SendMessage(ToolBarHandle, TB_SAVERESTORE, FALSE, (LPARAM)&ToolbarSaveParams); // Query the toolbar button width/height. toolbarButtonSize = (ULONG)SendMessage(ToolBarHandle, TB_GETBUTTONSIZE, 0, 0); // Enable theming: //SendMessage(RebarHandle, RB_SETWINDOWTHEME, 0, (LPARAM)L"Media"); //Media/Communications/BrowserTabBar/Help //SendMessage(ToolBarHandle, TB_SETWINDOWTHEME, 0, (LPARAM)L"Media"); //Media/Communications/BrowserTabBar/Help // Inset the toolbar into the rebar control. RebarBandInsert(BandID_ToolBar, ToolBarHandle, HIWORD(toolbarButtonSize), LOWORD(toolbarButtonSize)); ToolbarInitialized = TRUE; } // Initialize the Searchbox and TreeNewFilters. if (EnableSearchBox && !SearchboxHandle) { SearchboxText = PhReferenceEmptyString(); ProcessTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportProcessTreeList(), (PPH_TN_FILTER_FUNCTION)ProcessTreeFilterCallback, NULL); ServiceTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportServiceTreeList(), (PPH_TN_FILTER_FUNCTION)ServiceTreeFilterCallback, NULL); NetworkTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportNetworkTreeList(), (PPH_TN_FILTER_FUNCTION)NetworkTreeFilterCallback, NULL); // Create the Searchbox control. SearchboxHandle = CreateSearchControl(ID_SEARCH_CLEAR); } // Initialize the Statusbar control. if (EnableStatusBar && !StatusBarHandle) { // Create the StatusBar window. StatusBarHandle = CreateWindowEx( 0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP | SBARS_TOOLTIPS, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, PhMainWndHandle, NULL, NULL, NULL ); } // Hide or show controls (Note: don't unload or remove at runtime). if (EnableToolBar) { if (RebarHandle && !IsWindowVisible(RebarHandle)) ShowWindow(RebarHandle, SW_SHOW); } else { if (RebarHandle && IsWindowVisible(RebarHandle)) ShowWindow(RebarHandle, SW_HIDE); } if (EnableSearchBox) { // Add the Searchbox band into the rebar control. if (!RebarBandExists(BandID_SearchBox)) RebarBandInsert(BandID_SearchBox, SearchboxHandle, 20, 180); if (SearchboxHandle && !IsWindowVisible(SearchboxHandle)) ShowWindow(SearchboxHandle, SW_SHOW); } else { // Remove the Searchbox band from the rebar control. if (RebarBandExists(BandID_SearchBox)) RebarBandRemove(BandID_SearchBox); if (SearchboxHandle) { // Clear search text and reset search filters. SetFocus(SearchboxHandle); Static_SetText(SearchboxHandle, L""); if (IsWindowVisible(SearchboxHandle)) ShowWindow(SearchboxHandle, SW_HIDE); } } // TODO: Fix above code... if (SearchBoxDisplayMode == SearchBoxDisplayHideInactive) { if (RebarBandExists(BandID_SearchBox)) RebarBandRemove(BandID_SearchBox); } else { if (!RebarBandExists(BandID_SearchBox)) RebarBandInsert(BandID_SearchBox, SearchboxHandle, 20, 180); } if (EnableStatusBar) { if (StatusBarHandle && !IsWindowVisible(StatusBarHandle)) ShowWindow(StatusBarHandle, SW_SHOW); } else { if (StatusBarHandle && IsWindowVisible(StatusBarHandle)) ShowWindow(StatusBarHandle, SW_HIDE); } }