Define a custom icon on the console

0

Hello, I wanted to change the icon that appears on the console. For this, I created 3 files:

  • resource.rc
  • resource.h
  • main.cpp

The contents of each file are as follows:

  

resource.rc :

#include "resource.h"
IDI_MYICON ICON "icon.png"
  

resource.h :

#ifndef __RESOURCE_H_INCLUDED__
#define __RESOURCE_H_INCLUDED__
#define IDI_MYICON 101
#endif // __RESOURCE_H_INCLUDED__
  

main.cpp :

#include <windows.h>
#include <iostream>
#include "unistd.h"
#include "resource.h"

int main(int argc, char const *argv[]) {
    HICON hIcon1;   // icon handle 
    hIcon1 = LoadIconA(
      NULL,
      MAKEINTRESOURCE(101)
    ); 
    HDC hdc;        // handle to display context 

    DrawIcon(hdc, 10, 20, hIcon1); 

    sleep(5);
    return 0;
}

But this code does absolutely nothing, does anyone know the reason? If it were possible, could you give me an example?

I use windows 7 with mingw without Visual Studio.

    
asked by anonymous 10.07.2018 / 16:02

0 answers