|
|
|
Как в скрипте PB8 узнать закрыт ли OLE-объект?
|
|||
|---|---|---|---|
|
#18+
Ситуация такая: из приложения PB8 - открывается и заполняется WORD-файл, пользователь должен его просмотреть. Далее возможен вариант, что пользователь САМ закроет Word (ole-объект). Как это отследить? Скрипт такой: ------------------------------ .... ole.application.WindowState = Maximized! ole.visible=true ole.Documents.open(file_new) .... is_ole = ole.Enabled //! если Word закрыт - ОШИБКА!!! if is_ole then ole.ActiveDocument.Close(0, false) //! если Word закрыт - ОШИБКА!!! else //пользователь сам закрыл... end if ole.application.Quit() ole.DisconnectObject() ------------------------------ ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 16.08.2005, 12:51 |
|
||
|
Как в скрипте PB8 узнать закрыт ли OLE-объект?
|
|||
|---|---|---|---|
|
#18+
Активируй через OLE-Control. в нем есть событие CLOSE ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 17.08.2005, 10:59 |
|
||
|
Как в скрипте PB8 узнать закрыт ли OLE-объект?
|
|||
|---|---|---|---|
|
#18+
to Andrew Nagorny - thank. Значит бросать OLEControl (невидимый) на окно? а можно pb-примерчик кода? - основные операторы... please... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.08.2005, 09:58 |
|
||
|
Как в скрипте PB8 узнать закрыт ли OLE-объект?
|
|||
|---|---|---|---|
|
#18+
Обычно я делаю резидентное окно с невидимым OLE-контролом и кнопкой закрыть. т.е. когда идет вызов на открытие Ворд документа открывается это окно. оно через структуру принимает параметры. типа что это за документ. сам документ в блобе.что с ним делать. и и все остальное по мелочи. открытие резидента окна обусловлено тем что могут происходить сбои. и это окно позволяет закрыть Ворд документ из приложения Билдера. вот исходник этого окна: forward global type w_srv_blob from w_response end type type cb_close from u_cb within w_srv_blob end type type ole_blob from u_oc within w_srv_blob end type end forward global type w_srv_blob from w_response integer x = 214 integer y = 221 integer width = 1221 integer height = 420 string title = "OLE Агент" long backcolor = 67108864 string icon = "UserObject5!" event type integer srv_save ( ) event srv_close ( ) cb_close cb_close ole_blob ole_blob end type global w_srv_blob w_srv_blob type variables Protected: str_srv_blob istr_blob Boolean ib_datachange Boolean ib_BlobExist Boolean ib_ObjectPlace end variables event type integer srv_save();Return NO_ACTION end event event srv_close();String ls_displayname n_cst_user32 lnv_user32 Integer li_rc istr_blob.b_blob = ole_blob.objectdata lnv_user32.SetForegroundWindow(Handle(This)) if ib_datachange AND (istr_blob.b_readonly = false OR istr_blob.b_alwayssave = True) AND istr_blob.b_print = false then ls_displayname = ole_blob.DisplayName li_rc = 1 if istr_blob.b_alwayssave = False then li_rc = gnv_app.inv_error.of_Message("blob_closequery_savechanges",{ls_displayname}) if li_rc =1 then li_rc = EVENT srv_save() ib_datachange = False if li_rc=FAILURE then Return ib_DisableCloseQuery = True istr_blob.i_returnvalue = SUCCESS CloseWithReturn(This,istr_blob) Return end if end if ib_DisableCloseQuery = True istr_blob.i_returnvalue = NO_ACTION CloseWithReturn(This,istr_blob) end event on w_srv_blob.create int iCurrent call super::create this.cb_close=create cb_close this.ole_blob=create ole_blob iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.cb_close this.Control[iCurrent+2]=this.ole_blob end on on w_srv_blob.destroy call super::destroy destroy(this.cb_close) destroy(this.ole_blob) end on event closequery;if ib_DisableCloseQuery Or ib_datachange=False Or istr_blob.b_ReadOnly then Return 0 Return 1 end event event pfc_preopen;call super::pfc_preopen;ole_blob.Visible = False of_SetPreference(False) ole_blob.DisplayName = GetApplication().DisplayName istr_blob = Message.PowerObjectParm if Not IsValid(istr_blob) then Return if Not IsNull(istr_blob.s_displayname ) And istr_blob.s_displayname<>'' then ole_blob.displayname = istr_blob.s_displayname end if if istr_blob.b_ReadOnly then ole_blob.DisplayName = ole_blob.DisplayName + '[Только чтение]' end if Title = Title + "-" +ole_blob.DisplayName ole_blob.objectdata = istr_blob.b_blob if Len(istr_blob.s_classblob)>0 and (IsNull(istr_blob.b_blob) Or Len(istr_blob.b_blob)=0) then ole_blob.InsertClass(istr_blob.s_classblob) end if try if Len(istr_blob.s_FileName)>0 then ole_blob.InsertFile(istr_blob.s_FileName) else if Not IsNull(istr_blob.b_blob) And Len(istr_blob.b_blob)>0 then ib_BlobExist = True ole_blob.objectdata = istr_blob.b_blob elseif Len(istr_blob.s_classblob)>0 then // ole_blob.InsertClass(istr_blob.s_classblob) else if ole_blob.InsertObject()<>0 then Return end if end if catch(Throwable e) gnv_app.inv_error.of_Message("OLEObjectDataNotAccept") Return end try end event event pfc_postopen;call super::pfc_postopen;Integer li_ret //This.WindowState = Minimized! Yield() String ls_classname ls_classname = ole_blob.ClassShortName //if IsNull(ls_classname) Or Len(ls_classname)=0 then Return SetPointer(Hourglass!) Post SetPointer(Arrow!) String ls_error li_ret = ole_blob.Activate(OffSite!) CHOOSE CASE li_ret CASE -1 ls_error = 'OLEContainerIsEmpty' CASE -2 ls_error = 'InvalidVerbForObject' CASE -3 ls_error = 'VerbNotImplementedByObject' CASE -4 ls_error = 'NoVerbsSupportedByObject' CASE -5 ls_error = 'OLEObjectCanTExecuteVerbNow' CASE -9 ls_error = 'OLEOtherError' END CHOOSE if li_ret>=0 then ib_ObjectPlace = True if istr_blob.b_print then if Lower(istr_blob.s_classblob)='word.document' then ole_blob.Object.Application.ActiveDocument.PrintOut() ib_DisableCloseQuery = True Post Close(This) end if end if else gnv_app.inv_error.of_Message(ls_error) end if end event event close;call super::close;if Len(istr_blob.s_FileName)>0 AND istr_blob.b_FileDelete = True then Post FileDelete(istr_blob.s_FileName) end if end event type cb_close from u_cb within w_srv_blob integer x = 315 integer y = 52 integer width = 553 integer taborder = 10 string text = "Закрыть" boolean cancel = true boolean default = true end type event clicked;call super::clicked;Parent.EVENT srv_Close() end event type ole_blob from u_oc within w_srv_blob integer width = 311 integer height = 188 integer taborder = 20 boolean enabled = false string binarykey = "w_srv_blob.win" omactivation activation = activatemanually! omdisplaytype displaytype = displayasicon! omlinkupdateoptions linkupdateoptions = linkupdatemanual! end type event close;gnv_app.of_DebugMessage('OLE close!') if ib_ObjectPlace then Parent.Post EVENT srv_Close() end if end event event externalexception;string ls_context gnv_app.of_DebugMessage('OLE externalexception!') // Command line switch for WinHelp numeric context ID ls_context = "-n " + String(helpcontext) If Len(HelpFile) > 0 THEN Run("winhelp.exe " + ls_context + " " + helpfile) END IF end event event save;n_cst_user32 lnv_user gnv_app.of_DebugMessage('OLE save!') lnv_user.Post SetForegroundWindow( (Handle(Parent))) ib_datachange = True end event event datachange;call super::datachange;gnv_app.of_DebugMessage('OLE datachanged!') end event event rename;call super::rename;gnv_app.of_DebugMessage('OLE rename!') end event event saveobject;call super::saveobject;gnv_app.of_DebugMessage('OLE saveobject!') end event event viewchange;call super::viewchange;gnv_app.of_DebugMessage('OLE viewchange!') end event ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.08.2005, 10:39 |
|
||
|
|

start [/forum/topic.php?fid=15&fpage=82&tid=1338185]: |
0ms |
get settings: |
8ms |
get forum list: |
19ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
34ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
52ms |
get tp. blocked users: |
2ms |
| others: | 206ms |
| total: | 344ms |

| 0 / 0 |
