hi there, i am trying to get my program to display a different bitmap in four different child windows of my win32 C program but i cant seem to do it. Any idea's? I have got the information so far off of the forgers win32 tutorial.

#include <windows.h>
#include <commctrl.h>
#include "resource.h"
const char g_szClassName[] = "myWindowClass";
const char g_szChildClassName[] = "myMDIChildWindowClass";
HBITMAP g_hbmBall = NULL;
HWND g_hMDIClient = NULL;
HWND g_hMainWindow = NULL;
BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch(Message)
	{
		case WM_INITDIALOG:
		return TRUE;
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDOK:
					EndDialog(hwnd, IDOK);
				break;
				case IDCANCEL:
					EndDialog(hwnd, IDCANCEL);
				break;
			}
		break;
		default:
			return FALSE;
	}
	return TRUE;
}
//////////////////////////////////////////////////////////////////?/////////Default Child Window Class/////////////////
////////////////////////////////////////////////////
/////////Default Child Window Class/////////////////
////////////////////////////////////////////////////
HWND CreateNewMDIChild(HWND hMDIClient)
{
 MDICREATESTRUCT mcs;
 HWND hChild;
 mcs.szTitle = "test";
 mcs.szClass = g_szChildClassName;
 mcs.hOwner  = GetModuleHandle(NULL);
 mcs.x = mcs.cx = CW_USEDEFAULT;
 mcs.y = mcs.cy = CW_USEDEFAULT;
 mcs.style = MDIS_ALLCHILDSTYLES;
 hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
 if(!hChild)
 {
  MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
   MB_ICONEXCLAMATION | MB_OK);
 }
 return hChild;
}
/////////KEY GENERATION Child Window Class/////////////////
////////////////////////////////////////////////////
HWND CreateNewMDIChildkey(HWND hMDIClient)
{
 MDICREATESTRUCT mcs;
 HWND hChild;
 mcs.szTitle = "Pseudo Key Generation";
 mcs.szClass = g_szChildClassName;
 mcs.hOwner  = GetModuleHandle(NULL);
 mcs.x = mcs.cx = CW_USEDEFAULT;
 mcs.y = mcs.cy = CW_USEDEFAULT;
 mcs.style = MDIS_ALLCHILDSTYLES;
 hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
 if(!hChild)
 {
  MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
   MB_ICONEXCLAMATION | MB_OK);
 }
 return hChild;
}
/////////CTAK Child Window Class/////////////////
////////////////////////////////////////////////////
HWND CreateNewMDIChildctak(HWND hMDIClient)
{
 MDICREATESTRUCT mcs;
 HWND hChild;
 mcs.szTitle = "CTAK Key Distribution";
 mcs.szClass = g_szChildClassName;
 mcs.hOwner  = GetModuleHandle(NULL);
 mcs.x = mcs.cx = CW_USEDEFAULT;
 mcs.y = mcs.cy = CW_USEDEFAULT;
 mcs.style = MDIS_ALLCHILDSTYLES;
 hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
 if(!hChild)
 {
  MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
   MB_ICONEXCLAMATION | MB_OK);
 }
 return hChild;
}
/////////KAK Child Window Class/////////////////
////////////////////////////////////////////////////
HWND CreateNewMDIChildkak(HWND hMDIClient)
{
 MDICREATESTRUCT mcs;
 HWND hChild;
 mcs.szTitle = "KAK Key Distribution";
 mcs.szClass = g_szChildClassName;
 mcs.hOwner  = GetModuleHandle(NULL);
 mcs.x = mcs.cx = CW_USEDEFAULT;
 mcs.y = mcs.cy = CW_USEDEFAULT;
 mcs.style = MDIS_ALLCHILDSTYLES;
 hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
 if(!hChild)
 {
  MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
   MB_ICONEXCLAMATION | MB_OK);
 }
 return hChild;
}
/////////FULL ENCRYPTION Child Window Class/////////////////
////////////////////////////////////////////////////
HWND CreateNewMDIChildcryp(HWND hMDIClient)
{
 MDICREATESTRUCT mcs;
 HWND hChild;
 mcs.szTitle = "Full Symmetric Encryption";
 mcs.szClass = g_szChildClassName;
 mcs.hOwner  = GetModuleHandle(NULL);
 mcs.x = mcs.cx = CW_USEDEFAULT;
 mcs.y = mcs.cy = CW_USEDEFAULT;
 mcs.style = MDIS_ALLCHILDSTYLES;
 hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
  
 if(!hChild)
 {
  MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
   MB_ICONEXCLAMATION | MB_OK);
 }
 return hChild;
}
/////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
 switch(msg)
 {
  case WM_CREATE:
  {   
   HWND hTool;
   TBBUTTON tbb[4];
   TBADDBITMAP tbab;
   HWND hStatus;
   int statwidths[] = {100, -1};
   CLIENTCREATESTRUCT ccs;
   // Create MDI Client
   // Find window menu where children will be listed
   ccs.hWindowMenu  = GetSubMenu(GetMenu(hwnd), 2);
   ccs.idFirstChild = ID_MDI_FIRSTCHILD;
   g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL,
	WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
	CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
	hwnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);
   if(g_hMDIClient == NULL)
	MessageBox(hwnd, "Could not create MDI client.", "Error", MB_OK | MB_ICONERROR);
   // Create Toolbar
   hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
	hwnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
   if(hTool == NULL)
	MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);
   // Send the TB_BUTTONSTRUCTSIZE message, which is required for
   // backward compatibility.
   SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
   
   tbab.hInst = HINST_COMMCTRL;
   tbab.nID = IDB_STD_SMALL_COLOR;
   SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);
///////////MENU BUTTONS ALONG THE TOP///////////////
   /////////////////////////
   ZeroMemory(tbb, sizeof(tbb));
   tbb[0].iBitmap = "NULL";
   tbb[0].iString = "Key Generation";
   tbb[0].fsState = TBSTATE_ENABLED;
   tbb[0].fsStyle = TBSTYLE_BUTTON;
   
   tbb[0].idCommand = ID_MENU_KEYGENERATION;
   tbb[1].iBitmap = "NULL";
   tbb[1].iString = "CTAK Distribution";
   tbb[1].fsState = TBSTATE_ENABLED;
   tbb[1].fsStyle = TBSTYLE_BUTTON;
   tbb[1].idCommand = ID_MENU_CTAKKEYDISTRIBUTION;
   tbb[2].iBitmap = "NULL";
   tbb[2].iString = "KAK Distribution";
   tbb[2].fsState = TBSTATE_ENABLED;
   tbb[2].fsStyle = TBSTYLE_BUTTON;
   tbb[2].idCommand = ID_MENU_KAKKEYDISTRIBUTION;
   tbb[3].iBitmap = "NULL";
   tbb[3].iString = "Full Encryption";
   tbb[3].fsState = TBSTATE_ENABLED;
   tbb[3].fsStyle = TBSTYLE_BUTTON;
   tbb[3].idCommand = ID_MENU_FULLSYMMETRICENCRYPTION;   
   
   SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
   // Create Status bar
   hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
	WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
	hwnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL);
   SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
   SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"160285");
  }
 break;
  case WM_SIZE:
  {
   HWND hTool;
   RECT rcTool;
   int iToolHeight;
   HWND hStatus;
   RECT rcStatus;
   int iStatusHeight;
   HWND hMDI;
   int iMDIHeight;
   RECT rcClient;
   // Size toolbar and get height
   hTool = GetDlgItem(hwnd, IDC_MAIN_TOOL);
   SendMessage(hTool, TB_AUTOSIZE, 0, 0);
   GetWindowRect(hTool, &rcTool);
   iToolHeight = rcTool.bottom - rcTool.top;
   // Size status bar and get height
   hStatus = GetDlgItem(hwnd, IDC_MAIN_STATUS);
   SendMessage(hStatus, WM_SIZE, 0, 0);
   GetWindowRect(hStatus, &rcStatus);
   iStatusHeight = rcStatus.bottom - rcStatus.top;
   // Calculate remaining height and size edit
   GetClientRect(hwnd, &rcClient);
   iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
   hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI);
   SetWindowPos(hMDI, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);
  }
  break;
  case WM_CLOSE:
   DestroyWindow(hwnd);
  break;
  case WM_DESTROY:
   PostQuitMessage(0);
  break;
