473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

GUI Interop problem

Hi,

Introduction:
I have developed an interop project built of an unmanaged COM object and a
..NET WinForm application, the WinForm Application implement the user
interface while the unmanaged COM implements a collection of mathematical
calculations and algorithms.

The COM object, when requested, should be able to render a graph
representing it’s calculations to a window, to achieve that it expose a
‘Render’ method that receive a window handle as an argument, this window
handle represent am PictureBox window created by the WinForm application, the
handle to this window is then being passed to the unmanaged COM and used to
draw a graph using Win32 GDI API ( MoveToEx, LineTo, … ).

The actual rendering is performed through the OnPaint event of the
PictureBox control.
The problem:
The data is being rendered to the desired window by the unmanaged COM,
still, it seem as if the .NET Framework draw the control background over it (
although the rendering was performed through the control Paint event ), the
resulting image is a gray rectangle with a one pixel width frame of the
original picture drawn by the unmanaged COM.

Why does this happen?
Why does the image rendered by the unmanaged COM was overwritten ?
How can this be resolved? ( I can’t do the drawing with managed code )

Code snippets:
Managed OnPaint event implementation:
private void pbTimeView_Paint(object sender, PaintEventArgs e)
{
if (0 == m_WaveForm.FileName.Length)
return;
m_WaveForm.Time.Render(pbTimeView.Handle, 0);
}

Unmanaged Render call implementation:
HRESULT STDMETHODCALLTYPE CWaveForm::Time::Render(VARIANT hWindow, FLOAT
fPosition)
{
RECT rc;
HWND hWnd = (HWND)hWindow.byref;
::GetClientRect(hWnd, &rc);
rc.right -= 1;

float fWidthInSecondsResolution = (float)rc.right / rc.bottom / 2.0f;//
Assumming the amount of higth pixels represent half second
int iWidthInSamplesResolution = (int)(m_Container.m_wfex.nSamplesPerSec *
fWidthInSecondsResolution);

double* pPCM = m_Container.m_pWaveData.m_p + (int)(fPosition *
m_Container.m_ulSamplesCount);

HDC hdc = ::GetDC(hWnd);
::MoveToEx(hdc, 1, rc.bottom / 2, 0);

for(int i = 0; i < iWidthInSamplesResolution; i++)
LineTo(hdc, i, (int)(pPCM[i]*rc.bottom));

::ReleaseDC(hWnd, hdc);
return S_OK;
}

Any help would be appreciated.

--
Nadav
http://www.sophin.com
Mar 17 '06 #1
0 1022

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer,...
20
by: Razzie | last post by:
Hey all, I'm really going through a small hell right now - I've completely lost it :) I made a project, using two interop libraries from exchange (created them as in this msdn article:...
1
by: Shiro | last post by:
Hi I have read the various postings relating to Interop strong name signing and cannot find an example similar to mine. I have stringly named my AxInterops/Interops and they all work just...
8
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be...
2
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.