Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Activex con D5 y Windows7 funcionamiento incorrecto (https://www.clubdelphi.com/foros/showthread.php?t=76910)

Enan0 03-12-2011 23:19:44

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

Enan0 03-12-2011 23:26:48

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)


La franja horaria es GMT +2. Ahora son las 07:32:33.

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