Exemple #1
0
void MainWindow::W7ToolbarSetImages() {
    QPixmap img;
    QBitmap mask;
    HIMAGELIST himl = ImageList_Create(20, 20, ILC_COLOR32, 4, 0);

    img = QIcon(":/back.png").pixmap(20);
    mask  = img.createMaskFromColor(Qt::transparent);
    ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());

    img = QIcon(":/play.png").pixmap(20);
    mask  = img.createMaskFromColor(Qt::transparent);
    ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());

    img = QIcon(":/forward.png").pixmap(20);
    mask  = img.createMaskFromColor(Qt::transparent);
    ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());

    img = QIcon(":/pause.png").pixmap(20);
    mask  = img.createMaskFromColor(Qt::transparent);
    ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());

    if (m_w7toolbar) m_w7toolbar->ThumbBarSetImageList(this->winId(), himl);

    ImageList_Destroy(himl);
}
void InsertObjectDialog::LoadObjects()
{
	// Create imagelists
	m_LargeImages.Create(32, 32, ILC_COLOR24, 0, 10);
	small_images.Create(16, 16, ILC_COLOR24, 0, 10);

	map<int, CPlugin>::iterator i = g_Plugins.begin();

	for ( ; i != g_Plugins.end(); i++) 
	{
		CString lowerName = i->second.m_Name;
		lowerName.MakeLower();

		if (!i->second.m_bMovement && lowerName != "tag")
		{
			bool bGame = false;
			if (application.runtime != CApplication::rt_application) bGame = true;

			if (!bGame && i->second.m_Category == OT_GAME)
				continue;

			// Extract the icon
			ImageList_Add(m_LargeImages, i->second.m_LargeIcon, NULL);
			ImageList_Add(small_images, i->second.m_SmallIcon, NULL);
		}
	}
}
BOOL wbCreateTreeViewImageList(PWBOBJ pwbo, HBITMAP hbmImage, int nImages, COLORREF clTransparent)
{
	HBITMAP hbmMask;
	static HIMAGELIST hi;
	BITMAP bm;

	if(!pwbo || !pwbo->hwnd || !IsWindow(pwbo->hwnd))
		return FALSE;

	if(hbmImage && nImages) {

		GetObject(hbmImage, sizeof(BITMAP), (LPSTR) &bm);
		if((bm.bmWidth == 0) | (bm.bmHeight == 0))
			return FALSE;

		nImages = MAX(1, MIN(nImages, MIN(bm.bmWidth, MAX_IMAGELIST_IMAGES)));

		if(clTransparent != NOCOLOR) {
			hbmMask = wbCreateMask(hbmImage, clTransparent);
			hi = ImageList_Create(bm.bmWidth / nImages, bm.bmHeight, ILC_COLORDDB | ILC_MASK, nImages, 0);
			ImageList_Add(hi, hbmImage, hbmMask);
			TreeView_SetImageList(pwbo->hwnd, hi, TVSIL_NORMAL);
			DeleteObject(hbmMask);
		} else {
			hi = ImageList_Create(bm.bmWidth / nImages, bm.bmHeight, ILC_COLORDDB, nImages, 0);
			ImageList_Add(hi, hbmImage, NULL);
			TreeView_SetImageList(pwbo->hwnd, hi, TVSIL_NORMAL);
		}
	} else {
		TreeView_SetImageList(pwbo->hwnd, NULL, TVSIL_NORMAL);
		ImageList_Destroy(hi);
	}
	return TRUE;
}
Exemple #4
0
// Create a drag image from a bitmap and optional cursor
bool wxDragImage::Create(const wxBitmap& image, const wxCursor& cursor)
{
    if ( m_hImageList )
        ImageList_Destroy(GetHimageList());
    m_hImageList = 0;

#ifdef __WXWINCE__
    UINT flags = ILC_COLOR;
#else
    UINT flags wxDUMMY_INITIALIZE(0) ;
    if (image.GetDepth() <= 4)
        flags = ILC_COLOR4;
    else if (image.GetDepth() <= 8)
        flags = ILC_COLOR8;
    else if (image.GetDepth() <= 16)
        flags = ILC_COLOR16;
    else if (image.GetDepth() <= 24)
        flags = ILC_COLOR24;
    else
        flags = ILC_COLOR32;
#endif

    bool mask = (image.GetMask() != 0);

    // Curiously, even if the image doesn't have a mask,
    // we still have to use ILC_MASK or the image won't show
    // up when dragged.
//    if ( mask )
    flags |= ILC_MASK;

    m_hImageList = (WXHIMAGELIST) ImageList_Create(image.GetWidth(), image.GetHeight(), flags, 1, 1);

    int index;
    if (!mask)
    {
        HBITMAP hBitmap1 = (HBITMAP) image.GetHBITMAP();
        index = ImageList_Add(GetHimageList(), hBitmap1, 0);
    }
    else
    {
        HBITMAP hBitmap1 = (HBITMAP) image.GetHBITMAP();
        HBITMAP hBitmap2 = (HBITMAP) image.GetMask()->GetMaskBitmap();
        HBITMAP hbmpMask = wxInvertMask(hBitmap2);

        index = ImageList_Add(GetHimageList(), hBitmap1, hbmpMask);
        ::DeleteObject(hbmpMask);
    }
    if ( index == -1 )
    {
        wxLogError(_("Couldn't add an image to the image list."));
    }
    m_cursor = cursor; // Can only combine with drag image after calling BeginDrag.

    return (index != -1) ;
}
BOOL _ui_init(
		HINSTANCE h_inst
	)
{
	HBITMAP undisk      = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_UNDISK ) );
	HBITMAP undisk_mask = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_UNDISK_MASK ) );

	HBITMAP disk        = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_DISK ) );
	HBITMAP disk_mask   = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_DISK_MASK ) );

	HBITMAP cdrom       = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_CDROM ) );
	HBITMAP cdrom_mask  = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_CDROM_MASK ) );

	HBITMAP disk_enb    = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_ENABLED ) );

	HBITMAP check       = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_CHECK ) );
	HBITMAP check_mask  = LoadBitmap( h_inst, MAKEINTRESOURCE( IDB_CHECK_MASK ) );

	NONCLIENTMETRICS metric = { sizeof(metric) };

	InitCommonControls( );
	if ( LoadLibrary(L"riched20.dll") == 0 ) return FALSE;

	__hinst = h_inst;
	__dlg = HWND_DESKTOP;

	metric.lfMessageFont.lfWeight = FW_BOLD;
	metric.lfMessageFont.lfHeight = -11;
	__font_bold = CreateFontIndirect( &metric.lfMessageFont );

	metric.lfMessageFont.lfWeight = FW_DONTCARE;
	metric.lfMessageFont.lfUnderline = TRUE;
	__font_link = CreateFontIndirect( &metric.lfMessageFont );

	metric.lfMessageFont.lfHeight = -9;
	metric.lfMessageFont.lfUnderline = FALSE;
	__font_small = CreateFontIndirect( &metric.lfMessageFont );

	__img = ImageList_Create( 9, 9, ILC_MASK, 2, 2 );
	__dsk_img = ImageList_Create( 15, 11, ILC_MASK | ILC_COLOR24, 5, 5 );
	
	ImageList_Add( __img, check, check_mask );

	ImageList_Add( __dsk_img, disk, disk_mask );
	ImageList_Add( __dsk_img, undisk, undisk_mask );
	ImageList_Add( __dsk_img, disk_enb, disk_mask );
	ImageList_Add( __dsk_img, cdrom, cdrom_mask );

	__cur_arrow = LoadCursor( NULL, IDC_ARROW );
	__cur_hand  = LoadCursor( NULL, IDC_HAND );
	__cur_wait  = LoadCursor( NULL, IDC_WAIT );

	return TRUE;

}
Exemple #6
0
void pListView::setImageList() {
  auto &list = listView.state.image;

  if(imageList) {
    ImageList_Destroy(imageList);
    imageList = nullptr;
  }

  bool found = false;
  for(auto &row : listView.state.image) {
    for(auto &column : row) {
      if(column.empty() == false) {
        found = true;
        break;
      }
    }
  }
  if(found == false) return;

  imageList = ImageList_Create(15, 15, ILC_COLOR32, 1, 0);
  nall::image image;
  image.allocate(15, 15);
  image.clear(GetSysColor(COLOR_WINDOW));
  ImageList_Add(imageList, CreateBitmap(image), NULL);

  for(unsigned row = 0; row < list.size(); row++) {
    for(unsigned column = 0; column < list(row).size(); column++) {
      nall::image image = list(row)(column);
      if(image.empty()) continue;
      image.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
      image.scale(15, 15, Interpolation::Linear);
      ImageList_Add(imageList, CreateBitmap(image), NULL);
    }
  }

  ListView_SetImageList(hwnd, imageList, LVSIL_SMALL);

  unsigned ID = 1;
  for(unsigned row = 0; row < list.size(); row++) {
    for(unsigned column = 0; column < list(row).size(); column++) {
      if(list(row)(column).empty()) continue;  //I_IMAGENONE does not work properly
      LVITEM item;
      item.mask = LVIF_IMAGE;
      item.iItem = row;
      item.iSubItem = column;
      item.iImage = ID++;
      ListView_SetItem(hwnd, &item);
    }
  }
}
MapData::MapData(char const* path)
  : images(DictionaryMap::alNumNoCase)
{
  imgList = NULL;
  map = MPQArchive::open(path, File::READ);
  if (map == NULL)
    map = MPQArchive::open(String::buildFullName(cfg.warPath, path), File::READ);
  if (map)
  {
    imgList = ImageList_Create(16, 16, ILC_COLOR24, 16, 16);

    MPQLoader loader(*getApp()->getWarLoader());
    loader.addArchive(map);
    LoadGameData(data, &loader, WC3_LOAD_UNITS | WC3_LOAD_ITEMS |
      WC3_LOAD_ABILITIES | WC3_LOAD_UPGRADES | WC3_LOAD_MERGED | WC3_LOAD_NO_WEONLY);

    Image blank(16, 16);
    blank.fill(Image::clr(255, 255, 255));
    HBITMAP hBitmap = blank.createBitmap();
    ImageList_Add(imgList, hBitmap, NULL);
    DeleteObject(hBitmap);

    images.set("", 0);
  }
}
Exemple #8
0
void AnimatorBar::UpdateFilmStrip()
{
	film_strip.SetRedraw(false);
	m_ImageList.DeleteImageList();
	film_strip.DeleteAllItems();

	if(!m_pCurrentAnimation)
		return;
	
	m_ImageList.Create(32, 32, ILC_COLOR24, 3, 3);
	film_strip.SetImageList(&m_ImageList, LVSIL_NORMAL);
	
	for (int i = 0; i < m_pCurrentAnimation->m_Images.size(); i++)
	{
		// Create thumbnail & add to filmstrip
		CImageResource* pImage = application->resources.FindImageResourceFromNumber(m_pCurrentAnimation->m_Images[i]);

		if(pImage)
		{
			HBITMAP Bitmap = pImage->GetHBitmap(true,false);
			ImageList_Add(m_ImageList.m_hImageList, Bitmap, Bitmap);


			CString Name;
			Name.Format("%d", i + 1);
			film_strip.InsertItem(i, Name, i);
		}
	}

	film_strip.SetRedraw(true);
	film_strip.Invalidate();
}
void RendSplineParamsMapDlgProc::Initialize(HWND hWnd, TimeValue t)
{
	if (hWnd == NULL) return;
	else
	{
		ISpinnerControl *iSpin = GetISpinner(GetDlgItem(hWnd, IDC_ASPECTSPIN));
		iSpin->LinkToEdit(GetDlgItem(hWnd, IDC_ASPECT), EDITTYPE_FLOAT);
		iSpin->SetLimits(0.0f,99999999.0f);
		iSpin->SetAutoScale(TRUE);
		ReleaseISpinner(iSpin);

		if (RendSpline::hLockButton == NULL) {
			HBITMAP hBitmap, hMask;
			RendSpline::hLockButton = ImageList_Create(16, 15, TRUE, 2, 0);
			hBitmap = LoadBitmap(RendSplineDesc.HInstance(), MAKEINTRESOURCE(IDB_LOCK));
			hMask   = LoadBitmap(RendSplineDesc.HInstance(), MAKEINTRESOURCE(IDB_LOCKMASK));
			ImageList_Add(RendSpline::hLockButton,hBitmap,hMask);
			DeleteObject(hBitmap);
			DeleteObject(hMask);
		}

		ICustButton *lockAspect = GetICustButton(GetDlgItem(hWnd,IDC_ASPECTLOCK));
		lockAspect->SetImage(RendSpline::hLockButton,0,0,1,1,16,15);
		lockAspect->SetType(CBT_CHECK);
		ReleaseICustButton(lockAspect);

		CheckRadioButton(hWnd, IDC_VIEWPORT, IDC_RENDERER, IDC_RENDERER);

        BOOL usePhysUVs = mod->GetUsePhysicalScaleUVs();
        CheckDlgButton(hWnd, IDC_REAL_WORLD_MAP_SIZE, usePhysUVs);
	}

}
Exemple #10
0
void InitIML() {
	int i;
	HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 3, 0);
	HBITMAP hbIcons = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 48, 16, LR_DEFAULTCOLOR);
	ImageList_Add(hImageList, hbIcons, NULL);
	for (i = 0; i != 3; i++)
		stateicons[i] = ImageList_GetIcon(hImageList, i, ILD_NORMAL);
	SendMessage(hWnd_Tab, TCM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)hImageList);
	
	hCfgTabiml = ImageList_Create(16, 16, ILC_COLOR32, 6, 0);
	hbIcons = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP3), IMAGE_BITMAP, 96, 16, LR_DEFAULTCOLOR);
	ImageList_AddMasked(hCfgTabiml, hbIcons, 0);
	
	/////listview images
	hImageList = ImageList_Create(28, 14, ILC_COLOR32 | ILC_MASK, 32, 0);
	ImageList_SetBkColor(hImageList, CLR_NONE);
	lvwIML = hImageList;
	hbIcons = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP2), IMAGE_BITMAP, 896, 14,  /*ILC_MASK |*/ LR_DEFAULTCOLOR);
	//ImageList_Remove(hImageList, -1);

	//char asdf[32];
	//sprintf(asdf, "%d", CLR_INVALID == -1);
	//MessageBox(0,asdf,0,0);

	ImageList_AddMasked(hImageList, hbIcons, 0);
	for (i = 0; i != NUM_BNICONS; i++)
		bnicons[i] = ImageList_GetIcon(hImageList, i, ILD_NORMAL);
}
Exemple #11
0
void pButton::setImage(const image& image, Orientation orientation) {
  nall::image nallImage = image;
  nallImage.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);

  if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
  if(himagelist) { ImageList_Destroy(himagelist); himagelist = 0; }

  if(OsVersion() >= WindowsVista) {
    hbitmap = CreateBitmap(nallImage);
    SendMessage(hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbitmap);
    switch(orientation) {
    case Orientation::Horizontal: SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) & ~BS_TOP); break;
    case Orientation::Vertical:   SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) |  BS_TOP); break;
    }
  } else {
    //Windows XP and earlier cannot display bitmaps and text at the same time with BM_SETIMAGE
    //Use BCM_SETIMAGELIST instead. It does not support alpha blending, so blend with button color
    //The XP theme and above use a gradient fade background, so it won't be a perfect match there
    nallImage.alphaBlend(GetSysColor(COLOR_BTNFACE));
    hbitmap = CreateBitmap(nallImage);
    himagelist = ImageList_Create(nallImage.width, nallImage.height, ILC_COLOR32, 1, 0);
    ImageList_Add(himagelist, hbitmap, NULL);
    BUTTON_IMAGELIST list;
    list.himl = himagelist;
    switch(orientation) {
    case Orientation::Horizontal: SetRect(&list.margin, 5, 0, 0, 0); list.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT; break;
    case Orientation::Vertical:   SetRect(&list.margin, 0, 5, 0, 0); list.uAlign = BUTTON_IMAGELIST_ALIGN_TOP;  break;
    }
    Button_SetImageList(hwnd, &list);
  }

  setText(button.state.text);  //update text to display nicely with image (or lack thereof)
}
Exemple #12
0
int Icon::add_to_imagelist(HIMAGELIST himl, HDC hdc_wnd, COLORREF bk_color, HBRUSH bk_brush) const
{
    int ret;

    if (_itype == IT_SYSCACHE) {
        HIMAGELIST himl = g_Globals._icon_cache.get_sys_imagelist();

        int cx, cy;
        ImageList_GetIconSize(himl, &cx, &cy);

        HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, cx, cy);
        HDC hdc = CreateCompatibleDC(hdc_wnd);
        HBITMAP hbmp_old = SelectBitmap(hdc, hbmp);
        ImageList_DrawEx(himl, _sys_idx, hdc, 0, 0, cx, cy, bk_color, CLR_DEFAULT, ILD_NORMAL);
        SelectBitmap(hdc, hbmp_old);
        DeleteDC(hdc);

        ret = ImageList_Add(himl, hbmp, 0);

        DeleteObject(hbmp);
    } else
        ret = ImageList_AddAlphaIcon(himl, _hicon, bk_brush, hdc_wnd);

    return ret;
}
HWND Explorerplusplus::CreateTabToolbar(HWND hParent,int idCommand,TCHAR *szTip)
{
	HWND TabToolbar = CreateToolbar(hParent,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|
		TBSTYLE_TOOLTIPS|TBSTYLE_LIST|TBSTYLE_TRANSPARENT|TBSTYLE_FLAT|CCS_NODIVIDER|
		CCS_NOPARENTALIGN|CCS_NORESIZE,TBSTYLE_EX_MIXEDBUTTONS|TBSTYLE_EX_DOUBLEBUFFER);
	
	SendMessage(TabToolbar,TB_SETBITMAPSIZE,0,MAKELONG(7,7));
	SendMessage(TabToolbar,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0);
	SendMessage(TabToolbar,TB_SETBUTTONSIZE,0,MAKELPARAM(16,16));

	/* TODO: The image list is been leaked. */
	HIMAGELIST himl = ImageList_Create(7,7,ILC_COLOR32|ILC_MASK,0,2);
	HBITMAP hb = LoadBitmap(GetModuleHandle(0),MAKEINTRESOURCE(IDB_TABTOOLBAR_CLOSE));
	int iIndex = ImageList_Add(himl,hb,NULL);
	SendMessage(TabToolbar,TB_SETIMAGELIST,0,reinterpret_cast<LPARAM>(himl));
	DeleteObject(hb);

	/* Add the close button, used to close tabs. */
	TBBUTTON tbButton;
	tbButton.iBitmap	= iIndex;
	tbButton.idCommand	= idCommand;
	tbButton.fsState	= TBSTATE_ENABLED;
	tbButton.fsStyle	= TBSTYLE_BUTTON|TBSTYLE_AUTOSIZE;
	tbButton.dwData		= 0;
	tbButton.iString	= reinterpret_cast<INT_PTR>(szTip);
	SendMessage(TabToolbar,TB_INSERTBUTTON,0,reinterpret_cast<LPARAM>(&tbButton));

	SendMessage(TabToolbar,TB_AUTOSIZE,0,0);

	return TabToolbar;
}
Exemple #14
0
// CRotateDlg message handlers
BOOL CRotateDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_AngleIcons.Create(16, 16, ILC_COLOR24 | ILC_MASK, 3, 3);

	HBITMAP icon = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_ANGLEICONS));

	ImageList_Add(m_AngleIcons, icon, NULL);

	DeleteObject(icon);

	m_Angle.SetImageList(&m_AngleIcons);
	m_Angle.SetWindowText("0");

	for (int i = 0; i < 8; i++)
	{
		COMBOBOXEXITEM insItem;
		insItem.mask = CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE; 
		insItem.iItem = i;
		insItem.iImage = i;
		insItem.iSelectedImage = i;

		CString Text;
		Text.Format("%d", i * 45);
		insItem.pszText = Text.GetBuffer(0);
		m_Angle.InsertItem(&insItem);
	}

	m_Angle.SetFocus();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #15
