GraphicControl problem

Started by Peter Heffernan, December 26, 2013, 08:54:15 PM

Previous topic - Next topic

Peter Heffernan

Hi,

I tried using the GraphicControl on a Form to allow a user to scroll through a .PDF rather than printing it.

The GraphCtx.inc shows that I should be able to use the mouse scroll-wheel as well as keyboard keys and the scroll-bars to manipulate the screen contents. Since that appeared not to function I thought that I'd investigate using the FORM1_GRAPHICCONTROL1_CUSTOM function; but it seems that that nothing 'fires' in that function either!

Thinking that I may have a problem with my install of FF3 I re-installed the latest version to another folder and tested on that, to no avail.

Has anyone got any experience with the GRAPHICCONTROL that could shed any light on the problem that I'm having?


José Roca

The graphic control is not designed to show PDFs. You need to use an instance of the WebBrowser control and, in the custom property, enter the path of the PDF. Scrollbars and mouse wheel are managed automatically.

José Roca

Note: The graphic control (GraphCtx.inc) is designed as an easy to use control for drawing graphics. It manages scroll bars and muse wheel automatically when you set the virtual buffer to a size bigger than the size of the control. It is not suited to display very big images because it has the limitations imposed by Windows to GDI (the maximum bitmap size is 42 MB, if I remember well).

There is another control (GdipImageCtx.inc) that is designed to display images using GDI+. With it, you have to manage scroll bars and mouse wheel by yourself.

Peter Heffernan

#3
Thanks Jose, I didn't explain myself very well, I don't have an issue with either displaying the file or setting the buffer size, it's only when I use the FF3 GraphicControl that I do not get access to the mouse-wheel/keybord movement of the control. When I use the same code direct on PB I get full access to mouse/keyboard.

<Test>
Using an adapted version of one of your examples I do this:

Using FF3 create a GRAPHICCONTROL (about 300 x 300) and a BUTTON on a new Form
Set virtual height/width to match your screensize
Set GDIPlusAware to TRUE
Set Stretchable to False

Within a function FORM1_COMMAND1_BN_CLICKED I place this (adapted from one of your examples):

   Local hBitmap As Dword

   SetFocus HWND_FORM1_GRAPHICCONTROL1
   ' // Capture the desktop window and display it in the control
   hBitmap = AfxCaptureDesktopWindow
   GraphCtx_SetVirtualBufferSize(HWND_FORM1_GRAPHICCONTROL1, AfxGetBitmapWidth(hBitmap), AfxGetBitmapHeight(hBitmap))
   AfxDrawBitmap(GraphCtx_GetDc(HWND_FORM1_GRAPHICCONTROL1), 0, 0, hBitmap)
   DeleteObject hBitmap
   FF_Control_Redraw HWND_FORM1_GRAPHICCONTROL1

Once the code is run part of the desktop capture will be displayed within the GRAPHICCONTROL and Scroll-bars will be available.

When I use the mouse to select the GRAPHICCONTROL I don't have scrolling available with the mouse-wheel or the ability to use the keyboard to scroll the graphic (like I do on the PB version).
[Edit to add]
Also from within FORM1_GRAPHICCONTROL1_CUSTOM, (using a DebugPrint function that I use), if I place a DEBUGPRINT "Here", it will never get displayed.

If I create a control at runtime with something like:
hCtl = pWindow.AddGraphCtx(HWND_FORM1, %IDC_GRCTX, "", 20, 20, 300, 400)
I establish the ability of using the mouse scroll-wheel and keyboard control. It is only when I use the FF3 GraphicControl that I lose that ability.

Paul Squires

I just checked the generated source code. The code is NOT subclassing the Graphic Control and therefore will not trap any messages destined for the CUSTOM handler. Not sure why I did not allow the subclass for this control. I will check into this and add to the bug tracker.
Paul Squires
PlanetSquires Software

Paul Squires

Looks like at some point I lumped the Graphic Control in with OCX controls and the WebBrowser control which should not be subclassed. Try the attached new FireFly 3.7 to see if it works better for you.
Thanks.
Paul Squires
PlanetSquires Software

Peter Heffernan

#6
Thanks for the speedy reply Paul.

With this version I the FORM1_GRAPHICCONTROL1_CUSTOM is now firing though the scrolling is still not quite correct.

Using the above Form design:

If I use the mouse on the 'down'/'right' arrow of the scroll-bar: The captured bmp does not move.
If I use the 'down'/'right' keys on the keyboard: The captured bmp does not move.
No movement either with scrollwheel-down


Now if I drag both the scrollbar position indicators so as I am now viewing the bottom-right of the captured desktop:

If I use the mouse on the 'up'/'left' arrow of the scroll-bar: The captured bmp scrolls as expected.
If I use the 'up'/'left' keys on the keyboard: The captured bmp scrolls as expected..
The up scrollwheel movement also works as expected.

So it appears that the 'down'/'right' movements from keyboard and mouse/mouse-wheel are not being processed by the control?

Paul Squires

Hi Peter,

I just created a sample project and I have not seen any problem scrolling using the mouse or keyboard. Clicking the scrollbars works as expected and all of the keyboard naviagtion (up, down, left, right, home, end, PgUp, PgDn) all seem to function as expected.

Can you post your code that you are using in your CUSTOM handler? Maybe there is something in there that is interfering?
Paul Squires
PlanetSquires Software

Peter Heffernan

#8
Paul,

It seems:

If the 'Resizeable' option is set to False and I have VirtualH/W values entered then using GraphCtx_SetVirtualBufferSize(...) has no effect on the scrolling.

But, if the 'Resizeable' option is set to True and I have VirtualH/W values entered then by using GraphCtx_SetVirtualBufferSize(...) in code it causes the effect that I was seeing with the scrolling.

So, if I have 'Resizeable' set to True then leaving the VirtualH/W empty and relying on GraphCtx_SetVirtualBufferSize(...) does not affect the scrolling. On the other hand if 'Resizeable' is True and I use the VirtualH/W options for values then I shouldn't use the GraphCtx_SetVirtualBufferSize(...) function in code.

Thanks for the fix, and your time.
[edit to add]
The above seems to apply when both the FF3 option setting W/H are equal to the bitmap sizes from GraphCtx_SetVirtualBufferSize(...).
[Edit again to add]
I was going to create a little Project with a few examples, in way of explanation, but it seems that there is no facility to make an array from that control with copy/paste.
The resulting CODEGEN_PROJECT1_MAIN.bas file creating:

Sub FLY_InitializeVariables()   
   ' All FireFly variables relating to Forms and Controls are initialized here. This
   ' includes any Control Arrays that have been defined and control identifiers
   ' per the listing in the Declares include file.
   
    Global HWND_FORM1_GRAPHICCONTROL1() As Dword
    Dim HWND_FORM1_GRAPHICCONTROL1(0) As Global Dword
    Dim IDC_FORM1_GRAPHICCONTROL1(0) As Global Long
    IDC_FORM1_GRAPHICCONTROL1(0) = 1000
    IDC_FORM1_GRAPHICCONTROL1(0) = 1001
    IDC_FORM1_GRAPHICCONTROL1(0) = 1002
         

End Sub