[MSAccess] Resizing the control at runtime

Discussions about GdPicture.NET usage in non managed applications built in vb6, Delphi, vfp, MFC c++ etc...
Post Reply
glnoble
Posts: 11
Joined: Tue May 01, 2012 3:02 pm

[MSAccess] Resizing the control at runtime

Post by glnoble » Thu May 03, 2012 4:42 pm

We are working in Microsoft Access 2010, running Version .NET 8. We have a screen which displays id cards scanned into the system. In the previous activeX version we were able to change the size of the control and rotate the image to display the card landscape or portrait. The .NET 8 version does not seem to allow the use of .width or .height to alter the dimensions of the control? I searched the component source for a function but have not found one.


Edit: Here the solution!
Use the menu at the top to insert an activeX control. Pick the GdPicture.NET usercontrol. It will be a default size.
Then use the lower right corner and drag the size of the control to what you want. Save the form, close, then double click to open it.
Be sure you also set the anchoring on the control so windows does not try to resize it based on the form size. The control reacts badly to this. Set it to top left.
Nothing fancy but works!

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: [MSAccess] Resizing the control at runtime

Post by Loïc » Thu May 03, 2012 5:11 pm

Hello,

The resizing issue is a known problem between GdPicture.NET & MSAccess for which we currently do not have any solution.

A workaround consists to wrap the GdPciture.NET visual controls in vb6, Delphi or MFC ActiveX control. But this requires some knowledge and development time. Another solution is to port the code part of the database to vb6, vb.NET C# or something else that can correctly handles GdPicture.NET visual controls.

This problem is currently "on hold" for us, we already spent a lot of time investigating the problem. Maybe we will provide a special wrapper for MS-Access in the future. This will depend of the amount of potential user we can catch with such solution.

Thank you for you understanding.

With best regards,

Loïc

glnoble
Posts: 11
Joined: Tue May 01, 2012 3:02 pm

Re: [MSAccess] Resizing the control at runtime

Post by glnoble » Thu May 03, 2012 5:36 pm

Loic, thank you for the incredibly fast response! I will stop wasting time figuring out the problem and work towards a workaround. My initial thought is I will have two gdviewer controls and show/hide as needed depending on the orientation requested. A little extra work but no big deal.

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: [MSAccess] Resizing the control at runtime

Post by Loïc » Thu May 03, 2012 5:40 pm

You are welcome :)

I hope you will be able to find a workaround. I am here if you need any suggestion.

Regards,

Loïc

Kotti
Posts: 4
Joined: Tue Oct 08, 2013 3:55 pm

Re: [MSAccess] Resizing the control at runtime

Post by Kotti » Tue Oct 08, 2013 4:01 pm

Hello Loïc,

i'm evaluatiing GdPicture 10 - the problem still remains i think. Any chance to get a solution for that problem?

Best regards,

Kotti

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: [MSAccess] Resizing the control at runtime

Post by Loïc » Tue Oct 08, 2013 7:13 pm

Hello Kotti,

This is working like a charm for me. Are you using the latest minor release?

Kind regards,

Loïc

Kotti
Posts: 4
Joined: Tue Oct 08, 2013 3:55 pm

Re: [MSAccess] Resizing the control at runtime

Post by Kotti » Tue Oct 08, 2013 9:56 pm

Hello Loïc,

first i want to say thank you - your support is really great. I have read many threads already and your reaction time was always exemplary!

The .tlb file has no version details, so i post the .dll one's: 10.0.0.13
The MS Access version is: 14.0.7106.5001

I'm using the GdViewer control in a subform. The control has the full size of the subform with anchors to "Both". The subform has the same anchors in the main form. The subform is sizing well, until i load a document the GdViewer control does too but after i load a document it "oversizes" - the document is at the right bottom and i can only see the upper left corner of the document. Perhaps there's a property or a method to correct this beahvior but i didn't found anything in the documentation.

Hopefully you understand my gibberish description :wink: .

Best regards,

Kotti

Kotti
Posts: 4
Joined: Tue Oct 08, 2013 3:55 pm

Re: [MSAccess] Resizing the control at runtime

Post by Kotti » Wed Oct 09, 2013 11:52 am

Hello Loïc,

short update to this topic - with the following lines of code it's already close to what i like to have:

Code: Select all

oGdViewer.DocumentAlignment = ViewerDocumentAlignment_DocumentAlignmentTopCenter
oGdViewer.DocumentPosition = ViewerDocumentPosition_DocumentPositionTopCenter
oGdViewer.ZoomMode = ViewerZoomMode_ZoomModeHeightViewer
The problem of "control oversizing" still remains. I assume that the control set its width to the maximum possible on the current monitor resolution. If i resize my form's width to about half of my screen, the control doenst resize too. The anchors don't work. Further the height of the control exceeds the forms height.

