Caixa de busca para inserção de foto em formulários

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Responder
milhorini
Rank: Programador Júnior
Rank: Programador Júnior
Mensagens: 26
Registrado em: Qua, 05 Dez 2012 7:28 am

Eu queria criar no Forms uma caixa de busca, ou seja, ao clicar em um botão, uma caixa de diálogo fosse aberta para que eu procurasse um item, uma foto, por exemplo, e adicioná-la em meu formulário.

Como eu poderia fazer isso?
tora34
Rank: Analista Pleno
Rank: Analista Pleno
Mensagens: 108
Registrado em: Qua, 12 Nov 2008 6:01 pm
Localização: Campo Mourão PR
Renato Pasquini
Oracle Developer

Boa tarde,
criei a seguinte package para tratar este problema. Qualquer dúvida é só perguntar.

Selecionar tudo

PACKAGE BODY pck_arquivo IS
	diretorio_temp varchar2(500);
	
  procedure set_dir_arquivo(caminho_arquivo varchar2) is
  begin
  	diretorio := substr(caminho_arquivo, 1, instr(caminho_arquivo, '\', -1));
	  nome      := substr(caminho_arquivo, instr(caminho_arquivo, '\', -1) + 1);
  end;
  
  procedure buscar is
    caminho_arquivo varchar2(1000);
  begin
    caminho_arquivo := get_file_name(directory_name => null,
                                     file_name      => null,
                                     file_filter    => 'Imagem Croqui (*.jpeg, *.jpg)|*.jpeg; *.jpg|',
                                     message        => null,
                                     dialog_type    => open_file,
                                     select_file    => true);
    if caminho_arquivo is not null then
	    READ_IMAGE_FILE(caminho_arquivo, 'JPG', 'croprop.im_croqui');
	    set_dir_arquivo(caminho_arquivo);
    end if;
  end;
  
  function dir_existe (i_diretorio varchar2) return boolean is
	  out_file   Text_IO.File_Type;
	begin
		out_file := Text_IO.Fopen(i_diretorio||'temp.txt', 'w');
		Text_IO.Fclose(out_file);
		return true;
	exception
		when others then
		  return false;
	end;
	
  procedure abrir(i_nm_arquivo varchar2) is
	begin		
		if diretorio_temp is null then
			diretorio_temp := 'C:\Fontes\';
			if not dir_existe(diretorio_temp) then
				host('mkdir '|| diretorio_temp, no_screen);
			end if;
		end if;
		if i_nm_arquivo is not null then
			if not dir_existe(diretorio_temp) then
				loop
					diretorio_temp := get_file_name( directory_name => diretorio_temp,
			                                     file_name      => null,
			                                     file_filter    => null,
			                                     message        => 'Selecione um diretório para baixar o croqui',
			                                     dialog_type    => open_file,
			                                     select_file    => false);
				  if diretorio_temp is not null then
				  	diretorio_temp := diretorio_temp||'\';
				  	if not dir_existe(diretorio_temp) then
				  	  fgalproc(1, 'Não foi possível baixar o arquivo para a pasta '||diretorio_temp||'. Selecione outra pasta.');
				  	else
				  		exit;
				  	end if;
				  else
				    exit;		
				  end if;
			  end loop;			  
			end if;
			if diretorio_temp is not null then
		    write_image_file(diretorio_temp||i_nm_arquivo,
				                 'JPG',
				                 'croprop.im_croqui',
				                  no_compression,
				                  original_depth);
				host('"'||diretorio_temp||i_nm_arquivo||'"', no_screen);
			end if;
		end if;		
	end;
end;
milhorini
Rank: Programador Júnior
Rank: Programador Júnior
Mensagens: 26
Registrado em: Qua, 05 Dez 2012 7:28 am

Muito obrigado por responder!
Vou ver direitinho. Assim que eu terminar e se eu tiver dúvida, lhe pergunto!

Abraço!

Wilson
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 16 visitantes