Alex
Mon Mar 14 12:08:23 CST 2005
In order for the screen elements to redraw you need the message processing
to occur/
Have you tried to run a message loop inside? Something like:
MSG msg;
while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
This is a bit oversimplifed, but should get you started. In MFC app you
would to somthing similar to this:
while ( bDoingBackgroundProcessing )
{
MSG msg;
while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if ( !PumpMessage( ) )
{
bDoingBackgroundProcessing = FALSE;
::PostQuitMessage( );
break;
}
}
// let MFC do its idle processing
LONG lIdle = 0;
while ( AfxGetApp()->OnIdle(lIdle++ ) )
;
// Perform some background processing here
// using another call to OnIdle
}
A shortcut would be to call UpdateWindow() on your control which you just
updated with new text.
--
Alex Feinman
---
Visit
http://www.opennetcf.org
"JG" <jginfo@infonet.com.pl> wrote in message
news:uGdy8OLKFHA.3552@TK2MSFTNGP12.phx.gbl...
> thanks, you try to help
>
> I think the problem is in another point.
> I notice that when I start to execute the function (see previous post)
> it completely lock the screen refresh.
> I can nothing change on screen until the whole image was read and
> displayed.
>
> That's why, after I see only thte total number of bytes.
>
> Any possibility to break the locking.
>
> I tried to break in this way, but it is not working:
> dwBufferMax = 1024 and image has more than 300k
>
> static DWORD CALLBACK GetImageData(LPSTR szBuffer, DWORD dwBufferMax,
> LPARAM lParam)
> {
> DWORD dwNumberOfBytesRead;
>
> if ( (HANDLE)lParam != INVALID_HANDLE_VALUE )
> {
> ReadFile(
> (HANDLE)lParam,
> szBuffer,
> dwBufferMax,
> &dwNumberOfBytesRead,
> NULL);
> }
>
> Sleep(10);
> map_readsize += (int)dwNumberOfBytesRead;
> InvalidateRect(g_hWnd,NULL,FALSE);
> return dwNumberOfBytesRead;
> }
>
> I see the correct image total bytes as the value of map_readsize
> but nothing change before.
>
>
> "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
> news:uNmMj2yJFHA.2136@TK2MSFTNGP14.phx.gbl...
>> Out of curiosity - how big was the buffer passed to your function
>> (dwBufferMax) and how big was the bitmap itself?
>>
>> --
>> Alex Feinman
>> ---
>> Visit
http://www.opennetcf.org
>> "JG" <jginfo@infonet.com.pl> wrote in message
>> news:%23nTohbvJFHA.508@TK2MSFTNGP12.phx.gbl...
>>>I tried too.
>>>
>>> static DWORD CALLBACK GetImageData(LPSTR szBuffer, DWORD dwBufferMax,
>>> LPARAM lParam)
>>> {
>>> DWORD dwNumberOfBytesRead;
>>>
>>> if ( (HANDLE)lParam != INVALID_HANDLE_VALUE )
>>> {
>>> ReadFile(
>>> (HANDLE)lParam,
>>> szBuffer,
>>> dwBufferMax,
>>> &dwNumberOfBytesRead,
>>> NULL);
>>> }
>>> else return 0;
>>>
>>> mapsize += (int)dwNumberOfBytesRead;
>>> InvalidateRect(g_hWnd,NULL,FALSE);
>>> Sleep(50);
>>> return dwNumberOfBytesRead;
>>> }
>>>
>>> but, I got only the final size after the image was opened. nothing in
>>> the meantime.
>>> how to see the size in progress? any idea?
>>>
>>> "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
>>> news:uDF0$CrJFHA.3832@TK2MSFTNGP12.phx.gbl...
>>>> Since you provide GetImageData function yourself, why don't you use the
>>>> current read position as your progress indicator?
>>>>
>>>> --
>>>> Alex Feinman
>>>> ---
>>>> Visit
http://www.opennetcf.org
>>>> "JG" <jginfo@infonet.com.pl> wrote in message
>>>> news:%23kF50CpJFHA.2752@TK2MSFTNGP10.phx.gbl...
>>>>> is any possibility to get a value progress of the bitmap loading from
>>>>> the function:
>>>>>
>>>>> static void CALLBACK ImageProgress(IImageRender *pRender, BOOL
>>>>> bComplete, LPARAM lParam)
>>>>> {
>>>>> InvalidateRect(g_hWnd,NULL,FALSE);
>>>>> if(bComplete)
>>>>> {
>>>>> SetCursor(NULL);
>>>>> }
>>>>> }
>>>>>
>>>>> as the callback of:
>>>>>
>>>>> ....
>>>>> dii.crTransparentOverride = (UINT) -1;
>>>>> dii.pfnGetData = GetImageData;
>>>>> dii.pfnImageProgress = ImageProgress;
>>>>>
>>>>> hr = DecompressImageIndirect(&dii);
>>>>>
>>>>>
>>>>>
>>>>> I tried:
>>>>> bitmap_size = (int)lParam;
>>>>>
>>>>> but this it not wroking.
>>>>>
>>>>
>>>
>>>
>>
>
>