0
bool
CRootNode::SetupNode()
{

    // Load the bitmap we'll be using as the root image
    HBITMAP hRootImage;
    hRootImage = LoadBitmapW(g_hThisInstance,
                             MAKEINTRESOURCEW(IDB_ROOT_IMAGE));
    if (hRootImage == NULL) return FALSE;

    // Add this bitmap to the device image list. This is a bit hacky, but it's safe
    m_ClassImage = ImageList_Add(m_ImageListData->ImageList,
                                 hRootImage,
                                 NULL);
    DeleteObject(hRootImage);


    // Get the root instance 
    CONFIGRET cr;
    cr = CM_Locate_DevNodeW(&m_DevInst,
                            NULL,
                            CM_LOCATE_DEVNODE_NORMAL);
    if (cr != CR_SUCCESS)
    {
        return false;
    }

    // The root name is the computer name 
    DWORD Size = DISPLAY_NAME_LEN;
    GetComputerNameW(m_DisplayName, &Size);

    return true;
}
Exemple #16
0
HRESULT CCImageList::AddBitmapFromHandle(int* pn, HBITMAP hbm)
{
    int n = ImageList_Add(m_hImageList, hbm, NULL);
    DeleteObject(hbm);
    if(pn) *pn = n;
    return n == -1 ? E_FAIL : S_OK;
}
void CAnimationEditorDlg::UpdateList()
{
	m_Frames.SetRedraw(false);
	m_ImageList.DeleteImageList();
	m_Frames.DeleteAllItems();

	if(!m_CurrentAnimation)
		return;
	
	m_ImageList.Create(32, 32, ILC_COLOR24, 3, 3);
	m_Frames.SetImageList(&m_ImageList, LVSIL_NORMAL);
	
	for (int i = 0; i < m_CurrentAnimation->m_Images.size(); i++)
	{
		// Create thumbnail & add to filmstrip
		CImageResource* image = m_pApplication->FindImageResourceFromNumber(m_CurrentAnimation->m_Images[i]);

		if(image)
		{
				
				HBITMAP Bitmap = image->GetHBitmap(true,false);
				ImageList_Add(m_ImageList.m_hImageList, Bitmap, Bitmap);

				CString name;
				name.Format("%d", i+1);
				m_Frames.InsertItem(i, name, i);
		}
	}

	m_Frames.SetRedraw(true);
	m_Frames.Invalidate();
}
BOOL MyTreeView::setItemIcon(HTREEITEM elem, HBITMAP icon)
{
	if ( !icon ) return FALSE;

	TVITEM item;
	memset(&item, 0, sizeof(TVITEM));
	BOOL ret = FALSE;

	if ( getItem(elem, &item) )
	{
		//cambio immagine
		int idimg = ImageList_Add(imgList, icon, NULL);	
		if ( idimg != -1 )
		{
			//elimino la vecchia immagine
			//La ImageList_Remove rimuove un'immagine dalla lista ma riordina gli indici delle immagini rimaste
			//in modo da essere sempre un intervallo senza buchi
			/*if ( item.iImage )
			{
				//l'immagine di default ha indice 0, le altre possono essere rimosse
				ImageList_Remove(imgList, item.iImage);
			}
			*/

			item.mask = TVIF_SELECTEDIMAGE | TVIF_IMAGE;
			item.iImage = idimg;
			item.iSelectedImage = idimg;

			ret = SendMessage(hWnd, TVM_SETITEM, 0, (LPARAM)&item);
		}
	}
	return ret;
}
Exemple #19
0
// Adds a bitmap, and optionally a mask bitmap.
// Note that wxImageList creates new bitmaps, so you may delete
// 'bitmap' and 'mask'.
int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask)
{
    HBITMAP hbmp;

#if wxUSE_WXDIB && wxUSE_IMAGE
    // wxBitmap normally stores alpha in pre-multiplied format but
    // ImageList_Draw() does pre-multiplication internally so we need to undo
    // the pre-multiplication here. Converting back and forth like this is, of
    // course, very inefficient but it's better than wrong appearance so we do
    // this for now until a better way can be found.
    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);

    // Use mask only if we don't have alpha, the bitmap isn't drawn correctly
    // if we use both.
    AutoHBITMAP hbmpMask;
    if ( !bitmap.HasAlpha() )
        hbmpMask.Init(GetMaskForImage(bitmap, mask));

    int index = ImageList_Add(GetHImageList(), hbmp, hbmpMask);
    if ( index == -1 )
    {
        wxLogError(_("Couldn't add an image to the image list."));
    }

    return index;
}
HIMAGELIST CheckedListView::CreateCheckBoxImageList(HWND hWnd)
{
	HDC hdc_wnd, hdc;
	HBITMAP hbm_im, hbm_mask, hbm_orig;
	RECT rc;
	HIMAGELIST himl;
                                    
	int x = GetSystemMetrics(SM_CXSMICON);
	himl = ImageList_Create(x, GetSystemMetrics(SM_CYSMICON), ILC_COLOR16 | ILC_MASK, 2, 2);
	hdc_wnd = GetDC(hWnd);
	hdc = CreateCompatibleDC(hdc_wnd);
	hbm_im = CreateCompatibleBitmap(hdc_wnd, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));	
	hbm_mask = CreateBitmap(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 1, 1, NULL);
	ReleaseDC(hWnd, hdc_wnd);
                                                                      
	rc.left = rc.top = 0;
	rc.right = GetSystemMetrics(SM_CXSMICON);
	rc.bottom = GetSystemMetrics(SM_CYSMICON);

	hbm_orig = (HBITMAP) SelectObject(hdc, hbm_mask);
	SelectObject(hdc, hbm_im);	

	// Create normal image
	_createButtonCheckImage(hdc, &rc, false, CheckedColorNone);
	SelectObject(hdc, hbm_orig);
	ImageList_Add(himl, hbm_im, hbm_mask);
	SelectObject(hdc, hbm_im);

	// Create color checked images
	CheckedColor colors[] = {CheckedColorBlack, CheckedColorGrey, CheckedColorYellow, CheckedColorGreen, CheckedColorNone};
	CheckedColor* color = colors;

	while (*color != CheckedColorNone)
	{	
		_createButtonCheckImage(hdc, &rc, true, *color);
		SelectObject(hdc, hbm_orig);
		ImageList_Add(himl, hbm_im, hbm_mask);
		SelectObject(hdc, hbm_im);
		color++;
	}

	DeleteObject(hbm_mask);
	DeleteObject(hbm_im);
	DeleteDC(hdc);
	return himl;
}
/*!
	プレビューウインドウクラスを作成
	@param[in]	hInstance	アプリのインスタンス
	@param[in]	hParentWnd	親ウインドウのハンドル
	@return	なし
*/
VOID PreviewInitialise( HINSTANCE hInstance, HWND hParentWnd )
{
	WNDCLASSEX	wcex;
	GUID	guid;

	HBITMAP	hImg, hMsq;

	if( hInstance )
	{
		ghInst = hInstance;

		_Module.Init( ObjectMap, hInstance, &guid );

		//	専用のウインドウクラス作成
		ZeroMemory( &wcex, sizeof(WNDCLASSEX) );
		wcex.cbSize			= sizeof(WNDCLASSEX);
		wcex.style			= CS_HREDRAW | CS_VREDRAW;
		wcex.lpfnWndProc	= PreviewWndProc;
		wcex.cbClsExtra		= 0;
		wcex.cbWndExtra		= 0;
		wcex.hInstance		= hInstance;
		wcex.hIcon			= NULL;
		wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
		wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
		wcex.lpszMenuName	= NULL;
		wcex.lpszClassName	= DOC_PREVIEW_CLASS;
		wcex.hIconSm		= NULL;

		RegisterClassEx( &wcex );

		ghPrevWnd = NULL;

		PreviewHeaderGet(  );

		CoInitialize( NULL );

		giViewMode = 0;

		ghPrevwImgLst = ImageList_Create( 16, 16, ILC_COLOR24 | ILC_MASK, 1, 1 );
		hImg = LoadBitmap( ghInst, MAKEINTRESOURCE( (IDBMP_PREVIEW_ALL) ) );
		hMsq = LoadBitmap( ghInst, MAKEINTRESOURCE( (IDBMQ_PREVIEW_ALL) ) );
		ImageList_Add( ghPrevwImgLst , hImg, hMsq );	//	イメージリストにイメージを追加
		DeleteBitmap( hImg );	DeleteBitmap( hMsq );
	}
	else
	{
		//	もし開けたままだったら綺麗に閉じないとメモリリーク
		if( ghPrevWnd ){	SendMessage( ghPrevWnd, WM_CLOSE, 0, 0 );	}

		CoUninitialize( );

		FREE(gpcHtmlHdr);

		ImageList_Destroy( ghPrevwImgLst );
	}

	return;
}
Exemple #22
0
BOOL CNewBehaviorDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// Add movements to dialog
	POSITION pos = g_dlls->GetStartPosition();
	DWORD    nKey;
	OINFO*   oInfo;

	m_Images.Create(32, 32, ILC_COLOR24, 3, 3);
	ListView_SetImageList(m_List.m_hWnd, m_Images.m_hImageList, LVSIL_NORMAL);

	vector<OINFO*> sorted;

	while (pos != NULL)
	{ 
		// locate the object DLL to use
		g_dlls->GetNextAssoc(pos, nKey, oInfo);

		if (oInfo->ideFlags & OF_MOVEMENTPLUGIN) 
		{
			sorted.push_back(oInfo);
		}
	}

	sort(sorted.begin(), sorted.end(), BehaviorSortFunction);

	for (int i = 0; i < sorted.size(); i++)
	{
		int icon = ImageList_Add(m_Images.m_hImageList, sorted[i]->hLargeIcon, NULL);

		int item = m_List.InsertItem(m_List.GetItemCount(), sorted[i]->extName, icon);
		behaviors.push_back(sorted[i]->oID);
	}

	// Resizing
	dlgMan.Load(this->m_hWnd, "Software\\Construct\\NewBehaviorDialog");
    dlgAnchor.Init(this->m_hWnd);

	dlgAnchor.Add(IDC_LIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(IDOK, ANCHOR_RIGHT | ANCHOR_TOP);
	dlgAnchor.Add(IDCANCEL, ANCHOR_RIGHT | ANCHOR_TOP);
	dlgAnchor.Add(IDC_INFO, ANCHOR_BOTTOM | ANCHOR_LEFT);

	// Change title
	CString Title;
	Title.Format("Construct : %s", PROPERTIES_NEWMOVEMENT);
	SetWindowText(Title);

	m_Cancel.SetWindowText(CANCEL);
	m_OK.SetWindowText(INSERT);
	m_OK.EnableWindow(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
static void LoadImages() {
	if (hButtonImages) return;
	HBITMAP hBitmap, hMask;
	hButtonImages = ImageList_Create(15, 14, ILC_MASK, 2, 0);	// 17 is kluge to center square. -SA
	hBitmap     = LoadBitmap (hInstance,MAKEINTRESOURCE(IDB_BUTTONS));
	hMask       = LoadBitmap (hInstance,MAKEINTRESOURCE(IDB_BUTTON_MASK));
	ImageList_Add(hButtonImages, hBitmap, hMask);
	DeleteObject(hBitmap);
	DeleteObject(hMask);
}
void BuildTree::CreateTreeView(HWND hwndParent,HINSTANCE hInst,LPSTR lpszFileName) 
{ 
	RECT rcClient;
    
    InitCommonControls(); 
    GetClientRect(hwndParent, &rcClient); 
    s_hWndTV = CreateWindowEx(0,
                            WC_TREEVIEW,
                            "Tree View",
							WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS, 
                            0, 
                            0, 
                            rcClient.right, 
                            rcClient.bottom,
                            hwndParent, 
                            (HMENU)0, 
                            hInst, 
                            NULL); 

	::ShowWindow(s_hWndTV,SW_SHOW);

	HIMAGELIST himl;  // handle to image list 
    HBITMAP hbmp;     // handle to bitmap 

    // Create the image list. 
	himl = ImageList_Create(16,16,ILC_COLOR32,2, 0);
    

    // Add the open file, closed file, and document bitmaps. 
    hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP_BUILD)); 
    ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP_FOLDER)); 
    ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

	int ic = ImageList_GetImageCount(himl);

    // Associate the image list with the tree-view control. 
    TreeView_SetImageList(s_hWndTV, himl, TVSIL_NORMAL); 

} 
Exemple #25
0
int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd)
{
    HBITMAP hbmp = create_bitmap_from_icon(hIcon, hbrush_bkgnd, hdc_wnd);

    int ret = ImageList_Add(himl, hbmp, 0);

    DeleteObject(hbmp);

    return ret;
}
void CAddBookmarkDialog::SetDialogIcon()
{
	HIMAGELIST himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,48);
	HBITMAP hBitmap = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_SHELLIMAGES));
	ImageList_Add(himl,hBitmap,NULL);

	m_hDialogIcon = ImageList_GetIcon(himl,SHELLIMAGES_ADDFAV,ILD_NORMAL);
	SetClassLongPtr(m_hDlg,GCLP_HICONSM,reinterpret_cast<LONG_PTR>(m_hDialogIcon));

	DeleteObject(hBitmap);
	ImageList_Destroy(himl);
}
Exemple #27
0
static void ImageList_Append(HIMAGELIST imageList, const nall::image& source, unsigned scale) {
  auto image = source;
  if(image.empty()) {
    image.allocate(scale, scale);
    image.fill(GetSysColor(COLOR_WINDOW));
  }
  image.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
  image.scale(scale, scale);
  HBITMAP bitmap = CreateBitmap(image);
  ImageList_Add(imageList, bitmap, NULL);
  DeleteObject(bitmap);
}
Exemple #28
0
// Adds a bitmap, and optionally a mask bitmap.
// Note that wxImageList creates new bitmaps, so you may delete
// 'bitmap' and 'mask'.
int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask)
{
    HBITMAP hbmp;
    bool useMask;

#if wxUSE_WXDIB && wxUSE_IMAGE
    // wxBitmap normally stores alpha in pre-multiplied format but
    // ImageList_Draw() does pre-multiplication internally so we need to undo
    // the pre-multiplication here. Converting back and forth like this is, of
    // course, very inefficient but it's better than wrong appearance so we do
    // this for now until a better way can be found.
    AutoHBITMAP hbmpRelease;
    if ( bitmap.HasAlpha() )
    {
        wxImage img = bitmap.ConvertToImage();

        // For comctl32.dll < 6 remove alpha channel from image
        // to prevent possible interferences with the mask.
        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;
    }

    // Use mask only if we don't have alpha, the bitmap isn't drawn correctly
    // if we use both.
    AutoHBITMAP hbmpMask;
    if ( useMask )
        hbmpMask.Init(GetMaskForImage(bitmap, mask));

    int index = ImageList_Add(GetHImageList(), hbmp, hbmpMask);
    if ( index == -1 )
    {
        wxLogError(_("Couldn't add an image to the image list."));
    }

    return index;
}
void CRasterResourceListCtrl::_OnInitListView(int cItems)
{
    // Put an imagelist in the view, for our pic previews.

    // Destroy any old list
    if (_himlPics)
    {
        ImageList_Destroy(_himlPics);
        _himlPics = NULL;
    }

    CSize sizeImages(VIEW_IMAGE_SIZE, VIEW_IMAGE_SIZE);
    // Note: this color depth must match that which we get back from the ViewResource
    // Also: ILC_MASK must be specified, because of the overlay
    _himlPics = ImageList_Create(sizeImages.cx, sizeImages.cy, ILC_COLOR8 | ILC_MASK, cItems, 30);
    
    if (_himlPics)
    {
        CImageList *pTemp = CImageList::FromHandle(_himlPics);
        if (pTemp)
        {
            HIMAGELIST himlOld = (HIMAGELIST)SetImageList(pTemp, LVSIL_NORMAL);
        }
        // pTemp is a temporary object that we don't need to delete.

        // Load an overlay image to use for "unused" items
        HBITMAP hbmOverlay = LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_OVERLAYOLD40));
        if (hbmOverlay)
        {
            int iOverlayImageIndex = ImageList_AddMasked(_himlPics, hbmOverlay, RGB(255, 0, 255));
            ImageList_SetOverlayImage(_himlPics, iOverlayImageIndex, OVERLAYINDEX_UNUSED);
            DeleteObject(hbmOverlay);
        }

        HBITMAP hbmCorrupt = LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_CORRUPTRESOURCE));
        if (hbmCorrupt)
        {
            _iCorruptBitmapIndex = ImageList_Add(_himlPics, hbmCorrupt, NULL);
            DeleteObject(hbmCorrupt);
        }
    }

    // Adjust the icon spacing so things don't look too spread out.
    CSize sizeSpacing(sizeImages.cx + 20, sizeImages.cy + 30);
    SetIconSpacing(sizeSpacing);

    // LVS_EX_BORDERSELECT, supported on IE 4.0 or later. -> Removed, as it causes problems in details view
    // LVS_EX_DOUBLEBUFFER, supported on XP or later.
    SetExtendedStyle(GetExtendedStyle() | 0x00010000 | LVS_EX_INFOTIP);

}
void ToolBarFrame::Init()
{
	mParentWindow = NULL;
	mToolBarWindow = NULL;
	mPopUpWindow = NULL;
	mDummyWindow = NULL;

	mToolBar = NULL;
	mOwner = 0;

	mX = 0;
	mY = 0;
	mW = 0;
	mH = 0;

	mLocation = kFloat;

	mLoaded = false;

	mCenter = false;

	mImages = NULL; 
	

	static BOOL registered = FALSE;
	if (!registered && mhInstance) {
		registered = TRUE;
		WNDCLASS  wc;
		wc.style         = 0;
		wc.hInstance     = mhInstance;
		wc.hIcon         = NULL;
		wc.hCursor       = NULL;
		wc.hbrBackground = NULL; 
		wc.lpszMenuName  = NULL;
		wc.cbClsExtra    = 0;
		wc.cbWndExtra    = 0;
		wc.lpfnWndProc   = PopUpToolbarProc;
		wc.lpszClassName = _M("ToolBarFrameWindow");
		RegisterClass(&wc);

	}

	HBITMAP hBitmap, hMask;	
	mImages = ImageList_Create(16, 15, TRUE, 4, 0);
	hBitmap = LoadBitmap(mhInstance,MAKEINTRESOURCE(IDB_UNWRAP_TRANSFORM));
	hMask   = LoadBitmap(mhInstance,MAKEINTRESOURCE(IDB_UNWRAP_TRANSFORM_MASK));
	ImageList_Add(mImages,hBitmap,hMask);
	DeleteObject(hBitmap);
	DeleteObject(hMask);
}