Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Showmessage gigante? (https://www.clubdelphi.com/foros/showthread.php?t=66638)

nena_yei 04-03-2010 16:37:03

Showmessage gigante?
 
Holaa!

Un pequeño "expediente x" que tengo...
Tengo un showmessage que aleatoriamente sale extremadamente grande, se sale de la pantalla y ni se puede cerrar el mensaje ni nada, pero no pasa siempre. Alguien se ha encontrado alguna vez con esto? Qué puedo hacer? He intentado cambiar el Showmessage por MessageDlg pero le pasa lo mismo. Alguien puede ayudarme?

Gracias!!

roman 04-03-2010 16:39:29

Y ese ShowMessage, ¿qué mensaje muestra?

// Saludos

nena_yei 04-03-2010 16:43:34

Es algo tan secillo como:

showmessage('No existen casos para esta consulta');

duilioisola 04-03-2010 17:06:14

Lo único que se me ocurre es que estés construyendo el mensaje. (Aunque dices lo contrario)

mensaje := 'No existen casos para esta consulta';
mensaje := mensaje+#13+'Lo que sea';
[...]
showmessage(Mensaje);

Si mensaje se construye con muchas lineas (#13) o muchos espacios, te mostrará un montón de espacio vacío.

Al González 04-03-2010 18:37:31

Me ha ocurrido lo mismo en situaciones donde la instancia de la aplicación ha quedado inestable.

Puede que se trate de un mal manejo de variables u objetos previo a la ejecución del ShowMessage. Da la impresión de que Windows no reconoce el fin de la cadena y toma un montón de bytes adicionales de la memoria hasta donde encuentra un byte 0 finalizador.

No he comprobado a qué se debe exactamente, pero me ha sucedido una que otra vez mientras hago depuración de excepciones no controladas.

¿Tu rutina hace algo en especial antes de lanzar ese ShowMessage?

nena_yei 08-03-2010 10:19:05

Muchas gracias por la respuesta.

Antes del showmessage se monta una consulta sql bastante compleja, puede que venga de ahí buff..El código no es mio y la cosa se complica porque hay muchas condiciones que primero tengo que saber de donde salen. Lo raro es que no me lanza ninguna excepción ni error ni warning, nada, y el procedimiento lo realiza correctamente. Así que esto va a ser como buscar una aguja en un pajar.

Gracias de nuevo, un saludo!!

nena_yei 08-03-2010 12:46:31

Y una duda..ya que el código me funciona bien y no me aperece ningún error, ni ningún warning ni nada, habría alguna manera de "limpiar" antes de mostrar el showmessage y así no tome bytes adicionales? Es que tengo la aplicación ya acabada, y por culpa de este tema no puedo entregar el proyecto :(

nena_yei 09-03-2010 11:30:09

Holaa de nuevo!
Tal y como hablé con Al González, aquí pongo el código de la función que lanza el showmessage problemático, para ver si alguien ve algo que podría estar fallando. Vuelvo a remarcar que funciona correctamente el procedimiento, que no me salta ningún error ni warning ni nada.
Gracias de antemano

Código Delphi [-]
procedure Tmultiple.executaconsulta();
var final,temp,condicio,contemp,con:widestring;
var i,num:integer;
begin

image12.Cursor:=crHourglass;
screen.Cursor:=crHourglass;
self.Cursor:=crHourglass;
busllengua:=0;
numopcions:=0;
busdoc:=0;
buslema:=0;
dades.q2.SQL.text:='delete from temp';
dades.q2.ExecSQL;
con:='select lema,subvoce,apartado,lemabusc,lemaord,id,lemaordinv from adm_lema where  ';
  temp:=StringReplace(lema.text,'$','%',[rfReplaceAll]);
  temp:=StringReplace(temp,'#','_',[rfReplaceAll]);
  //lema
  if(lema.Text<>'') then begin
    dades.q3.SQL.Text:='select id,lema from adm_lema where (adm_lema.lema like "'+ansilowercase(temp)+'" or adm_lema.lema like "'+ansiuppercase(temp)+'")';
    dades.q3.open;
    contemp:='';
    while not dades.q3.eof do begin
      dades.q2.SQL.text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
      dades.q2.ExecSQL;
      dades.q3.Next;
    end;
    buslema:=1;
    condicio:='actiu';
  end;

  //llengues
  final:='';
  llengues.totll:=0;

  for i:=0 to busqueda.items.Count-1 do
  begin
   if(busqueda.Items.Strings[i]='Y') then
   begin
    condicio:='and';
   end else if(busqueda.Items.Strings[i]='O') then begin
    condicio:='or';
   end else if(copy(busqueda.Items.Strings[i],0,1)='>') then
   begin
   contemp:=llengues.treureLlengues2(strtoint(ids.Items.Strings[i]));
   contemp:=copy(contemp,0,length(contemp)-3);
   if(contemp<>'')then begin
     if(condicio='and') then begin
       dades.q3.SQL.text:='select id_adm_lem from adm_etims right join temp on temp.id_adm_lem=adm_etims.id_adm_lem where '+contemp+' group by id_adm_lem';
       dades.q3.open;
     end else begin
       if(condicio='actiu') then
         dades.q3.SQL.text:='select id_adm_lem from adm_etims INNER JOIN temp ON adm_etims.id_adm_lem=temp.id_adm_lem where ('+contemp+') and id_adm_lem<>"" group by id_adm_lem'
       else
         dades.q3.SQL.text:='select id_adm_lem from adm_etims where ('+contemp+') and id_adm_lem<>"" group by id_adm_lem';

       dades.q3.open;
       dades.q2.SQL.Text:='delete from temp';
       dades.q2.ExecSQL;
       dades.q2.close;
     end;
     while not dades.q3.Eof do begin
       dades.q2.SQL.Text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
       dades.q2.ExecSQL;
       dades.q2.close;
       dades.q3.next;
     end;
     dades.q3.Close;
   end;

   end else begin
     if(condicio='and') or (condicio='actiu') then begin
       dades.q3.SQL.text:='select id_adm_lem from adm_etims right join temp on temp.id_adm_lem=adm_etims.id_adm_lem where id_adm_len='+trim(ids.Items.Strings[i])+' group by id_adm_lem';
       dades.q3.Open;
       dades.q2.close;
     end else begin
        dades.q3.SQL.text:='select id_adm_lem from adm_etims where id_adm_len='+trim(ids.Items.Strings[i])+' and id_adm_lem<>"" group by id_adm_lem';
        dades.q3.Open;
     end;
     dades.q2.SQL.Text:='delete from temp';
     dades.q2.ExecSQL;

     while not dades.q3.Eof do begin
      dades.q2.SQL.Text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
      dades.q2.ExecSQL;
      dades.q2.close;
      dades.q3.next;
     end;
     dades.q3.Close;
    llengues.abrlle[llengues.totll]:=trim(ids.Items.Strings[i]);
    llengues.totll:=llengues.totll+1;
   end;
  end;

  if(busqueda.items.Count>0)then begin
    con:=con+final+' and';
    busllengua:=1;
    condicio:='actiu';
  end;

  //transmission
  if (semicultismo.Checked) or  (cultismo.Checked) or  (patrimonial.Checked) then begin
    if(condicio='actiu')then
      con:='select id_adm_lem from adm_etims RIGHT JOIN temp ON temp.id_adm_lem=adm_etims.id_adm_lem where '
    else
      con:='select id_adm_lem from adm_etims where ';

    buslema:=1;
  end;

  if semicultismo.Checked then con:=con+'(transmisio=''S-'' or transmisio=''DS'') or';
  if cultismo.Checked then
  begin
    con:=con+' (transmisio=''C-'' or transmisio=''DC'') or';
  end;

  if patrimonial.Checked then
  begin
    con:=con+' (transmisio=''H-'' or transmisio=''DH'') or';
  end;

  if (semicultismo.Checked) or  (cultismo.Checked) or  (patrimonial.Checked) then
  begin
    con:=copy(con,0,length(con)-3);
    dades.q3.SQL.Text:=con+' and id_adm_lem<>"" group by id_adm_lem';
    dades.q3.open;
    dades.q2.SQL.text:='delete from temp';
    dades.q2.ExecSQL;
    contemp:='';
    while not dades.q3.eof do begin
      dades.q2.SQL.text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
      dades.q2.ExecSQL;
      dades.q3.Next;
    end;
    con:=con+') and ';
    condicio:='actiu';
  end;

  //documentacio
  //anys i primeradoc
  temp:='';
  if f_ini.text<>'' then
  begin
    busdoc:=1;
    temp:=' and ';
    if f_ini.text=f_fi.text then
      temp:=temp+' adm_documentacio.data_ini='+f_ini.Text+' and '
    else
      temp:=temp+' ((adm_documentacio.data_ini<="'+f_ini.Text+'" and adm_documentacio.data_fi>="'+f_fi.text+'") or (data_ini BETWEEN "'+f_ini.text+'" and "'+f_fi.text+'")) ';
  end;
  if primeradoc.Checked then temp:=temp+' and primeradoc="Sí" ';
  //obra
  paraulabusc:=0;
  if (autor.Text<>'') and (autor.text<>'Todos') then begin
    if(condicio='actiu')then
      contemp:='select id_adm_lem from adm_documentacio INNER JOIN temp ON temp.id_adm_lem=adm_documentacio.id_adm_lem where id_adm_aut in (select id from adm_autors where (adm_autors.autor_norm="'+autor.Text+'")) '+temp
    else
      contemp:='select id_adm_lem from adm_autors INNER JOIN adm_documentacio ON adm_autors.id = adm_documentacio.id_adm_aut where (adm_autors.autor_norm="'+autor.Text+'") and id_adm_lem<>"" '+temp;

    dades.q3.SQL.Text:=contemp;
    dades.q3.open;
    dades.q2.SQL.text:='delete from temp';
    dades.q2.ExecSQL;
    contemp:='';
    while not dades.q3.eof do begin
      dades.q2.SQL.text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
      dades.q2.ExecSQL;
      dades.q3.Next;
    end;
    busdoc:=1;
    paraulabusc:=2;
    numopcions:=1;
    condicio:='actiu';
  end;

  if (obra.Text<>'') and (obra.text<>'Todas') then
  begin
      if(condicio='actiu')then
        contemp:='select id_adm_lem from adm_documentacio INNER JOIN temp ON temp.id_adm_lem=adm_documentacio.id_adm_lem where id_adm_obr in (select id from adm_obras where adm_obras.obra_norm="'+obra.Text+'") '+temp
      else
        contemp:='select id_adm_lem from adm_obras INNER JOIN adm_documentacio ON adm_obras.id = adm_documentacio.id_adm_obr where (adm_obras.obra_norm="'+obra.Text+'") and id_adm_lem<>"" '+temp;

    dades.q3.SQL.Text:=contemp;
    dades.q3.open;
    dades.q2.SQL.text:='delete from temp';
    dades.q2.ExecSQL;
    contemp:='';

    while not dades.q3.eof do begin
      dades.q2.SQL.text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
      dades.q2.ExecSQL;
      dades.q3.Next;
    end;
    busdoc:=1;
    paraulabusc:=3;
    condicio:='actiu';
  end;

  if (f_ini.text<>'') and (paraulabusc<2)then
  begin
    busdoc:=1;
    if(condicio='actiu')then
      contemp:='select id_adm_lem from adm_documentacio INNER JOIN temp ON temp.id_adm_lem=adm_documentacio.id_adm_lem where'
    else
      contemp:='select id_adm_lem from adm_documentacio where';

    if f_ini.text=f_fi.text then
      contemp:=contemp+' adm_documentacio.data_ini="'+f_ini.Text+'" '
    else
        contemp:=contemp+'(((adm_documentacio.data_ini<="'+f_ini.Text+'" and adm_documentacio.data_fi>="'+f_fi.text+'") and adm_documentacio.data_fi<>0) or ((adm_documentacio.data_ini between "'+f_ini.Text+'" and "'+f_fi.text+'"))) ';

    if primeradoc.Checked then contemp:=contemp+' and primeradoc="Sí" ';

    dades.q3.SQL.Text:=contemp;
    dades.q3.open;
    dades.q2.SQL.text:='delete from temp';
    dades.q2.ExecSQL;
    contemp:='';
    while not dades.q3.eof do begin
      dades.q2.SQL.text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
      dades.q2.ExecSQL;
      dades.q3.Next;
    end;
    paraulabusc:=1;
    condicio:='actiu';
  end;

  if (paraulabusc=0) and (primeradoc.Checked) then
  begin
    if(condicio='actiu')then
      contemp:='select id_adm_lem from adm_documentacio INNER JOIN temp ON temp.id_adm_lem=adm_documentacio.id_adm_lem where primeradoc="Sí"'
    else
      contemp:='select id_adm_lem from adm_documentacio where primeradoc="Sí"';

    dades.q3.SQL.Text:=contemp;
    dades.q3.open;
    dades.q2.SQL.text:='delete from temp';
    dades.q2.ExecSQL;
    contemp:='';
    while not dades.q3.eof do begin
      dades.q2.SQL.text:='insert into temp (id_adm_lem) values ('+dades.q3.Fields.Fields[0].AsString+')';
      dades.q2.ExecSQL;
      dades.q3.Next;
    end;
    paraulabusc:=3;
    busdoc:=1;
    condicio:='actiu';
  end;

  con:='select lema,subvoce,apartado,lemabusc,lemaord,id,lema as temp,lemaordinv from adm_lema INNER JOIN temp ON adm_lema.id=temp.id_adm_lem where lema<>"" group by lema,subvoce,apartado,lemabusc,lemaord,id,lemaordinv order by lemaord';
  dades.q1.close;
  dades.q1.sql.text:=con;
  dades.q1.Open;
  num:=dades.q1.RecordCount;
  carga.Close;

  image12.Cursor:=crDefault;
  screen.Cursor:=crDefault;
  self.Cursor:=crDefault;

  if(num<1)then begin
    ShowMessage('No existen casos para esta consulta');
    exit;
  end;

  central.primeravegada:=false;
  dades.dsllistat.DataSet:=dades.q1;
  central.statusbar.panels[0].text:=inttostr(num)+' Registros';
  close;

end;


La franja horaria es GMT +2. Ahora son las 23:08:35.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi