1. Toan Nguyen
  2. PowerBuilder
  3. Friday, 7 July 2023 16:02 PM UTC

Hello Everyone,

Roland Smith - Thank you for sharing your canvas application. I managed to modify your sample application to implement the picture control to display passport image in my application.

Another requirement for my application is as user zooms in/out of the picture image, vertical/horizontal scrolling should be supported so user can see the zoomed information on the image.

I added the VScrollBar and HScrollBar to the User Object but 

If anyone has implemented the scrolling functionality successfully for User Object, can you share the codes with me?

Thank you very much in advance.

Tony Nguyen

 

 

Attachments (2)
Accepted Answer
Toan Nguyen Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 22:32 PM UTC
  2. PowerBuilder
  3. # Permalink

Hello Miguel,

Thanks for responding to my question.

Basically, the scrolling works when we have a picture control in a user object like in my previous sample.

In Roland's canvas app, the image is directly placed in the visual user object so the scrolling doesn't do anything.

So, in the latest sample app, I have 2 user objects, vuo_photo and vuo_photo_pic.

vuo_photo is basically what is in the canvas application. In the vuo_photo_pic, I added the picture control to the user object and tried but UNSUCCESSFULLY placing the image in this control.

I don't understand the GDIPlus API calls to modify the codes to place the image in the picture control instead of the user object itself.

I attached the updated application for you to have a look. 

Hopefully, you can help me resolving my issues.

Thanks again.

Tony

Attachments (1)
Comment
  1. Miguel Leeuwe
  2. Wednesday, 12 July 2023 02:11 AM UTC
Hi Tony,

I don't understand the GDI stuff either regretfully. What I do know, is that all of the External Function declarations have to be revised to use Lonptr data types for all Hwnd parameters and in the calls towards them. Not sure if that might be of any influence?

regards
  1. Helpful
  1. Roland Smith
  2. Wednesday, 12 July 2023 12:51 PM UTC
All my examples come with PB 10.5 and PB 12.6 versions. The 12.6 version should already have LongPtr variables for 64bit support.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Wednesday, 12 July 2023 16:31 PM UTC
Thanks Roland, so Tony isn't using your 12.6 version then.
  1. Helpful
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Wednesday, 12 July 2023 16:15 PM UTC
  2. PowerBuilder
  3. # 1

Hi Roland,

Thanks for responding to my question.


Since the app allows panning with the mouse to move the picture then I think it is a good alternative to scrolling functionality. 

Again, greatly appreciate all the responses and suggestions from you, Miguel and Chris on this issue.

Regards,

Tony

 

Comment
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Wednesday, 12 July 2023 02:41 AM UTC
  2. PowerBuilder
  3. # 2

Hi Miguel,

Once again, thanks for taking your time to look into my issues.

In the sample apps, the vuo_photo_pic user object has the picture control so if somehow I can get the image to load into this control then the scrolling will work.

That's my dilemma. Roland's canvas application loads the image directly into the user object (vuo_photo in the sample app) so the scrolling doesn't work in this case.

I am hoping Roland can take a look at my sample app when he has a chance and modify the user object to use the picture control for display.

Thanks,

Tony

Comment
  1. Roland Smith
  2. Wednesday, 12 July 2023 13:15 PM UTC
The whole point of the canvas app is to display images without using the built-in picture control so I don't see why that would be a good idea. If the built-in picture control works better, just use that.

The canvas picture control allows for panning with the mouse. You could just tell the end users that they can use the mouse to move the picture.
  1. Helpful 1
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 20:48 PM UTC
  2. PowerBuilder
  3. # 3

Hi Miguel and Roland,

Miguel - Follow your suggestion, in the sample application, I deleted all the codes inside the user events (H & V), the scroll works fine. Thank you.

Roland,

In your canvas application, I added  a picture control to the u_cst_picture. That way the image will be displayed inside the picture control and scrolling will work like in my sample application

However, I am running into issues when trying to load the image into the picture control. 

I was wondering if this is something simple you can help me with?

Thanks in advance.

Regards,

Tony

Comment
  1. Miguel Leeuwe
  2. Tuesday, 11 July 2023 21:08 PM UTC
yw,

What " issues when trying to load the image into the picture control."? Can you describe what you do, or event better: add it to the sample app to illustrate what you are trying to do?

regards.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 17:36 PM UTC
  2. PowerBuilder
  3. # 4

Lol,

The solution was easier than expected.

I've imported your sample application into PB2019 R3 (latest build) and it would also blow up after doing a single initial scroll.

 

The solution:

Delete all of the code in you h and -vscroll events and then run it. For me it works!!

Comment
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 16:59 PM UTC
  2. PowerBuilder
  3. # 5

Hi Roland,

Just curios, when you said "When I tried activating scrollbars to the picture control in my Canvas example, they don't do anything. No abort. This is PB 10.5 by the way."

Did you add the call to Send() in the scripts for the pbm_vscroll and pbm_hscroll user events?

For pbm_vscroll, Send(Handle(this), 277, scrollcode, scrollpos)

For pbm_hscroll, Send(Handle(this), 276, scrollcode, scrollpos)

The call crashes the application when moving the scrollbar controls.

Thanks,

Tony

Comment
  1. Miguel Leeuwe
  2. Wednesday, 12 July 2023 00:01 AM UTC
I think that doing the Send within the scroll events somehow triggers the event itself again, thus creating an infinite loop until it crashes?

