Switching from console application to GUI application loses custom icon

Hi
Has anyone experienced or solved the issue?

When you switch the build target -> type from Console application to GUI application then the icon doesnt get loaded anymore. Well the custom icon of the exe file in the windows explorer is still there, but the custom icon in the taskbar is gone.

I want to switch to GUI application to get rid of the cmd window.
Any ideas why the custom icon in the taskbar disappears?
jakob

Codeblocks 13.12
of v0.8.1
win7

I’m not sure about why that is (perhaps there’s a different way to set the icons up for gui applications?), but here’s some alternative ways to hide the console:

alternatively, something like this might help?

ShowWindow (GetConsoleWindow(), SW_HIDE);

@zach
You are probably right, that it must be implemented differently. Thanks for the alternative. I guess I will go with that for now :slight_smile:

this is working, thanks!

For me the icon was still not working after this. But I managed to fix it like this:

I changed the SubSystem to Windows, and my main function into this:

#include "ofMain.h"
#include "ofApp.h"
#include "../resource.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
	
	ofSetupOpenGL(1280, 720,OF_WINDOW);
	
	HWND hwnd = ofGetWin32Window();  
	HICON hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(MAIN_ICON));
	SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hMyIcon);

	ofRunApp(new ofApp());

}

This fixes both the icon and console window problem :slightly_smiling:

3 Likes