I have a problem with VCL styles in Embarcadero C++ Berlin 10.1. I have an application written in BCB C++ and it calls pspiHost.dll (written in VS 2017), that executes Photoshop 8bf plugin filters (https://github.com/spetric/Photoshop-Plugin-Host).
Everything works OK until I change project application appearance to some VCL Style. When plugin is called from styled application, it's window is also styled!? Also, plugin window is constantly repainted and any action in window (like panning image) is slowed down.
I have also noticed this strange behavior on one scanner preview dialog which was also styled and it was definitely not a VCL application.
How can I disable VCL styling for non-VCL windows called from DLL?
Here is an example with Charcoal Dark Slate style:
Please disregard image orientation (before correction for TBitmap style containers).
Here is an example of the same application without styling (windows default):
Styled plugin is completely useless (slow when zooming, panning or any image change). Last example is with image orientation correction, but it's not relevant for this problem (just for info).
Here is a simple application. A form that has TImage, one TPanel and two speedbuttons on panel ("Load image" and "Execute plugin").
Here is an OnClick event for "Load image" button:
//---------------------------------------------------------------------------
void __fastcall TfrmSimple::SpeedButton1Click(TObject *Sender)
{
// load BMP in Image1
Image1->Picture->LoadFromFile("974-1.bmp");
// set our bitmap to pspiHost - we know that it's 24 bit bgr, no alpha, so we know the TImgType
int w, h;
srcImage = Image1->Picture->Bitmap;
TImgType type = PSPI_IMG_TYPE_BGR;
w = srcImage->Width;
h = srcImage->Height;
// let's say we don't know if TBitmap has contiguous buffer, so we'll add scanlines one by one
pspiStartImageSL(type, w, h);
for (int i = 0; i < h; i++)
pspiAddImageSL(srcImage->ScanLine[i]);
pspiFinishImageSL(); // done
}
In this example, scanlines are "send" to pspiHost.dll one by one, so there are three API calls.
Here is OnClick event for "Execute plugin" button:
//---------------------------------------------------------------------------
void __fastcall TfrmSimple::SpeedButton2Click(TObject *Sender)
{
// let's deal with filter
if (srcImage->Width < 2 || srcImage->Height < 2)
return;
// some 8bf filter for testing
String filter = "curves3 (32 bits).8bf";
// load filter
if (pspiPlugInLoad(filter.c_str()) == 0)
{
void *FP = DisableTaskWindows((HWND)(this->Handle)); // so that plugin window stays on top like modal (required for some filters)
int rc;
// execute filter
try {
rc = pspiPlugInExecute((HWND)(this->Handle));
} catch (...) {
rc = -1;
}
EnableTaskWindows(FP); // back to normal
Image1->Refresh();
if (rc != 0)
{
// error executing
}
}
else
{
// error loading -> plugin not loaded
}
}
There are two API calls, load filter and execute filter. That's all. The architecture is quite simple: Application -> pspiHost.dll -> 8bf filter (which is again DLL). Application appearance affects plugin window. Question is how to disable such behaviour?