Thanks in advance!

Best regards,

Kotti

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: [MSAccess] Resizing the control at runtime

Post by Loïc » Wed Oct 09, 2013 4:20 pm

Hello Kotti,

First, thank you very much for your feedback.
The anchors don't work. Further the height of the control exceeds the forms height.
Unfortunately there is nothing we can do to control this behavior. The width and height of the control are computed by MS-Access and not by GdPicture. This is a known issue and the only solution that we can suggest is to don't use the anchor mechanism when .NET components.

Thank you for your understanding.

With best regards,

Loïc

Kotti
Posts: 4
Joined: Tue Oct 08, 2013 3:55 pm

Re: [MSAccess] Resizing the control at runtime

Post by Kotti » Wed Oct 09, 2013 5:13 pm

Hello Loïc,

i created some diferent subforms for different standard fullscreen resolutions and load them into my main form dependent on the main forms size. It's a workaround but not a completely satisfying one.

What's about this solution i found here (quoted below): http://social.msdn.microsoft.com/Forums ... =vbinterop

Sound's pretty easy to implement - if it's really working :wink:. Is it worth trying out for you? Would be a great feature for me and perhaps you make some already existing or future customers very happy. Futher i want to offer my assistance for testing or what else could be helpful for you.
I have found a partial solution. It will work if your Interop UserControl is placed on an Access form.

Even though you can't programatically resize the Interop UserControl, you can set its Horizontal Anchor and Vertical Anchor properties to "Both" and the Access form will then cause the UserControl to be resized when the form is resized. The problem is that Access causes the UserControl to become way bigger than the form its on.

Here's the workaround:

Create a new Interop UserControl in .NET. Add a panel to the control. Place all your other controls on the panel.

Add a Rezise method that will be called from Access:

Code: Select all

Public Sub ResizeInTwips(Optional ByVal Width As Integer = -1, Optional ByVal Height As Integer = -1)
	If Width > 0 Then
		Panel1.Width = ConvertTwipsToPixels(Width, 0)
	End If
	If Height > 0 Then
		Panel1.Height = ConvertTwipsToPixels(Height, 1)
	End If
End Sub
<DllImport("user32.dll")> _
Private Shared Function GetDC(ByVal hwnd As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")> _
Private Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Boolean
End Function
<DllImport("gdi32.dll")> _
Public Shared Function GetDeviceCaps(ByVal hDC As IntPtr, ByVal nIndex As Integer) As Integer
End Function

Const WU_LOGPIXELSX = 88
Const WU_LOGPIXELSY = 90

Function ConvertTwipsToPixels(ByVal intTwips As Integer, ByVal intDirection As Integer) As Integer

	Static bGotDC As Boolean = False

	Static intDC As Integer
	Static intPixelsPerInchHorizontal As Integer
	Static intPixelsPerInchVertical As Integer

	If Not bGotDC Then
		intDC = GetDC(0)
		intPixelsPerInchHorizontal = GetDeviceCaps(intDC, WU_LOGPIXELSX)
		intPixelsPerInchVertical = GetDeviceCaps(intDC, WU_LOGPIXELSY)
		intDC = ReleaseDC(0, intDC)
		bGotDC = True
	End If

	Dim intPixelsPerInch As Integer

	Const nTwipsPerInch = 1440

	If (intDirection = 0) Then   'Horizontal
		intPixelsPerInch = intPixelsPerInchHorizontal
	Else              'Vertical
		intPixelsPerInch = intPixelsPerInchVertical
	End If

	Return (intTwips / nTwipsPerInch) * intPixelsPerInch

End Function
Add your Interop UserControl to the Access form.

In the Access form, add the following code:

Code: Select all

Private Sub Form_Resize()

InteropUserControl1.ResizeInTwips Me.InsideWidth, Me.InsideHeight

End Sub
That's all there is to it.

It works for me both when displaying the form as normal or making it a popup form.

If you need your Interop UserControl not to take up the whole Access form, you can put it in a subform.
With best regards,

Kotti

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: [MSAccess] Resizing the control at runtime

Post by Loïc » Sun Oct 13, 2013 9:01 pm

Hello Kotti,

I've tried the "workaround" without success. A solution, if you really want to stay in MS access for your GUI, is to wrap GdPicture usercontrols in a vb6, Delphi or MFC activex. But this sounds a little bit more to just support the buggy anchor feature of the MS access COM container...
I always try to convince my customers to use a strong environment of development (visual studio and embarcadero are my favorites) to create GUI. This is not a big challenge, especially since vb.net can be very easy to use, for free :) And keep access only to store small volume of data in database.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest