Hi, I have created HTML View control. Now I'm trying to display images
(using CVOImage class) -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppc2k/html/ppc_viewer.asp.
The problem is that image <img src="aaaa.bmp"> is displaying but
disappearing very quick - I have no idea, what is happening... Could someone
give me a solution? Maybe another way of declaring variables etc.?

Below is fragment of code for displaying images:

CVOImage img; // global

....

case WM_NOTIFY:
if(wParam==IDC_HTMLVIEW &&
((LPNMLISTVIEW)lParam)->hdr.code==NM_INLINE_IMAGE)
{
hDC = GetDC(hDlg);
if(img.Load(hDC,((NM_HTMLVIEW*)lParam)->szTarget))
{
INLINEIMAGEINFO imgInfo;
imgInfo.dwCookie = ((NM_HTMLVIEW*)lParam)->dwCookie;
imgInfo.iOrigHeight = img.GetHeight();
imgInfo.iOrigWidth = img.GetWidth();
imgInfo.hbm = img.Copy();
imgInfo.bOwnBitmap = FALSE;

SendMessage(((LPNMLISTVIEW)lParam)->hdr.hwndFrom,DTM_SETIMAGE,0,(LPARAM)&img
Info);
}
else
SendMessage(((LPNMLISTVIEW)lParam)->hdr.hwndFrom,DTM_IMAGEFAIL,0,((NM_HTMLVI
EW*)lParam)->dwCookie);
ReleaseDC(hDlg,hDC);
}
break;

Re: HTML View - images? by Riki

Riki
Wed Jan 26 02:53:36 CST 2005

in windowproc, change the statement 'break;' to 'return (LRESULT)1;'
i'm experiencing that that problem when using wm2k3

regards,
Riki Risnandar

"Marcin" <mparka@NOSPAM.elka.pw.edu.pl> wrote in message
news:ct6hl6$3fl$1@mamut1.aster.pl...
> Hi, I have created HTML View control. Now I'm trying to display images
> (using CVOImage class) -
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppc2k/html/ppc_viewer.asp.
> The problem is that image <img src="aaaa.bmp"> is displaying but
> disappearing very quick - I have no idea, what is happening... Could
> someone
> give me a solution? Maybe another way of declaring variables etc.?
>
> Below is fragment of code for displaying images:
>
> CVOImage img; // global
>
> ....
>
> case WM_NOTIFY:
> if(wParam==IDC_HTMLVIEW &&
> ((LPNMLISTVIEW)lParam)->hdr.code==NM_INLINE_IMAGE)
> {
> hDC = GetDC(hDlg);
> if(img.Load(hDC,((NM_HTMLVIEW*)lParam)->szTarget))
> {
> INLINEIMAGEINFO imgInfo;
> imgInfo.dwCookie = ((NM_HTMLVIEW*)lParam)->dwCookie;
> imgInfo.iOrigHeight = img.GetHeight();
> imgInfo.iOrigWidth = img.GetWidth();
> imgInfo.hbm = img.Copy();
> imgInfo.bOwnBitmap = FALSE;
>
> SendMessage(((LPNMLISTVIEW)lParam)->hdr.hwndFrom,DTM_SETIMAGE,0,(LPARAM)&img
> Info);
> }
> else
> SendMessage(((LPNMLISTVIEW)lParam)->hdr.hwndFrom,DTM_IMAGEFAIL,0,((NM_HTMLVI
> EW*)lParam)->dwCookie);
> ReleaseDC(hDlg,hDC);
> }
> break;
>
>



Re: HTML View - images? by Marcin

Marcin
Wed Jan 26 13:54:46 CST 2005

Riki Risnandar wrote:
> in windowproc, change the statement 'break;' to 'return (LRESULT)1;'
> i'm experiencing that that problem when using wm2k3
>

System is WM2003 - I have read about change (returning nonzero value), but
unfortunately it didn't help.

I have run this code on PPC2002 emulator (compiled with VisualTools 3.0 -
and it is working well, so PPC 2002 is ok). Maybe problem is that main
dialog has child window "tab control" and html view is child window for tab?
Of course WM_NOTIFY is passed to main dialog two levels up - but I suppose
this can cause a problem (LRESULT from dialog wndproc isn't passed to html
view properly?). If so, is there any solution? I cannot change current
relation: hDlg -> tab -> html view



My code is like below:

case WM_NOTIFY:
/* if(((NM_HTMLVIEW*)lParam)->hdr.idFrom==IDC_HTMLVIEW)
{
if(((NM_HTMLVIEW*)lParam)->hdr.code==NM_INLINE_IMAGE)
{
hDC = GetDC(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom);
if(img.Load(hDC,((NM_HTMLVIEW*)lParam)->szTarget))
{
INLINEIMAGEINFO imgInfo;
imgInfo.dwCookie = ((NM_HTMLVIEW*)lParam)->dwCookie;
imgInfo.iOrigHeight = img.GetHeight();
imgInfo.iOrigWidth = img.GetWidth();
imgInfo.hbm = img.Copy();
imgInfo.bOwnBitmap = FALSE;

SendMessage(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,DTM_SETIMAGE,0,(LPARAM)&img
Info);
} else
SendMessage(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,DTM_IMAGEFAIL,0,((NM_HTMLVI
EW*)lParam)->dwCookie);
ReleaseDC(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,hDC);
return TRUE;
}
}
....
other message handlers



Re: HTML View - images? by Riki

Riki
Thu Jan 27 00:23:13 CST 2005

try to add the 'return TRUE' after the line :
> SendMessage(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,DTM_SETIMAGE,0,(LPARAM)&img
> Info);
your code still processing the rest of the '> other message handlers' or the
normal windowproc which cause the images dissappear, while your 'return
TRUE' is active when htmlview images fail (DTM_IMAGEFAIL).
this is my windowproc when processing htmlview images (notice the return
value after set the images using DTM_SETIMAGE).

case NM_INLINE_IMAGE:
CString strSrcText = pnmHTML->szTarget;
DWORD dwCookieValue = pnmHTML->dwCookie;

CBitmap* pBitmap;
if (! m_imagesCache.Lookup(strSrcText, (CObject*&)pBitmap)) {
::SendMessage(m_hwndHtml, DTM_IMAGEFAIL, 0, (LPARAM)&dwCookieValue);
return (LRESULT)1;
}
INLINEIMAGEINFO imageInfo;
imageInfo.dwCookie = dwCookieValue;
imageInfo.bOwnBitmap = FALSE;
imageInfo.hbm = (HBITMAP)(*pBitmap);
CSize size = pBitmap->GetBitmapDimension();
imageInfo.iOrigWidth = size.cx;
imageInfo.iOrigHeight = size.cy;
::SendMessage(m_hwndHtml, DTM_SETIMAGE, 0, (LPARAM)&imageInfo);
return (LRESULT)1;

Regards,
Riki Risnandar

"Marcin" <mparka@NOSPAM.elka.pw.edu.pl> wrote in message
news:ct8sgg$v5g$1@mamut1.aster.pl...
>
> I have run this code on PPC2002 emulator (compiled with VisualTools 3.0 -
> and it is working well, so PPC 2002 is ok). Maybe problem is that main
> dialog has child window "tab control" and html view is child window for
> tab?
> Of course WM_NOTIFY is passed to main dialog two levels up - but I suppose
> this can cause a problem (LRESULT from dialog wndproc isn't passed to html
> view properly?). If so, is there any solution? I cannot change current
> relation: hDlg -> tab -> html view
>
>
>
> My code is like below:
>
> case WM_NOTIFY:
> /* if(((NM_HTMLVIEW*)lParam)->hdr.idFrom==IDC_HTMLVIEW)
> {
> if(((NM_HTMLVIEW*)lParam)->hdr.code==NM_INLINE_IMAGE)
> {
> hDC = GetDC(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom);
> if(img.Load(hDC,((NM_HTMLVIEW*)lParam)->szTarget))
> {
> INLINEIMAGEINFO imgInfo;
> imgInfo.dwCookie = ((NM_HTMLVIEW*)lParam)->dwCookie;
> imgInfo.iOrigHeight = img.GetHeight();
> imgInfo.iOrigWidth = img.GetWidth();
> imgInfo.hbm = img.Copy();
> imgInfo.bOwnBitmap = FALSE;
>
> SendMessage(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,DTM_SETIMAGE,0,(LPARAM)&img
> Info);
> } else
> SendMessage(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,DTM_IMAGEFAIL,0,((NM_HTMLVI
> EW*)lParam)->dwCookie);
> ReleaseDC(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,hDC);
> return TRUE;
> }
> }
> ....
> other message handlers
>
>



Re: HTML View - images? by Marcin

Marcin
Thu Jan 27 09:10:24 CST 2005

Riki Risnandar wrote:
> try to add the 'return TRUE' after the line :
>>
SendMessage(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,DTM_SETIMAGE,0,(LPARAM)&img
>> Info);
> your code still processing the rest of the '> other message handlers'
> or the normal windowproc which cause the images dissappear, while
> your 'return TRUE' is active when htmlview images fail
> (DTM_IMAGEFAIL).
> this is my windowproc when processing htmlview images (notice the
> return value after set the images using DTM_SETIMAGE).
>

1. As you can see in my code after else there isn't any {} - so after "else"
only DTM_IMAGEFAIL is executed, return TRUE is executed always (the same
effect is when I enter return (LRESULT)1; )

2. Maybe problem lies somewhere else?
--
regards,
Marcin



Re: HTML View - images? by Riki

Riki
Thu Jan 27 12:16:43 CST 2005

i though your line that says '>other message handler' contains line to
process the default message like :
return CView::WindowProc(message, wParam, lParam);

maybe this is occur when you passed WM_NOTIFY with two levels up.

or you can try to subclass the htmlview to your own windproc with
setwindowlong

regards,
Riki Risnandar


"Marcin" <mparka@NOSPAM.elka.pw.edu.pl> wrote in message
news:ctb08t$uup$1@mamut1.aster.pl...
> Riki Risnandar wrote:
>> try to add the 'return TRUE' after the line :
>>>
> SendMessage(((NM_HTMLVIEW*)lParam)->hdr.hwndFrom,DTM_SETIMAGE,0,(LPARAM)&img
>>> Info);
>> your code still processing the rest of the '> other message handlers'
>> or the normal windowproc which cause the images dissappear, while
>> your 'return TRUE' is active when htmlview images fail
>> (DTM_IMAGEFAIL).
>> this is my windowproc when processing htmlview images (notice the
>> return value after set the images using DTM_SETIMAGE).
>>
>
> 1. As you can see in my code after else there isn't any {} - so after
> "else"
> only DTM_IMAGEFAIL is executed, return TRUE is executed always (the same
> effect is when I enter return (LRESULT)1; )
>
> 2. Maybe problem lies somewhere else?
> --
> regards,
> Marcin
>
>



Re: HTML View - images? by Marcin

Marcin
Thu Jan 27 13:19:10 CST 2005

Riki Risnandar wrote:
> i though your line that says '>other message handler' contains line to
> process the default message like :
> return CView::WindowProc(message, wParam, lParam);
>

No, I meant: other msg handlers eg. WM_COMMAND, WM_PAINT etc... I am not
using any of default message handlers like DefWindowsProc() or DefDlgProc().

This is standard Dialog (hDlg) -> thent tab control is cerated as its child
window and then html view control as child of tab - WM_NOTIFY is passed two
levels down to DlgProc but I am not sure if this procedure returns LRESULT
two levels up correctly to control.

I have done one more test - created html view as child for hDlg (so, there
was one level down/up)- result was the same - and have no idea what is
happening. Maybe I will try to create some simple app and test only such a
case - "diplaying images on html view".

> maybe this is occur when you passed WM_NOTIFY with two levels up.
>
> or you can try to subclass the htmlview to your own windproc with
> setwindowlong
>

Thanks for help - I will try.

regards,
Marcin



Re: HTML View - images? by Marcin

Marcin
Thu Jan 27 14:04:57 CST 2005

If I create html view as child for main window (hWnd) - and handle WM_NOTIFY
in its window procedure, everything is working fine.

So, situation:

hWnd->hDlg->hTab->hHTMLView or hWnd->hDlg->hHTMLView is causing problems

but

hWnd->hHTMLView is OK

Could someone give an explanation why such a situation happens? - maybe
dialogs, controls should be created with some "special" window style?

regards,
Marcin