How to show multilple images in child window of Firebreath plugin window?

137 views
Skip to first unread message

Yoganathan Venkatesan

unread,
Apr 25, 2013, 11:00:02 AM4/25/13
to firebre...@googlegroups.com
Hi,

   We have successfully loaded the image into child window within the firebreath plugin window. I did this to show the images with scroll bar options as per suggestion given by John Tan and Neil. But the problem is if we scanned more than one images the first image alone getting loaded the others are not displayed. We have followed the below steps

1. Create Child Window.
hChildWin = CreateWindowEx(
        WS_EX_WINDOWEDGE,                                    //Extended Window Styles - WS_OVERLAPPEDWINDOW, WS_OVERLAPPED
        className.c_str(),                                //window class name
        winName.c_str(),                                //window caption
        WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL,    //window style 
        0,                                                //initial x position
        0,                                                //initial y position
        iChildWinWidth,                                    //initial x size
        iChildWinHeight,                                //initial y size
        hParentWin,                                        //parent window handle
        NULL,                                            //window menu handle
        hInstance,                                        //program instance handle
        NULL                                            //creation parameters
        );   


2. Get the physical path of scanned images into array and show that images into Device context using WM_PAINT message of ChildWindow_Proc.

HDC hdc = GetDC(hChildWin);
RECT Rect;   
GetWindowRect(hChildWin, &Rect);

for (int i = 0; i < g_arrFiles.size(); ++i)  //Scanned images file path in array.
{
//1.getting bitmap info from scanned images here to show that in child window.
.........

//2. Begin the paint
PAINTSTRUCT ps;
hdc = ::BeginPaint(hChildWin, &ps);

//3. Paint the image into device context
StretchDIBits(hdc, 0, iNextPagePos, iRectWidth, iRectHeight, 0, 0, cxDib, cyDib, pBits, pbmi, DIB_RGB_COLORS, SRCCOPY);

EndPaint(hChildWin, &ps);

}

Here iNextPagePos = No.Of.Files * EachImageHeight; // to draw the image one by one in child window(or HDC).

Please give me the suggestion for below my doubts.

1. Is there any code statement I did missed here to show all the images in single child window.
2. If so please let me know how to show all the images in single child window.
3. Its also so helpful if there is another work around for this task.

Thanks,
Yoga V
yoga...@gmail.com

John Tan

unread,
Apr 25, 2013, 11:48:56 AM4/25/13
to firebre...@googlegroups.com
Since the first image works, how about try out duplicating the first image? From the code, I can't see any problem though

Neil Griffiths

unread,
Apr 25, 2013, 12:31:21 PM4/25/13
to firebre...@googlegroups.com
There's nothing that leaps out at me as being wrong... But this statement does:

"Here iNextPagePos = No.Of.Files * EachImageHeight; // to draw the image one by one in child window(or HDC)."

Doesn't this imply that iNextPagePos is going to be a constant number and so you're only going to be rendering to the same position?

Also, are you sure that cxDib and cyDib are initialized correctly to the width of the images?



--
 
---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Yoganathan Venkatesan

