# Image Control not working properly in MFC application

**URL:** <https://forum.commonvisionblox.com/t/image-control-not-working-properly-in-mfc-application/501>\
**Category:** C-style API\
**Tags:** activex, mfc, 64bit\
**Created:** [July 30, 2018, 9:00am UTC](https://forum.commonvisionblox.com/t/image-control-not-working-properly-in-mfc-application/501 "2018-07-30T09:00:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LincolnshirePoacher](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/lincolnshirepoacher/32/44_2.png) [@LincolnshirePoacher](https://forum.commonvisionblox.com/u/LincolnshirePoacher)\
**Post date:** [July 30, 2018, 9:00am UTC](https://forum.commonvisionblox.com/t/image-control-not-working-properly-in-mfc-application/501/1 "2018-07-30T09:00:35Z")

</div>

Hi,

I have started a simple test application with MFC and added an Image and a Display control to it, basically doing what the Getting Started section in CommonVisionBlox.chm recommends.

Loading an image seems to work, but when assigning the image to the display I don’t see any effect. Is this a known issue in the Display control???

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [July 30, 2018, 9:22am UTC](https://forum.commonvisionblox.com/t/image-control-not-working-properly-in-mfc-application/501/2 "2018-07-30T09:22:12Z")

</div>

Hi,

which version of :cvb: did you install? _Win32_ or _x64_? It could be that you compile for _Win32_ (default) and have an _x64_ version installed. It might be related to the _Prefer 32 bit_ issue of C# projects:

> [https://forum.commonvisionblox.com/t/hello-world-cvb/249/6?u=parsd](https://forum.commonvisionblox.com/t/hello-world-cvb/249/6)

---

<div class="post-metadata">

**Author:** ![LincolnshirePoacher](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/lincolnshirepoacher/32/44_2.png) [@LincolnshirePoacher](https://forum.commonvisionblox.com/u/LincolnshirePoacher)\
**Post date:** [July 30, 2018, 9:47am UTC](https://forum.commonvisionblox.com/t/image-control-not-working-properly-in-mfc-application/501/3 "2018-07-30T09:47:06Z")

</div>

Not C#. MFC.  
I am writing a 64 bit application. These are the wrapper classes that the MFC class wizard generated for me:

- [cvimagectrl1.zip](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/599fbacdd2b250c1a6c848574cd2945b30a67af8.zip) (2.4 KB)
- [cvdisplayctrl1.zip](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/4c24bb3fcddd234e3a688e942b0ddcb4fdd86488.zip) (3.6 KB)

---

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [July 30, 2018, 11:31am UTC](https://forum.commonvisionblox.com/t/image-control-not-working-properly-in-mfc-application/501/4 "2018-07-30T11:31:13Z")

</div>

Hi.

The wrapper files that you sent have been generated with a 64 bit installation of :cvb: and are therefore targeting the x64 platform. This is visible from looking e.g. at the `GetImage` and `SetImage` methods:

```c++
__int64 GetImage()
{
	__int64 result;
	GetProperty(0x1, VT_EMPTY, (void*)&result);
	return result;
}
void SetImage(__int64 propVal)
{
	SetProperty(0x1, VT_EMPTY, propVal);
}

```

The 32 bit version of :cvb: would have `int` instead of ` __int64` here. These two automatically generated wrapper function implementation also directly show the problem: Rather than passing the `__ int64` value through the `IDispatch` interface, the code passes an empty variant (`VT_EMPTY`) - which is exactly the reason why your image won’t show (and I would guess that there is a lot going on in the trace output of Visual Studio whenever `SetImage` or `GetImage` is called.

This is a known and very unfortunate flaw of the wizard that builds the ActiveX control wrappers for MFC applications (and it is in fact not limited to this one; the corresponding Delphi wizards are also struggling with `__int64` properties - the only tools doing well on this so far to my knowledge are _aximp_ and _tlbimp_ that generate the wrapper DLLs for .Net projects).

My recommendation to circumvent this problem:

1. When using the MFC class wizard to generate member variables for ActiveX controls on a dialog, remove the trailing “1” from the default settings (i.e. from the class name and from the file names) and let it do its botched job.
2. Open the source folder of any of the Visual C++ tutorials that ships with :cvb: which contains the ActiveX control that you are after. From there copy the _…ctrl.h_ and the _…ctrl.cpp_ file into your own source folder, overwriting the files that the wizard just generated.
3. Build your project. If everything worked your source should simply compile. If it doesn’t then redo step 1 and 2 but watch out for (and take into account) any subtle differences in class name and/or file name that your particular Visual Studio version might try to use and the wrapper files shipped with :cvb:.
