after trying for a while to disable the (ugly) console that pops out on windows I’d like to share what I have found to work. Not the hardest thing in the universe, of course, but it may be useful to someone else.
First of all you need to change visual studio linker setting to instruct it to generate a windows app instead of a console one:
Right click on your app name in solution explorer, then choose Properties > Linker > System > Subsystem
and set it to “Windows (/SUBSYSTEM:WINDOWS)”
int main()entry point to
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
Now your app should start without console but the icon will not be set.
Right click again on app name in solution explorer and choose Add -> Resource -> Icon and click on “import” (you should have a .ico file ready) or on “new” if you want to use the VS embedded icon editor
in your main.cpp add a #include “…/resource.h” and after the ofSetupOpenGL() and before the ofRunApp() call add this code:
HWND hwnd = ofGetWin32Window();
HICON hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hMyIcon);
IDI_ICON1 is a numerical value (usually 101) defined in resource.h (byVS, it is wise to leave it as it is)