unread,
Apr 25, 2013, 1:08:44 PM4/25/13
to firebre...@googlegroups.com
->John Tan... I have experimented what you have suggested(duplicate first image) here but my unfortunate time its also not working? :-(

->Neil.
1. Doesn't this imply that iNextPagePos is going to be a constant number and so you're only going to be rendering to the same position?
No Neil.. I have checked that. Its getting different values based on file array index value and image height.
iNextPagePos = arrFiles[i] * image height;
Example:
iNextPagePos = 0 * 870;
iNextPagePos = 1 * 870;
iNextPagePos = 2 * 870;

2.
Also, are you sure that cxDib and cyDib are initialized correctly to the width of the images?
Yes... its getting configured correctly to 'ImageWidth' and 'ImageHeight' respectively.

Neil or John Tan.. My doubts are :-(
Is single hdc will be enough to create multiple images? or
do we need to create each new hdc for each images by declaring the below code into 'for' loop?
do we also need to workout for WM_VSCROLL action of child window?

for (int i = 0; i < g_arrFiles.size(); ++i)  //Scanned images file path in array.
{
HDC hdc = GetDC(hChildWin);
RECT Rect;   
GetWindowRect(hChildWin, &Rect);
....
.....
}

Thanks lot 
Neil and John for your reply.

Regards,
Yoga V
yoga...@gmail.com




John Tan

unread,
Apr 25, 2013, 6:31:12 PM4/25/13
to firebre...@googlegroups.com
No, you don't need multiple hdc for multiple images. Even if you call getdc multiple times, the value will be the same.
Just to confirm something, when you said only the first image work, you mean the vscrollbar does appear but when you scroll down, it doesn't show the 2nd image? or is it that the vscrollbar doesn't even show thus unable to scroll down?

John Tan

unread,
Apr 25, 2013, 8:03:43 PM4/25/13
to firebre...@googlegroups.com
Ah, I think I know why now.... You need to add CS_VREDRAW and CS_HREDRAW in your RegisterClass, which you probably didn't add...

Yoganathan Venkatesan

unread,
Apr 26, 2013, 1:34:21 AM4/26/13
to firebre...@googlegroups.com
John even you could not see my whole code your gave me a suggestion for my problem Thank you very much. We have already used this option too when register the class style. Please kindly refer my below code. The both H & V scroll bars are appeared.
Note: After I handled the action of scroll bars in winproc using WM_VSCROLL message I m able to move my scroll bar up and down but second image is not shown.

wc.cbSize        = sizeof(WNDCLASSEX);
        wc.style         = CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE | CS_SAVEBITS;
        wc.lpfnWndProc   = &CImgWindow::ImgWinProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = hInstance;
        wc.lpszMenuName  = NULL;
        wc.lpszClassName = className.c_str();
        wc.hIcon = NULL;
        wc.hCursor = NULL;
        wc.hIconSm = NULL;
        wcAcsysImg.hbrBackground = NULL;


hChildWin = CreateWindowEx(
        WS_EX_WINDOWEDGE,                                    //Extended Window Styles - WS_OVERLAPPEDWINDOW, WS_OVERLAPPED
        className.c_str(),                                //window class name
        winName.c_str(),                                //window caption
        WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL,    //window style 
        0,                                                //initial x position
        0,                                                //initial y position
        iChildWinWidth,                                    //initial x size
        iChildWinHeight,                                //initial y size
        hParentWin,                                        //parent window handle
        NULL,                                            //window menu handle
        hInstance,                                        //program instance handle
        NULL                                            //creation parameters
        ); 

ShowWindow(hChildWin, SW_SHOWNORMAL);
    UpdateWindow(hChildWin);

while (GetMessage (&msg, NULL, 0, 0))
    {
        TranslateMessage (&msg) ;
        DispatchMessage (&msg) ;
    }

return msg.wParam ;

Thanks,
Yoga V

John Tan

unread,
Apr 26, 2013, 1:50:05 AM4/26/13
to firebre...@googlegroups.com
Hmmm..... I'm out of idea at this point of time......
 
You can probably try out, drawing something outside the first image like TextOut(hdc, ...) or Rectangle(hdc, ...), just to make sure drawing on the scrolled area works.

John Tan

unread,
Apr 26, 2013, 1:54:51 AM4/26/13
to firebre...@googlegroups.com
Wait, I'm curious though, why is there a need to add this:
 
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
The above is not necessary. WinProc should already be handling all the messages. You can try adding a beep/log/breakpoint on your WM_VSCROLL to make sure that this message really gets called.
 

Yoganathan Venkatesan

unread,
Apr 26, 2013, 2:37:16 AM4/26/13
to firebre...@googlegroups.com
Yes John your right the below part of code is not really necessary I removed it now. but its not the reason for this problem. Now i should really need to crush my head to find out the bug or solution to make it work perfectly. Hope it will not be so tough... I will post my doubt or result back. :-)

Thanks,
Yoga V

John Tan

unread,
Apr 26, 2013, 2:44:21 AM4/26/13
to firebre...@googlegroups.com
Put a beep in your WM_VSCROLL to verify it really gets called. If it does gets called, try calling InvalidateWindow to force the repaint. This will most like cause the image to flicker but at this point of time, it should be bug tracking and isolation purpose...

Yoganathan Venkatesan

unread,
Apr 26, 2013, 2:56:51 AM4/26/13
to firebre...@googlegroups.com
My WM_Scroll action is working correctly John. I put the break point their and analyzed, its working what i expected.. but the image is getting flickering and also only one image alone be displayed in the child window. Do I need to use strchBlt or BitBlt to avoid flickering during scroll? Thats what I m doing noew please confirm my doubt.

Thanks,
Yoga V

John Tan

unread,
Apr 26, 2013, 3:03:09 AM4/26/13
to firebre...@googlegroups.com
I can't advice you on how to avoid the flickering as my knowledge is not tip-top on blitting stuff. I believe, it's something to do with managing the WM_ERASEBKGND message.
 
Anyway, could you try TextOut(hdc, ...) on those scrollable areas?

Yoganathan Venkatesan

unread,
Apr 26, 2013, 3:19:50 AM4/26/13
to firebre...@googlegroups.com
I will try out TextOut and let you know soon John.

Thanks
Yoga V

Yoganathan Venkatesan

unread,
Apr 26, 2013, 3:37:46 AM4/26/13
to firebre...@googlegroups.com
Jhon I have tried out but still not able to get text in next page only first page alone showed. I am examining my code to know where could i probably did mistake.

Thanks,
Yoga V

John Tan

unread,
Apr 26, 2013, 3:39:58 AM4/26/13
to firebre...@googlegroups.com
I'm really out of idea now.... but safe to say, it's not the stretchblt's problem...

Yoganathan Venkatesan

unread,
Apr 26, 2013, 5:22:03 AM4/26/13
to firebre...@googlegroups.com
Hi John & Neil... :-)

I did the one black mistake in my code that was the problem for this.

I painted the images within for loop that was the reason of this problem.


for (int i = 0; i < g_arrFiles.size(); ++i)  //Scanned images file path in array.
{
//1.getting bitmap info from scanned images here to show that in child window.
.........

//2. Begin the paint
PAINTSTRUCT ps;
hdc = ::BeginPaint(hChildWin, &ps);


//3. Paint the image into device context
StretchDIBits(hdc, 0, iNextPagePos, iRectWidth, iRectHeight, 0, 0, cxDib, cyDib, pBits, pbmi, DIB_RGB_COLORS, SRCCOPY);

EndPaint(hChildWin, &ps);

}

Thanks lot for your prompt reply John and Neil.



Thanks,
Yoga V

Yoganathan Venkatesan

unread,
Apr 26, 2013, 5:28:38 AM4/26/13
to firebre...@googlegroups.com
John your textOut() idea is very helpful to solve this issue. :-)

Thanks,
Yoga V

John Tan

unread,
Apr 26, 2013, 5:28:45 AM4/26/13
to firebre...@googlegroups.com
Yea, the BeginPaint and EndPaint should be outside the loop. I should be called only once per WM_PAINT call.

John Tan

unread,
Apr 26, 2013, 5:30:34 AM4/26/13
to firebre...@googlegroups.com
Glad that it helped..... ^^
Reply all
Reply to author
Forward
0 new messages