Disable all messages when open DWG - delphi

I'm developing application for converting DWG to PDF. Developing on Delphi using AutoCAD OLE. The best solution I found it's using Publish command. It work OK, but the problem is when I open DWG file some messages can appear. For a example, it can be missing SHX files message, or remember file was created in an earlier version, about ObjectARX and so on. Of course these messages appear when manually opening these DWG in AutoCAD.
But, for a example, when using Excel via OLE it has silent mode, so no messages will appear.
Is any similar in AutoCAD?
There is some system variables like FILEDIA or EXPERT (I use it) but it available only in document, when it opened already, not for application.
Here is a part of my code, where I open DWG:
...
CoInitializeEx(nil, 0);
AutoCAD := GetActiveOleObject('AutoCAD.Application');//connect to running AutoCAD
if not VarIsNull(AutoCAD) then
begin
cadDocument := AutoCAD.Documents.Open(InputFilename, True);//here's problem line code
...
end;
...

Related

TOleContainer opening .tmp(word2016) documents Delphi7

we are working with Delphi 7, SQL server 2008 and MS word 2003. now we are planning to migrate MS word 2003 to MS word 2016.
in our application we will load the document(BLOB field) from database and save it into .tmp file and then we will open the document using TOleContainer in Delphi7.
above process is working fine for .doc and it is not working for .docx. we are able to replicate the issue with below example
create the .docx file
open .docx file and enter some text and save and close
rename the .docx to .tmp
open the .tmp file using TOleContainer(Below Delphi code)
Delphi Code:
procedure TForm1.FormShow(Sender: TObject);
begin
WordOleContainer.AllowInPlace := True;
WordOleContainer.CreateObjectFromFile('F:\WordViewerTest\docx.tmp', False);
end;
when we run the application we are getting below error.if we click on open document is getting opened in another window, not in olecontainer.
if i double click on .tmp file, it is opening with out any warning.
if i use the above delphi code it is showing warning. how to make above code work?
So long as *.docx file is actually a *.zip file from a binary point of view, there's no way to distinguish for the OLE binary pattern class search mechanism (described in the GetClassFile reference, step 2. of determining strategy) between those file types. If you registered a binary pattern for *.docx file, you would actually register *.zip files for opening by an application of your choice. Since then all the programs using OleCreateFromFile would open *.zip files in the application you've registered.
So to resolve your problem without any ambiguity in the system simply save the file with the proper *.docx extension and let OLE find the class by the file extension (step 3. of determining strategy).

Safest way of using Outlook ActiveX

Just after running my Delphi application i check for the installed MS Outlook version because my app works differntly if in the machine there is a Outlook version greater than 2007.
I also wrote an Outlook Addin that sometimes crashes. I suspect
those crashes are related to the Outlook instances I create at startup.
Is there a way to create these ActiveX instances in a "softer way". As i create the OLE object now I see in Tray Bar an icon whose hint says "Outlook is being used by another application", may be if it were possible to remove this I would also see my problems disappear.
Somehow what I would like to achive is the same done here, where the wdDoNotSaveChanges parameter allows a "smoother" use of the OLE Object.
This is the code i use to check for Outlook version:
var
OutlookApp: OLEVariant;
Version : String;
begin
{ Create the OLE Object }
Try
OutlookApp := CreateOLEObject('Outlook.Application');
Version := OutlookApp.version;
OutlookVersion := StrToint(SubstrEx(1,Version,'.'));
OutlookApp := VarNull;
except
on E: Exception do
begin
OutlookVersion := -1;
end;
End;
Your approach is different from the one suggested by Microsoft here:
How to: Check the Version of Outlook .
Their version uses the Microsoft Installer functionality to detect the location of the Outlook executable, then extract the file version straight from there. This approach doesn't suffer from any of the problems you might encounter when instancing Outlook like you do. It is also a lot faster.
It does however suffer from one major disadvantage: it will only work if Outlook is deployed properly, the Microsoft way. On consumer machines this isn't so much of a problem, but in enterprise environments you might (/will) occasionally run into stripped down custom installs by overzealous IT departments that do not include the necessary MSI footprint.
Depending on your target audience, that might not be a real problem at all.

Compress a file with JclCompression

