Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 03-12-2011
Avatar de Enan0
Enan0 Enan0 is offline
Miembro
 
Registrado: may 2004
Ubicación: Argentina
Posts: 565
Poder: 20
Enan0 Va por buen camino
Activex con D5 y Windows7 funcionamiento incorrecto

Hola Amigos.

En el Dia de hoy vengo un problemita con la Unidad ACTIVEX en delphi 5 windows 7 64 bts (creo que ha de ser igual en cualquier version de W7), El incoveniente esta en que la funciones de manejo de datos OLE no responde como en las otras versiones.


Cita:
En esta funcion hago el inicio del proceso y muestro la ventana tipica de, Seleccionar y crear un documento dsede Cero de una aplicacion registrada o da la opcion de cargar uno desde un archivo ya existente (aca es donde esta el problema).

Result:=OleUIInsertObject(io)=OLEUI_OK;
Código Delphi [-]

function TOleItem.InitNew(AOwner: TComponent; Category: TTemplateCategory; nas: TNoteAllowSet): Boolean;
var
  io: TOleUIInsertObject;
  NameBuffer: array[0..255] of Char;
  ws: WideString;
begin
   ws:='' ;
   FillChar(NameBuffer,SizeOf(NameBuffer),0);
   FillChar(io,SizeOf(io),0);
   with io do
   begin
      cbStruct:=SizeOf(io);
      dwFlags:=IOF_SELECTCREATENEW or IOF_DISABLEDISPLAYASICON or IOF_DISABLELINK;
      hWndOwner:=Application.Handle;
      lpszFile:=@NameBuffer;
      cchFile:=SizeOf(NameBuffer);
   end;
   Result:=OleUIInsertObject(io)=OLEUI_OK;
   if Result then
   begin
      OleCheck(CreateILockBytesOnHGlobal(0,true,fLockBytes));
      OleCheck(StgCreateDocfileOnILockBytes(fLockBytes,
         STGM_READWRITE or STGM_SHARE_EXCLUSIVE or STGM_CREATE,0,fStorage));

      if io.dwFlags and IOF_SELECTCREATEFROMFILE=0 then
         OleCheck(OleCreate(io.clsid,IOleObject,OLERENDER_DRAW,nil,Self,fStorage,fOleObject))
      else
      begin
         ws:=string(io.lpszFile);
         if io.dwFlags and IOF_CREATELINKOBJECT=0 then
            OleCheck(OleCreateFromFile(GUID_NULL,PWideChar(ws),IOleObject,OLERENDER_DRAW,nil,Self,fStorage,fOleO  bject))
         else
            OleCheck(OleCreateLinkToFile(PWideChar(ws),IOleObject,OLERENDER_DRAW,nil,Self,fStorage,fOleObject));
      end;
      oiClassID:=io.clsid;

      Inc(CNewOleTmpId); fItemId.IdType:=itOleItem; fItemId.IdLow:=CNewOleTmpId;
      if ws='' then
         FullName:=cUntitled
      else
         FullName:=ExtractFileName(ws);
   end;
end;

Código Delphi [-]

{esta funcion no hace nada raro simplemente preparo los datos para ser leidos, carga e inicializa objetos.}

procedure TOleItem.BeginEdit;
var
  hMem: THandle;
  p: Pointer;
