Main Window Icon loading
-
Hi. Usual question. How can I load an Icon into my main MFC window. I already searched on this web site for answers but obviously they won't work for me. I tried several differnt ways: I then tried this : BOOL CMyAppView::PreCreateWindow(CREATESTRUCT& cs) { if (!CWnd::PreCreateWindow(cs)) return FALSE; m_hIconFrame = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), m_hIconFrame ); return TRUE; } Then I tried : in MyApp::InitInstance() { AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); <--- this wont work CWinApp::LoadIcon(IDR_MAINFRAME ); <------------------------- this wont work too m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); } Then I tried in int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct). Still no luck.. However same function call ie. AfxGetApp()->LoadIcon(IDR_MAINFRAME); in my dialog class displays the bloody icon ok. what is going on? Why can't I see this icon in my main window caption bar? ARGH.... Can somebody help please. thank you.
-
Hi. Usual question. How can I load an Icon into my main MFC window. I already searched on this web site for answers but obviously they won't work for me. I tried several differnt ways: I then tried this : BOOL CMyAppView::PreCreateWindow(CREATESTRUCT& cs) { if (!CWnd::PreCreateWindow(cs)) return FALSE; m_hIconFrame = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), m_hIconFrame ); return TRUE; } Then I tried : in MyApp::InitInstance() { AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); <--- this wont work CWinApp::LoadIcon(IDR_MAINFRAME ); <------------------------- this wont work too m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); } Then I tried in int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct). Still no luck.. However same function call ie. AfxGetApp()->LoadIcon(IDR_MAINFRAME); in my dialog class displays the bloody icon ok. what is going on? Why can't I see this icon in my main window caption bar? ARGH.... Can somebody help please. thank you.
I'm pretty sure you just need to add an icon as a resource and then name it: IDR_MAINFRAME Then when you create the mainframe it should be there. I don't think you need to manually load. Look here to help out in MFC: http://www.adminmod.org/karel/2/index.htm
-
Hi. Usual question. How can I load an Icon into my main MFC window. I already searched on this web site for answers but obviously they won't work for me. I tried several differnt ways: I then tried this : BOOL CMyAppView::PreCreateWindow(CREATESTRUCT& cs) { if (!CWnd::PreCreateWindow(cs)) return FALSE; m_hIconFrame = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), m_hIconFrame ); return TRUE; } Then I tried : in MyApp::InitInstance() { AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); <--- this wont work CWinApp::LoadIcon(IDR_MAINFRAME ); <------------------------- this wont work too m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); } Then I tried in int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct). Still no luck.. However same function call ie. AfxGetApp()->LoadIcon(IDR_MAINFRAME); in my dialog class displays the bloody icon ok. what is going on? Why can't I see this icon in my main window caption bar? ARGH.... Can somebody help please. thank you.
-
Hi. Usual question. How can I load an Icon into my main MFC window. I already searched on this web site for answers but obviously they won't work for me. I tried several differnt ways: I then tried this : BOOL CMyAppView::PreCreateWindow(CREATESTRUCT& cs) { if (!CWnd::PreCreateWindow(cs)) return FALSE; m_hIconFrame = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), m_hIconFrame ); return TRUE; } Then I tried : in MyApp::InitInstance() { AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME)); <--- this wont work CWinApp::LoadIcon(IDR_MAINFRAME ); <------------------------- this wont work too m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); } Then I tried in int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct). Still no luck.. However same function call ie. AfxGetApp()->LoadIcon(IDR_MAINFRAME); in my dialog class displays the bloody icon ok. what is going on? Why can't I see this icon in my main window caption bar? ARGH.... Can somebody help please. thank you.