I am trying to save (compress) a .zip file using JclCompression with the JCL Demo. When I press the Save button on the Read and Write Tab the demo calls:
procedure TFormMain.ActionSaveExecute(Sender: TObject);
begin
(FArchive as TJclCompressArchive).Compress;
CloseArchive;
end;
When (FArchive as TJclCompressArchive).Compress; is executed it produces an exception: "At least one compression volumes could not be replaced after an archive out-of-place update." Also sometimes when I press the save button, the "application is not responding" appears in the form's caption, so I have to shutdown the demo.
Is this code correct or do I have to change it to sucessfully compress and save the zip file? Are there any other demos for JclCompression so I can learn how to use these classes?
Aside from this problem the demo seems to be working correctly. I can open a zip file, create a new zip file, add files, add files from a directory, extract selected files, extract all, and get zip file properties. Saving seems to be a problem.
I am using Delphi 2010 on Windows 7.
Same issue as jedi-jcl-compression-library-wont-open-spanned-archive-files.
JEDI JCL Compression library wont open spanned archive files
The JCL-JVCL version you use is buggy.
I would recommand to upgrade your JCL installation to latest daily build
I saw this error message when files which I wanted to archive were opened for writing, so you need to close them or copy them to temp folder in advance. Also If you using function Create7zArchive() as i do you need 7z.dll placed in your bin output folder. It's sad, but it seems JCL doesn't use Zlib.pas which is already integrated in Delphi.
JCL 2.7.0.5676 (Stable)

WM_Copy, wm_gettext and wm_keydown fail?

The problem: I need to obtain the selected text from a window in a Windows application (not my program). I am doing my work in Delphi XE and the software I am attempting to access is a kluge built over the past 15 years with C, C++, VB and who knows what else. I do not have the source code. The edit box (an RTF memo) I am attempting to read is of the class "Ter32Class". When I use wm_copy, nothing goes to the clipboard. when I use wm_gettext, nothing. When I use wm_keydown commands (to simulate Ctrl-Ins or Ctrl-C) nothing happens. Note that I can get all of these alternatives to work in wordpad, notepad, and FireFox but not this application (or OpenOffice, incidentally, but that's not the issue). The only way I have been able to programmatically obtain text from this box is to use autohotkey with the simple "send ^c" command. While it works, it is inelegant. HELP?!?
More information: Window hierarchy: Ter32Class is a child of OI_Mdi which is a child of MDIClient, which is a child of OI_Window . I am drilling down to obtain the appropriate handle as it will respond to a paste command.
I am using Delphi XE but I'd love any solution in C++ or VB if no Delphi XE gurus have the answer.
From Quick Macros Forum
One of the windows I need to talk to is of class Ter32Class which
apparently is a TE Edit Control, an editor that doesn't inherit from
the standard RichText Control
and
The published method of talking to this control is via it's DLL
so unless something has changed (post is 2006), it appears you'll need to use it's dll to get the text.
From Sub Systems (TE Edit control website)
Application Interface functions
GetTerBuffer: Retrieve Window Text
HANDLE GetTerBuffer(hWnd, size)

Which problems exist when using 32bit applications that handle Office 2010 64bit files?

I am testing one application that handles files (stored in SQL Server using FILESTREAM). It is a Delphi 32bit application.
Opening an XLS document stored in the database (originally saved with Office 2003) gives an error from Excel 2010 64bit. Is there some known compatibility issue of Office 2010 64bit with 32bit applications?
Error messages and workflow
When opening the file Excel gives one of the following error messages:
Impossible to open the file FILE because of problems in contents
Impossible to open the file because some parts are missing or not valid
Opening a file on machine A with Office 2007 opens the file with no problems. Opening the same file on machine B with Office 2010 produces the error message. Opening again on machine A there is also an error message! In all these steps I am just reading from the database, not writing. So why does this can happen?
How do I open the documents?
SELECT query to get 'DOCUMENT' varbinary(max) field for the specific ID_Document.
Extract from database using
TBlobField(sqlQuery.FieldByName('DOCUMENT')).SaveToFile(sDestinationPath + FileUniqueName + .zip');
Copy file from one path to another using Windows.CopyFile
Unzip file using TZipforge component
Set attribute of unzipped file to ROM using FileSetReadOnly function.
Open document using ShellExecute(0, 'open', PWideChar(FIleName), '', '', SW_SHOWNORMAL);
As you can see there is nothing that writes back to the database. Once the file is extracted from TBlobField it is even copied to another place before unzipping and opening it.
Possibly broken installation
Office has been reinstalled and now everything works, the problem of corruption was due to a conflict with an open Office installation that asked "do you want to fix the office installation?". Anyway the problem still remains, because I cannot understand what happened. How can I corrupt a file in the database if I extract it in a folder and open it from the folder without writing anything back to database?
Office 2010 64-bit should have no problems with files created with its 32-bit version. The files (.docx, .xls) are bitness independant.
I have some questions:
How do you open your files?
Can you show some code?
Are you sure that you are only reading the file from the database?
Do you give your files the right extension? Saving a .xls as .xlsx will cause problems when opening the file.
Check if your SQL server database is corrupt. Check disk where database is for errors. Reinstall SQL server.
Solved: it was a bug in my program. There was an error in the logic that persisted the document status and by mistake sometimes Is_File_Compressed was set to False, even if it is true.
Thanks for the support.

Resources