Not sure, just a thought.
  1. Helpful
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 16:47 PM UTC
  2. PowerBuilder
  3. # 6

Hi Roland,

Thanks for responding to my question.

The Send() function calls in the script for pbm_vscroll and pbm_hscroll user events crash the application in both PB2017R3 and PB2019R3.

To further test this out, I added the scroll bars to the window object and the application also crashes here as well.

Do you think this is a bug in PowerBuilder?

As far as your suggestion of calling of_MousePan(x,y) function to reposition the photo, I tried but did not seem to do much.

For example, for vertical scrolling, of_MousePan(0, scrollcode) and horizontal scrolling, of_MousePan(scrollcode, 0). 

Am I doing what you suggesting correctly? 

The reason I want to have the scrollbars enabled so user can see to the right and or bottom of the photo after they enlarge the picture.

Once again, thanks for taking a look at my issue.

Regards,

Tony

 

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 15:39 PM UTC
  2. PowerBuilder
  3. # 7

When I tried activating scrollbars to the picture control in my Canvas example, they don't do anything. No abort. This is PB 10.5 by the way.

You can move the picture with the mouse.

Maybe you can use hscroll and vscroll objects and use those to reposition by calling of_MousePan. The function is private so would need to be changed to public.

Comment
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 15:10 PM UTC
  2. PowerBuilder
  3. # 8

Hi Miguel,

Thanks for respond to my question.

Follow your suggestion, I created a sample app in PB2017R3 with just a window and a user object (adding scrollbars for H & V) with a picture control.

Running the app, one will see that it crashes as soon as moving the scrollbars up/down or left/right in the user object.

The zip file for the sample app is attached here. I would appreciate anyone can take a look at the source code and let me know what I am doing wrong.

Thanks in advance!

Tony

Attachments (1)
Comment
  1. Miguel Leeuwe
  2. Tuesday, 11 July 2023 16:57 PM UTC
Hi Toan,

I'll try to see if I have some time to have a look at it.

Thank you!
  1. Helpful 1
  1. Miguel Leeuwe
  2. Tuesday, 11 July 2023 17:38 PM UTC
See my latest answer:you have to delete all of the code in your scroll events and it will work (at least in pb2019 r3).
  1. Helpful 1
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 14:06 PM UTC
  2. PowerBuilder
  3. # 9

Hi Chris,

Thanks for respond to my question.

To troubleshoot the crash in the user object caused by H/V scrolling, I created a simple user object with just a picture control and added scrollbars for H and V. Running the application, it crashes as soon as I move the scrollbars up/down or left/right. So, it doesn't look like the send() function calls in the user events are working as I thought it would like the scrolling functionality in the datawindows.

Have you or anyone been successful in implement scrolling for user objects?

I attached the screen shots of my user object for your review.

I would appreciate any ideas/suggestions to make this work.

Thanks,

Tony

Attachments (2)
Comment
  1. Miguel Leeuwe
  2. Tuesday, 11 July 2023 14:13 PM UTC
It would help if you could make a small sample app that others can try.

Maybe not very helopful, but all I know is that Send() commands in older powerbuilder versions worked a lot better than in the later versions. (For example when used to generate certain key strokes). I try to avoid the command alltogether.
  1. Helpful
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Sunday, 9 July 2023 03:16 AM UTC
  2. PowerBuilder
  3. # 10

Hi Chris,

Thanks for sharing your past project with Passport Canada.

For my application, I added the horizontal and vertical scrollbar to the user object. I created user events using pbm_vscroll and pbm_hscroll event IDs.

For the scripts, I added the calls to Send(ih_hCanvas, 277, scrollcode, scrollpos) for vertical scrolling and Send(ih_hCanvas, 276, scrollcode, scrollpos) for the horizontal scrolling.

The application crashes as soon as I move the either the vertical or horizon scroll bar at runtime.

Do you have any idea what I am doing wrong? I am attaching screen shots to show the user object.

Thanks,

Tony



Attachments (3)
Comment
  1. Chris Pollach @Appeon
  2. Sunday, 9 July 2023 03:43 AM UTC
Hi Tony;

Your Send() command offhand looks correct. I'm wondering though if it's triggering something in Roland's code that then causes the crash (just a guess).

Regards ... Chris
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 7 July 2023 17:39 PM UTC
  2. PowerBuilder
  3. # 11

HI Tony ;

  FWIW: When I used  to do PB consulting with Passport Canada, I did all this passport photo work using either the native InkEdit or InkPicture controls with no need for special coding like Roland's approach. Also, if you use the InkPicture feature in a DataWindow object then it becomes fully Zoomable & Scrollable (food for thought).  ;-)

HTH

Regards ... Chris

Comment
  1. Toan Nguyen
  2. Friday, 7 July 2023 18:05 PM UTC
Hi Chris,

Thanks for your response to my question. It's good to know about the InkPicture object in PB.

However, the main reason, I used Roland's approach is the rotating feature in the canvas application.

Did you by chance have the rotating functionality in your application?



Thanks again,



Tony



  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 7 July 2023 18:37 PM UTC
Yes, I certainly did .. flip, rotate, crop, image conversion, compression, resizing, etc - the whole "ball of wax" (enchilada - LOL).

In addition to using the InkPicture & InkEdit, features of PB, I also used the free & open source ImageMagicK software for those image manipulation features putting the image result back into the IE / IP when the required operation was completed.

FWIW:These systems even had OCR and facial recognition capabilities as well.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.