////////////////////////////////
///////MAIN WINDOW CASES////////
////////////////////////////////
  case WM_COMMAND:
   switch(LOWORD(wParam))
   {
///////ABOUT CASE/////////////	
	case ID_HELP_ABOUT:
	{
	 int ret = DialogBox(GetModuleHandle(NULL), 
	  MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
	 if(ret == -1){
	  MessageBox(hwnd, "Dialog failed!", "Error",
	   MB_OK | MB_ICONINFORMATION);
	 }
	}
	break;
///////KEY GENERATION CASE///////////// 
	case ID_MENU_KEYGENERATION:
	 CreateNewMDIChildkey(g_hMDIClient);
	break;
///////CTAK KEY DISTRIBUTION CASE///////////// 
	case ID_MENU_CTAKKEYDISTRIBUTION:
	 CreateNewMDIChildctak(g_hMDIClient);
	break;
///////KAK KEY DISTRIBUTION CASE///////////// 
	case ID_MENU_KAKKEYDISTRIBUTION:
	 CreateNewMDIChildkak(g_hMDIClient);
	break;
///////FULL SYMMETRIC ENCRYPTION CASE///////////// 
	case ID_MENU_FULLSYMMETRICENCRYPTION:
	 CreateNewMDIChildcryp(g_hMDIClient);
	break;
	case ID_FILE_EXIT:
	 PostMessage(hwnd, WM_CLOSE, 0, 0);
	break;
   
	case ID_FILE_CLOSE:
	{
	 HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
	 if(hChild)
	 {
	  SendMessage(hChild, WM_CLOSE, 0, 0);
	 }
	}
	break;
	case ID_WINDOW_TILE:
	 SendMessage(g_hMDIClient, WM_MDITILE, 0, 0);
	break;
	case ID_WINDOW_CASCADE:
	 SendMessage(g_hMDIClient, WM_MDICASCADE, 0, 0);
	break;
	default:
	{
	 if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
	 {
	  DefFrameProc(hwnd, g_hMDIClient, WM_COMMAND, wParam, lParam);
	 }
	 else 
	 {
	  HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
	  if(hChild)
	  {
	   SendMessage(hChild, WM_COMMAND, wParam, lParam);
	  }
	 }
	}
   }
  break;
  default:
   return DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
 }
 return 0;
}
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
 switch(msg)
 {
  case WM_CREATE:
  {
   
   HFONT hfDefault;
   HWND hEdit;
   // Create Edit Control
   hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
	WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 
	0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL);
   if(hEdit == NULL)
	MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
   hfDefault = GetStockObject(DEFAULT_GUI_FONT);
   SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
   
   g_hbmBall = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BALL));
  }		
  break;
 case WM_PAINT:
	{
		BITMAP bm;
		PAINTSTRUCT ps;
		HDC hdc = BeginPaint(hwnd, &ps);
		HDC hdcMem = CreateCompatibleDC(hdc);
		HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall);
		GetObject(g_hbmBall, sizeof(bm), &bm);
		BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
		SelectObject(hdcMem, hbmOld);
		DeleteDC(hdcMem);
		EndPaint(hwnd, &ps);
	}
	break;
 case WM_DESTROY:
		DeleteObject(g_hbmBall);
		PostQuitMessage(0);
	break;
  case WM_MDIACTIVATE:
  {
   HMENU hMenu, hFileMenu;
   UINT EnableFlag;
   hMenu = GetMenu(g_hMainWindow);
   if(hwnd == (HWND)lParam)
   {	//being activated, enable the menus
	EnableFlag = MF_ENABLED;
   }   
   EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag);
   EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag);
   hFileMenu = GetSubMenu(hMenu, 0);
   EnableMenuItem(hFileMenu, ID_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag);
   EnableMenuItem(hFileMenu, ID_FILE_CLOSE, MF_BYCOMMAND | EnableFlag);
   EnableMenuItem(hFileMenu, ID_FILE_CLOSEALL, MF_BYCOMMAND | EnableFlag);
   DrawMenuBar(g_hMainWindow);
  }
  break;
