Click here to Skip to main content
15,878,970 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: WaitForSingleObject Crash Pin
Stephen Hewitt18-Aug-13 19:53
Stephen Hewitt18-Aug-13 19:53 
AnswerRe: WaitForSingleObject Crash Pin
Erudite_Eric18-Aug-13 20:07
Erudite_Eric18-Aug-13 20:07 
GeneralRe: WaitForSingleObject Crash Pin
ForNow19-Aug-13 4:45
ForNow19-Aug-13 4:45 
GeneralRe: WaitForSingleObject Crash Pin
Jochen Arndt19-Aug-13 5:14
professionalJochen Arndt19-Aug-13 5:14 
GeneralRe: WaitForSingleObject Crash Pin
ForNow19-Aug-13 5:20
ForNow19-Aug-13 5:20 
GeneralRe: WaitForSingleObject Crash Pin
Stephen Hewitt19-Aug-13 20:32
Stephen Hewitt19-Aug-13 20:32 
AnswerRe: WaitForSingleObject Crash Pin
Richard MacCutchan18-Aug-13 20:35
mveRichard MacCutchan18-Aug-13 20:35 
QuestionWin32 Menu bitmaps Pin
Jonathan Davies17-Aug-13 10:43
Jonathan Davies17-Aug-13 10:43 
Using an ImageList to load 16 x 16 bitmaps into a toolbar I've been trying to use the bitmaps from that same ImageList for corresponding menu items but I can't get rid of a whiteness around the images. The main code block code below gives the best I can get. Though I can use a IMAGELISTDRAWPARAMS setting the ilDrawParams.rgbBk = GetSysColor(COLOR_MENU) and using ImageList_DrawIndirect which does get rid of the whiteness though the background is then wrong again if the menu item is highlighted - this also seems to be missing the point when is seems the bitmaps can supposedly be drawn transparently anyway. Any suggestions appreciated.
C++
// Get a menu handle for the one to have an image added to it
HMENU hMenuMain = GetMenu(hWnd);
HMENU hTestMenu = GetSubMenu(hMenuMain, PORT_MENU_ID);

// Load the image i.e. a bitmap 'strip' that is actually a number of bitmaps
HIMAGELIST hImageList = ::ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDB_BITMAP1), 16, 0,
                      RGB(255,0,255), IMAGE_BITMAP, LR_SHARED | LR_LOADTRANSPARENT);

// Get DC for Window client area
HDC hDCWindow = ::GetDC(hWnd);

// and create a compatibles DC im memory
HDC hDCDest = CreateCompatibleDC(hDCWindow);

// Create a bitmap compatible with the device associated with the DC
HBITMAP hComapatBitmap = CreateCompatibleBitmap(hDCWindow, 16, 16);

// Select the destination bitmap into the DC
HGDIOBJ hOldDestBmp = SelectObject(hDCDest, hComapatBitmap);

// Bitmap is already selected into a screen-compatible device context by the image list
BOOL bDrawn = ImageList_DrawEx(hImageList, 1, hDCDest, 0, 0, 16, 16, RGB(255, 0, 255),
                                                    CLR_NONE , ILD_TRANSPARENT);

// Select back old object back in retrieving returned drawn bitmap
HBITMAP hRetrievedBitmap = (HBITMAP)::SelectObject(hDCDest, hOldDestBmp);

// as used CreateCompatibleDC(...) must delete it
::DeleteDC(hDCDest);

// as used GetDc must release it
::ReleaseDC(hWnd, hDCWindow);

// Create a structure that describes the change to make to the menu item
MENUITEMINFO MenuItemInfo;
::SecureZeroMemory(&MenuItemInfo, sizeof(MENUITEMINFO));
MenuItemInfo.cbSize = sizeof(MENUITEMINFO);

MenuItemInfo.fMask = MIIM_BITMAP;
MenuItemInfo.hbmpItem = hRetrievedBitmap;

// Make the change
::SetMenuItemInfo(hTestMenu, ID_PORT_EDIT, FALSE, &MenuItemInfo);

// Call as required by Windows.
::DrawMenuBar(hWnd);


modified 18-Aug-13 4:57am.

GeneralRe: Win32 Menu bitmaps Pin
Richard MacCutchan18-Aug-13 1:25
mveRichard MacCutchan18-Aug-13 1:25 
GeneralRe: Win32 Menu bitmaps Pin
Jonathan Davies18-Aug-13 5:20
Jonathan Davies18-Aug-13 5:20 
AnswerRe: Win32 Menu bitmaps Pin
pasztorpisti18-Aug-13 4:36
pasztorpisti18-Aug-13 4:36 
GeneralRe: Win32 Menu bitmaps Pin
Jonathan Davies18-Aug-13 5:05
Jonathan Davies18-Aug-13 5:05 
GeneralRe: Win32 Menu bitmaps Pin
pasztorpisti18-Aug-13 5:27
pasztorpisti18-Aug-13 5:27 
GeneralRe: Win32 Menu bitmaps Pin
Jonathan Davies18-Aug-13 5:40
Jonathan Davies18-Aug-13 5:40 
GeneralRe: Win32 Menu bitmaps Pin
pasztorpisti18-Aug-13 5:43
pasztorpisti18-Aug-13 5:43 
QuestionUDP sockets - not getting FD_READ after some time of activity on a socket Pin
csrss17-Aug-13 6:28
csrss17-Aug-13 6:28 
SuggestionRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
pasztorpisti17-Aug-13 7:01
pasztorpisti17-Aug-13 7:01 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
csrss17-Aug-13 7:45
csrss17-Aug-13 7:45 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
pasztorpisti17-Aug-13 8:16
pasztorpisti17-Aug-13 8:16 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
csrss17-Aug-13 8:48
csrss17-Aug-13 8:48 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
pasztorpisti17-Aug-13 8:53
pasztorpisti17-Aug-13 8:53 
QuestionDirectX hierarchy - who is on first? Pin
Vaclav_17-Aug-13 3:07
Vaclav_17-Aug-13 3:07 
AnswerRe: DirectX hierarchy - who is on first? Pin
Richard MacCutchan17-Aug-13 5:45
mveRichard MacCutchan17-Aug-13 5:45 
AnswerRe: DirectX hierarchy - who is on first? SOLVED Pin
Vaclav_17-Aug-13 18:12
Vaclav_17-Aug-13 18:12 
Questionerror -1.#IND00 in vc++2010 Pin
yahya7716-Aug-13 5:40
yahya7716-Aug-13 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.