begin
   if IDValid(fItemID) and 
               (fItemID.idLowthen
   begin
      fiStream.Position:=fObjPosition;

      hMem:=GlobalAlloc(GMEM_MOVEABLE,fiStream.Size);
      p:=GlobalLock(hMem);
      try
         fiStream.Read(p^,fiStream.Size);
      finally
         GlobalUnlock(hMem);
      end;

      if SUCCEEDED(CreateILockBytesOnHGlobal(hMem,true,fLockBytes)) then
      begin
         if SUCCEEDED(StgOpenStorageOnILockBytes(fLockBytes,nil,STGM_READWRITE or STGM_SHARE_EXCLUSIVE,nil,0,fStorage)) then
         begin
            OleLoad(fStorage,IOleObject,Self,fOleObject);
         end;
      end;
   end;
   inherited BeginEdit;
end;

{ Aca empezamos con el funcionamiento extrano, comento debajo}
function TOleItem.VisualEditParam(AOwner: TComponent; AParm: PTtEditParms): Boolean;
var
  wnd: HWND;
  R: TRect;
  wsApp, wsObj: WideString;
  WindowList: Pointer;
  dwConn: Longint;
begin
   fWaitForSave:=false;
   if fOleObject=nil then Result:=false else
   begin
      wnd:=GetParentForm(AOwner as TControl).Handle;
      GetWindowRect(wnd,R);

      wsApp:=cProgNameVerNo; wsObj:=cProgNameVerNo;
      fOleObject.SetHostNames(PWideChar(@wsApp[1]),PWideChar(@wsObj[1]));
      fOleObject.Advise(Self,dwConn);
      try
         Result:=Succeeded(fOleObject.DoVerb(OLEIVERB_OPEN,nil,Self,0,wnd,R));

         if Result then
         begin
            WindowList:=DisableTaskWindows(0);
            try
               while not fWaitForSave do
                  SysTimer.CheckMessages;
            finally
               EnableTaskWindows(WindowList);
            end;

            if (fSaveError<>'') then
               MsgError(GetParentForm(AOwner as TControl) as TForm,fSaveError,nil);
         end;
      finally
         fOleObject.Unadvise(dwConn);
      end;
   end;
end;


function TOleItem.OnShowWindow(fShow: BOOL): HResult;
begin
   if not fShow then fWaitForSave:=true;
   Result:=S_OK;
end;

procedure TOleItem.OnClose;
begin
   fWaitForSave:=true;
end;
Cita:
Funcionamiento extraño.

En versiones distintas a windows 7 en esta linea
Result:=Succeeded(fOleObject.DoVerb(OLEIVERB_OPEN,nil,Self,0,wnd,R));

Abre el editor por defecto o la aplicacion asociada al tipo de archivo, En Windows 7 abre una ventana de "EMPAQUETAMIENTO", esta vista tiene una especie de ASistente para seleccionar archivos. y siempre hace lo mismo. entra en un bucle, si le doy la opcion cancelar. retorna valor OK (SUCCEEDED) ya que finalizar sin error, pero no retorna que la ventana se cerro.

Con pruebas realizadas en las otras versiones y en W7 si cambio el OLEIVERB_OPEN por OLEIVERB_VIEW este punto funciona sin problemas.
en verssiones anteriores y al parecer en W7.

El otro inconveniente es que no detecta cuando Cierro la ventana (utilizando OLEIVERB_VIEW) entonces no puedo realizar el salvado de los datos. alguna idea de lo que pudo cambiar entre las versiones anteriores a windows y la tan ... amigable W7?
Bueno amigos espero que se entienda y pueda recibir alguna ayudita!

Saludos

Última edición por Enan0 fecha: 03-12-2011 a las 23:25:46.
Responder Con Cita
  #2  
Antiguo 03-12-2011
Avatar de Enan0
Enan0 Enan0 is offline
Miembro
 
Registrado: may 2004
Ubicación: Argentina
Posts: 565
Poder: 20
Enan0 Va por buen camino
algo le pasa a los estilos que no le gusta no muestra un espacio y un ")"
Código Delphi [-]
  if IDValid(fItemID) and  (fItemID.idLowthen)
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Problemas en Windows7 64bits - Conectando iButton mcs Varios 0 23-04-2010 08:45:50
Delphi 2010 + Windows7 Professional 64 bits ppb Windows 2 08-02-2010 15:49:56
Error: Parámetro Incorrecto Manuel Varios 2 30-04-2004 01:19:30
Filtro Incorrecto JamesBond_Mx Conexión con bases de datos 2 06-04-2004 22:31:23
Indice incorrecto VolaRe Varios 8 22-02-2004 20:34:45


La franja horaria es GMT +2. Ahora son las 11:27:45.


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