I found a cpp source code to change the icon of the MDI parent. I use it related to change company (library list) by user selection. And it works when I had full path to icon object. But I need to reset to orginal icon f.i. when company record has an empty value in path for icon.
CWnd *pWnd = ObPanelAPI::GetPanelCWndByName("*Current");
if (pWnd){
// loads from file
HICON hIcon = (HICON)LoadImage(0, &(1:), IMAGE_ICON, 0 , 0 ,LR_DEFAULTSIZE|LR_LOADFROMFILE);
// TODO: Set orginal icon if LoadImage returns NULL
if(hIcon) {
// send the message to frame to update icon
HICON hPrevIcon = (HICON) pWnd->SetIcon(hIcon,FALSE);
if(hPrevIcon) {
// Free the previous icon resource
DestroyIcon(hPrevIcon);
}
}
}
But I cant find out how to get the orginal icon from the EXE object f.i. OBicon.ico.
Last try was like this:
CWnd *pWnd = ObPanelAPI::GetPanelCWndByName("*Current");
if (pWnd){
// loads from file
HICON hIcon = (HICON)LoadImage(0, &(1:), IMAGE_ICON, 0 , 0 ,LR_DEFAULTSIZE|LR_LOADFROMFILE);
if (!hIcon) {
HICON hIcon = AfxGetApp()->LoadIcon(128);
// eða ef IDE_MAINFRAME finnst ekki HICON hIcon = AfxGetApp()->LoadIcon(128);
if (!hIcon)
MessageBox(NULL,"from Exe in error","msg1", MB_OK);
}
if(hIcon) {
// send the message to frame to update icon
HICON hPrevIcon = (HICON) pWnd->SetIcon(hIcon,FALSE);
if(hPrevIcon) {
// Free the previous icon resource
DestroyIcon(hPrevIcon);
}
}
}