BitMaps in the console

Before anyone says anything:
YES this is very out-dated code

YES i am aware that there are MUCH easier ways of doing this

and YES i am aware that the console was not made for images,
HOWEVER it is for a school project and we are being required
to do this.

now, with that said here is my dilemma:

I have, after much searching and prodding over the web, found the code for loading a bitmap image into the console, and with a bit of tweaking i have turned it into a function that i can simply call from anywhere, and give it a few parameters to work with. This is my simple adaption of the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// put a bitmap image on a Windows Console display
// BCX basic original by Joe Caverly and Kevin Diggins
// BCX generated C code modified for PellesC/Dev-C++

#include <iostream>
#include <stdio.h>
#include <string.h>
#ifdef UNICODE
#undef UNICODE
#endif
#include <windows.h>    // Win32Api Header File
#include "ResourceFunctions.h"


using namespace std;

static HWND  hConWnd;

HWND BCX_Bitmap(char*,HWND=0,int=0,int=0,int=0,int=0,int=0,int=0,int=0,int=0);
HWND GetConsoleWndHandle(void);


void BitImage(string file, int x, int y, int z)
{

char * writable = new char[file.size() + 1];
copy(file.begin(), file.end(), writable);
writable[file.size()] = '\0';


  hConWnd = GetConsoleWndHandle();
  if (hConWnd)
  {
    // select a bitmap file you have or use one of the files in the Windows folder
    // filename, handle, ID, ulcX, ulcY, width, height   0,0 auto-adjusts
	  BCX_Bitmap(writable,hConWnd,x,y,z,0,0);
  }
  delete[] writable;
}


// draw the bitmap
HWND BCX_Bitmap(char* Text,HWND hWnd,int id,int X,int Y,int W,int H,int Res,int Style,int Exstyle)
{
  HWND A;
  HBITMAP hBitmap;

  // set default style
  if (!Style) Style = WS_CLIPSIBLINGS|WS_CHILD|WS_VISIBLE|SS_BITMAP|WS_TABSTOP;

  // form for <strong class="highlight">the</strong> image
  A = CreateWindowEx(Exstyle,"static",NULL,Style,X,Y,0,0,hWnd,(HMENU)id,GetModuleHandle(0),NULL);

  // Text contains filename
  hBitmap=(HBITMAP)LoadImage(0,Text,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);

  // auto-adjust width and height
  if (W || H) hBitmap = (HBITMAP)CopyImage(hBitmap,IMAGE_BITMAP,W,H,LR_COPYRETURNORG);
  SendMessage(A,(UINT)STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBitmap);
  if (W || H) SetWindowPos(A,HWND_TOP,X,Y,W,H,SWP_DRAWFRAME);
  return A;
}


// tricking Windows just a little ...
HWND GetConsoleWndHandle(void)
{
  HWND hConWnd;
  OSVERSIONINFO os;
  char szTempTitle[64], szClassName[128], szOriginalTitle[1024];

  os.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
  GetVersionEx( &os );
  // may not work on WIN9x
  if ( os.dwPlatformId == VER_PLATFORM_WIN32s ) return 0;

  GetConsoleTitle( szOriginalTitle, sizeof ( szOriginalTitle ) );
  sprintf( szTempTitle,"%u - %u", GetTickCount(), GetCurrentProcessId() );
  SetConsoleTitle( szTempTitle );
  Sleep( 40 );
  // handle for NT and XP
  hConWnd = FindWindow( NULL, szTempTitle );
  SetConsoleTitle( szOriginalTitle );

  // may not work on WIN9x
  if ( os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
  {
    hConWnd = GetWindow( hConWnd, GW_CHILD );
    if ( hConWnd == NULL ) return 0;
    GetClassName( hConWnd, szClassName, sizeof ( szClassName ) );
    // while ( _stricmp( szClassName, "ttyGrab" ) != 0 )
    while ( strcmp( szClassName, "ttyGrab" ) != 0 )
    {
      hConWnd = GetNextWindow( hConWnd, GW_HWNDNEXT );
      if ( hConWnd == NULL ) return 0;
      GetClassName( hConWnd, szClassName, sizeof( szClassName ) );
    }
  }
  return hConWnd;
}

anyone interested in seeing the original code, look in this post: http://www.cplusplus.com/forum/beginner/34500/

The problem i'm having is that it seems i can only use this to load a single image. Even if i give the new image a new ID (being int x) and give it a new coordiante position in the console.
Now admitadly i have little to no understanding of how this code actually works, so I'm hoping someone who sees this does and will be able to answer my question.

Long story short : can i use this code to be able to load multiple bitmap images? If so, how?
Topic archived. No new replies allowed.