Click here to Skip to main content
15,921,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: hotkeys on a dialog Pin
Qadddd24-Feb-03 6:55
Qadddd24-Feb-03 6:55 
GeneralRe: hotkeys on a dialog Pin
Iain Clarke, Warrior Programmer25-Feb-03 0:41
Iain Clarke, Warrior Programmer25-Feb-03 0:41 
GeneralRe: hotkeys on a dialog Pin
Qadddd26-Feb-03 23:20
Qadddd26-Feb-03 23:20 
GeneralPort forwarding Pin
User 988520-Feb-03 4:59
User 988520-Feb-03 4:59 
GeneralRe: Port forwarding Pin
User 988520-Feb-03 5:10
User 988520-Feb-03 5:10 
GeneralRe: Port forwarding Pin
Anonymous20-Feb-03 10:01
Anonymous20-Feb-03 10:01 
GeneralRe: Port forwarding Pin
User 988520-Feb-03 10:12
User 988520-Feb-03 10:12 
GeneralRe: Port forwarding Pin
User 988520-Feb-03 10:13
User 988520-Feb-03 10:13 
GeneralSlider control Pin
jimNLX20-Feb-03 4:35
jimNLX20-Feb-03 4:35 
GeneralRe: Slider control Pin
valikac20-Feb-03 7:32
valikac20-Feb-03 7:32 
GeneralDeriving MFC Class for DLL, instantiating in Visual Basic Pin
DigitalSabre20-Feb-03 4:31
DigitalSabre20-Feb-03 4:31 
GeneralRe: Deriving MFC Class for DLL, instantiating in Visual Basic Pin
Anna-Jayne Metcalfe20-Feb-03 4:53
Anna-Jayne Metcalfe20-Feb-03 4:53 
Generalget keyboard events Pin
Willem B20-Feb-03 4:21
Willem B20-Feb-03 4:21 
GeneralRe: get keyboard events Pin
Michael Shuster20-Feb-03 4:50
Michael Shuster20-Feb-03 4:50 
GeneralRe: get keyboard events Pin
HENDRIK R20-Feb-03 4:52
HENDRIK R20-Feb-03 4:52 
GeneralRe: get keyboard events Pin
Willem B20-Feb-03 21:11
Willem B20-Feb-03 21:11 
GeneralGetting focus for modeless dialogs in a controlbar. Pin
Maximilien20-Feb-03 4:17
Maximilien20-Feb-03 4:17 
GeneralProb converting Hex to CString Pin
afender20-Feb-03 4:14
afender20-Feb-03 4:14 
GeneralRe: Prob converting Hex to CString Pin
Ryan_Roberts20-Feb-03 4:26
Ryan_Roberts20-Feb-03 4:26 
GeneralRe: Prob converting Hex to CString Pin
afender20-Feb-03 5:26
afender20-Feb-03 5:26 
GeneralRe: Prob converting Hex to CString Pin
David Chamberlain20-Feb-03 6:05
David Chamberlain20-Feb-03 6:05 
GeneralRe: Prob converting Hex to CString Pin
Ted Ferenc20-Feb-03 6:16
Ted Ferenc20-Feb-03 6:16 
GeneralRe: Prob converting Hex to CString Pin
Michael Dunn20-Feb-03 7:23
sitebuilderMichael Dunn20-Feb-03 7:23 
GeneralRe: Prob converting Hex to CString Pin
afender20-Feb-03 20:15
afender20-Feb-03 20:15 
GeneralDrawing icons on a toolbar Pin
Ron Olson20-Feb-03 4:02
Ron Olson20-Feb-03 4:02 
Hi all-

I'm completely stuck. I am trying to dynamically set buttons on a CToolbar object using SetBitmap() via a memory dc. The code I have is below:

// begin code block
void CBitmap_toolbar2View::OnInitialUpdate()
{
CWindowDC dc(this);
CDC memdc;
memdc.CreateCompatibleDC(&dc);

CBitmap bm;
VERIFY(bm.LoadBitmap(IDR_MAINFRAME));
CBitmap *poldbm = memdc.SelectObject(&bm);

// draw into the dc/bitmap
CBrush brush;
brush.CreateSysColorBrush(COLOR_BTNFACE);
HICON theIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ENTRY), IMAGE_ICON, 0,
0,
LR_DEFAULTCOLOR);
VERIFY(::DrawIconEx(memdc,
0,
0, // dc, x, y
theIcon, // HICON (first small one)
GetSystemMetrics(SM_CXICON), // cx
GetSystemMetrics(SM_CYICON), // cy
0,
brush,
DI_NORMAL)); // frame, brush, flags

DestroyIcon(theIcon);

theIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ORDER),
IMAGE_ICON,
0,
0,
LR_DEFAULTCOLOR);

VERIFY(::DrawIconEx(memdc,
32,
0, // dc, x, y
theIcon, // HICON (first small one)
GetSystemMetrics(SM_CXICON), // cx
GetSystemMetrics(SM_CYICON), // cy
0,
brush,
DI_NORMAL)); // frame, brush, flags

memdc.SelectObject(poldbm);
((CMainFrame*)GetParentFrame())->m_wndToolBar.SetBitmap((HBITMAP)bm.Detach());
((CMainFrame*)GetParentFrame())->m_wndToolBar.Invalidate(TRUE);
((CMainFrame*)GetParentFrame())->m_wndToolBar.SetButtons(NULL,2);
}
//// end of code block

I made the toolbar in the frame public just to make it easier to play with.

So I have two icons that I want to set on the toolbar. The two calls to DrawIconEx() sets the first icon at 0,0 and the second one at 32,0 but what I see is the first icon twice. I have zero clue as to why I should see the first icon twice, especially when I call DestroyIcon() between DrawIconEx() and LoadImage() for the second icon.

Any help would be appreciated, this is something of a showstopper and I have no way of getting around it right now. Frown | :(

Ron

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.