LRESULT CALLBACK MainWindowHandler (HWND w_handle, UINT message, WPARAM w_param,
																		LPARAM l_param)
{
  int wm_id, wm_event ;
	HWND main_dialog, cband_handle ;


	HIMAGELIST image_list ;
	HBITMAP bitmaps ;
	REBARBANDINFO rbi[1];
	HWND band_handle ;
	int i ;
	BOOL foo ;

  wm_id    = LOWORD (w_param) ;
  wm_event = HIWORD (w_param) ;

  switch (message) {
		  case WM_CREATE:
				main_dialog = CreateDialog (app_instance_handle,
					MAKEINTRESOURCE(IDD_DIALOG_MAIN), w_handle, (DLGPROC) MainDlgHandler) ;
				// Init global references on the listbox used to display results
				// and on the edit used to get the user's request
				result_listbox_hd = GetDlgItem (main_dialog, IDC_LIST_MAIN) ;
				main_edit_hd = GetDlgItem (main_dialog, IDC_EDIT_MAIN) ;
				// Add the command bar.
				// cb_handle = CommandBar_Create (app_instance_handle, w_handle, 1000) ;



				image_list = ImageList_Create (16, 16, ILC_COLOR, 2, 0) ;
				bitmaps = LoadBitmap (app_instance_handle, TEXT ("IDBBITMAPCBAND")) ;
				ImageList_Add (image_list, bitmaps, NULL) ;
				DeleteObject (bitmaps) ;
				cband_handle = CommandBands_Create (app_instance_handle, w_handle, 10001,
					RBS_SMARTLABELS|RBS_VARHEIGHT, image_list) ;
		    // Initialize common REBARBANDINFO structure fields.
				for (i = 0; i < 1; i++) {
					rbi[i].cbSize = sizeof (REBARBANDINFO);
					rbi[i].fMask = RBBIM_ID | RBBIM_IMAGE | RBBIM_SIZE | RBBIM_STYLE ;
					rbi[i].fStyle = RBBS_GRIPPERALWAYS ;
					rbi[i].wID = 10001 + i ;
				}

				// Initialize REBARBANDINFO structure for each band.
				// 2. Standard button band
				rbi[0].fMask |= RBBIM_TEXT ;
				rbi[0].cx = 200 ;
				rbi[0].iImage = 0 ;
				rbi[0].lpText = TEXT ("Std Btns") ;

				// Add bands.
				foo = CommandBands_AddBands (cband_handle, app_instance_handle, 1, rbi) ;

				// Add standard buttons to second band.
				band_handle = CommandBands_GetCommandBar (cband_handle, 0);
				// Insert buttons
				CommandBar_AddBitmap (band_handle, HINST_COMMCTRL, IDB_STD_SMALL_COLOR,	16, 0, 0) ;
				CommandBar_AddButtons (band_handle, 2, cb_buttons_def) ;
				CommandBands_AddAdornments (cband_handle, app_instance_handle, 0, NULL);


				// CommandBar_AddBitmap (cb_handle, HINST_COMMCTRL, IDB_STD_SMALL_COLOR, 2, 0, 0) ;
				// CommandBar_AddButtons (cb_handle, 2, cb_buttons_def) ;
				// Set the current action by default to SEARCH.
				current_action = ACTION_SEARCH ;
				MoveWindow (main_dialog, 0, 50, 240, 300, FALSE) ;
				ShowWindow (main_dialog, SW_SHOW) ;
				UpdateWindow (main_dialog) ;
				break ;									// End WM_CREATE
