
LRESULT CALLBACK OriginalHandler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
		if(hwnd == hWnd)
		{
			if(wParam == SC_CLOSE){sys_exit(NULL);}	
		}
	
	switch (message)
	{
		case WM_COMMAND:
		if(wParam == 1)
		{
			
			filepfad= file_dialog("Load Map","*.dat"); // map laden
				if(filepfad != NULL)
				{
					//level_load("");
					file_sma = str_create(filepfad);
					str_replace(file_sma, ".dat", ".sma");
					file_map = str_create(filepfad);
					str_replace(file_map, ".dat", ".map");
					file_id = str_create(filepfad);
					str_replace(file_id, ".dat", " ");
					dat_read();
				}
		}
		if(wParam == 2)
		{
			if(startwindow)
			{
				LBG_destroy_window (startwindow);obj_editor = 0;
			}
			
			filepfad = file_dialog_save("Save Map","*.dat");
			if(filepfad != NULL){save_dat_map_file();}
			
		}
		if(wParam == 3)
		{
			filepfad = file_dialog_save("Save SMA","*.sma");
			if(filepfad != NULL){save_sma();}
		}
		if(wParam == 4)
		{sys_exit(NULL);}
		if(wParam == 5)
		{
		 	save_file_all();
		}
		
		if(wParam == 6)
		{
			MessageBox(hWnd,"
			-Memory Optimization\n
			-You can now open several maps succession\n
			-Some errors have been corrected\n
			-ChangeLog has been added\n
			-About has been added\n
			-Clone button was removed\n
			-Save all added
			","ChangeLog",MB_OK);
		}
		
		if(wParam == 7)
		{
			MessageBox(hWnd,"For questions and errors writes me under a.rietz@gmx.net.","About",MB_OK);
		}
		
		if(wParam == 8)
		{
			
			//str_folder
			folder_dialog(str_folder);
			
			STRING* searchfolder = str_create(str_folder);
			
			
			str_cat(searchfolder,"\\*.obj");
			
			
			
			
			
			HANDLE test = _findfirst(_chr(searchfolder),&finddata);
			
			
			if(test == -1)
			{
				error("Wrong object folder!");
			}
			else
			{
				
				//printf(finddata.name);
				if(str_len(finddata.name) == 12)
				IMPORT_ACE_OBJ_FILE(_str(finddata.name));
				
				while(_findnext(test, &finddata) != -1) 
				{
					if(str_len(finddata.name) == 12)
					IMPORT_ACE_OBJ_FILE(_str(finddata.name));
					//printf(_chr(finddata.name));
				}
				
				_findclose(test);
				error("Import Finished, Please restart the Editor!");
			}
			
			
			
			
		}
		default:
		return OriginalHandler(hwnd, message, wParam, lParam);
		break;
		//
		//
	}

	return 0;
}