///////WINDOW COMMANDS//////////
  case WM_COMMAND:
   switch(LOWORD(wParam))
   {
///////EXIT CASE///////////// 
	case ID_FILE_EXIT:
	 PostMessage(hwnd, WM_CLOSE, 0, 0);
	break;
  }
  break;
///////RESIZING THE WINDOW////////////
  case WM_SIZE:
  {
   HWND hEdit;
   RECT rcClient;
   // Calculate remaining height and size edit
   GetClientRect(hwnd, &rcClient);
   hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
   SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
  }
  return DefMDIChildProc(hwnd, msg, wParam, lParam);
  default:
   return DefMDIChildProc(hwnd, msg, wParam, lParam);
 
 }
 return 0;
}
BOOL SetUpMDIChildWindowClass(HINSTANCE hInstance)
{
 WNDCLASSEX wc;
 wc.cbSize   = sizeof(WNDCLASSEX);
 wc.style   = CS_HREDRAW | CS_VREDRAW;
 wc.lpfnWndProc  = MDIChildWndProc;
 wc.cbClsExtra  = 0;
 wc.cbWndExtra  = 0;
 wc.hInstance  = hInstance;
 wc.hIcon   = LoadIcon(NULL, IDI_APPLICATION);
 wc.hCursor   = LoadCursor(NULL, IDC_ARROW);
 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
 wc.lpszMenuName  = NULL;
 wc.lpszClassName = g_szChildClassName;
 wc.hIconSm   = LoadIcon(NULL, IDI_APPLICATION);
 if(!RegisterClassEx(&wc))
 {
  MessageBox(0, "Could Not Register Child Window", "Oh Oh...",
   MB_ICONEXCLAMATION | MB_OK);
  return FALSE;
 }
 else
  return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
 LPSTR lpCmdLine, int nCmdShow)
{
 WNDCLASSEX wc;
 HWND hwnd;
 MSG Msg;
 InitCommonControls();
 wc.cbSize   = sizeof(WNDCLASSEX);
 wc.style   = 0;
 wc.lpfnWndProc  = WndProc;
 wc.cbClsExtra  = 0;
 wc.cbWndExtra  = 0;
 wc.hInstance  = hInstance;
 wc.hIcon   = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
	wc.hIconSm   = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0);
 wc.hCursor   = LoadCursor(NULL, IDC_ARROW);
 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
 wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MAINMENU);
 wc.lpszClassName = g_szClassName;
 wc.hIconSm   = LoadIcon(NULL, IDI_APPLICATION);
 if(!RegisterClassEx(&wc))
 {
  MessageBox(NULL, "Window Registration Failed!", "Error!",
   MB_ICONEXCLAMATION | MB_OK);
  return 0;
 }
 if(!SetUpMDIChildWindowClass(hInstance))
  return 0;
 hwnd = CreateWindowEx(
  0,
  g_szClassName,
  "The Symmetric Encryption Tutorial with CTAK & KAK",
  WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
  CW_USEDEFAULT, CW_USEDEFAULT, 480, 320,
  NULL, NULL, hInstance, NULL);
 if(hwnd == NULL)
 {
  MessageBox(NULL, "Window Creation Failed!", "Error!",
   MB_ICONEXCLAMATION | MB_OK);
  return 0;
 }
 g_hMainWindow = hwnd;
 ShowWindow(hwnd, nCmdShow);
 UpdateWindow(hwnd);
 while(GetMessage(&Msg, NULL, 0, 0) > 0)
 {
  if (!TranslateMDISysAccel(g_hMDIClient, &Msg))
  {
   TranslateMessage(&Msg);
   DispatchMessage(&Msg);
  }
 }
 return Msg.wParam;
}

Any idea's?? any help will be gratefully received.

thanks to those who looked over my question, but i have solved it now.

Can you post your fix so that perhaps it might be able to help others in the future?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.