Monday 15 July 2013

c++ - Copy part of one bitmap into an ImageList -


itemprop = "text">

Quick background: I, a TreeView which I created in Visual Studio 2008 (using the Windows API call in C ++) Should not make a difference):

  hTreeview = CreateWindowEx (0, WC_TREEVIEW, L "My triview", WSHCLD | WS_VISIBLE | TVSNCOXOFC | TVSISOHCRL | TVSISILTARS | TVSICITATS | TVSISISISIXPand, M_TX, M_t, m_tiv, am_th , HWO, (HMNU) 2, H. Instance, Nouvel);   

I have successfully submitted an ImageList to it:

  m_hImageList = ImageList_Create (CX, cy, ILC_COLOR24, N, N); Tree Vyssat Image (HRREView, M_Himjlist, TVSIL_NOML);   

Where cx , cy , and n are all specified (in this case, 18, 18 , And 5, respectively). All this works well, as I can see because now there is a place next to my item for the image.

What I am trying to accomplish is to make a copy of a bitmap again). The code that I have tried (but does not work) is:

  HBITMAP hSkin = (HBITMAP) LoadImage (zero, szPathBmp, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); For (tall I = 0; i   

I have omitted the error checking code for short, and it can be assumed that all of the listed variables are set elsewhere in the program (to provide me with a working source Sorry for the file, but this is a huge project and I have only tried to include parts that are relevant).

I'm getting into the previewview, which is the black intersection (which is the background color of Treeview), so I'm assuming something is going wrong in the last block of code - which Loads and tries to create a new bitmap for bitmap for a bitmap so that the image list can be saved Can someone tell me what I am doing, or tell me a better way to do what I want to do The attempt of L am?

I am using C ++ and Windows API, especially not Net, MFC, or Windows Form Designer.

Thank you in advance for your help, and if I have left anything, then I apologize; This is one of my first posts.

There are some problems with your code.

First of all, when you create a new DC, it starts with a monochrome bitmap, so your CreateCompatibleBitmap call will also give a monochrome. Instead, you can probably make bitmaps on the basis of the DC window or want to do the screen.

Second, you will never actually select bitmap in dcDest , so anything will be generated in the code> HICON anyway.

Third, ImageList_Add will be unsuccessful for you to cancel if the bitmap is currently selected in a device context, by HICON dcDest Before you add an icon to the image list.

Finally, if you are ignoring the original bitmaps to save and restore them, then it will also cause a GDI leakage.

Try something like this:

  HDC HDCDDO = Gate DC (HWND); HDC DCDist = Content Compatible DC (HDCWindo); HBITMAP hIcon = CreateCompatibleBitmap (HDC Window, cx, cy); HDC DCSRC = Creative Dual (NULL); HGDIOBJ hOldSourceBmp = SelectObject (DCSRC, HSSCIN); HGDIOBJ hOldDestBmp = SelectObject (DCDist, HICCON); Bitblatt (DCDEST, 0, cx, cy, dcsrc, x, y, srccopi); Select Object (DCDist, H OldDist BMP); SelectObject (DCSRC, HOSSOSMbP); * Picon = ImageList_Add (m_hImageList, hIcon, NULL); DeleteObject (HICON); DeleteDC (dcSrc); DeleteDC (dcDest); Release Dadi (HWND, HDC Vando);    

No comments:

Post a Comment