|
-
Jun 9th, 2000, 04:25 AM
#1
I have an ActiveX Control. and I want to resize it when you hit a button on it.
Currently what happens is that when I click the button, it take two clicks before it resizes. The first click it does nothing. On the second click the control resizes correctly.
once it's resized i only need to click it once again for it to size back to normal.
So assume it's width is 400 and the height is 400
when i click on it, i want to width to be 400 and the height to be 200. when i click the button again, it should size back to 400x400
i use this code with a command button for simplicity
Private Sub Command1_Click()
If UserControl.Height = 400 Then
Size 400, 200
Else: Size 400, 400
End If
End Sub
Any help would be appreciated. btw, how does one get teh VB to look like the code layout on the forum?
-
Jun 9th, 2000, 04:37 AM
#2
Are you using a CommandButton or some other Control? I find that it takes 2 clicks for an Image Control to get it's Click event to trigger.
-
Jun 9th, 2000, 04:38 AM
#3
it's a command button, but the actual implementation will be an image.
-
Jun 9th, 2000, 05:12 AM
#4
gargamehl,
it could be, that you are facing scaling problems. under normal circumstances, if you resize you control's width to 400 twips and then query the widh property it shows a different value (405 on my machine), since the twips are being rounded to pixels internaly. i hope the following example will point you in the right direction:
'**********************************************************
Option Explicit
Private mlngWidth As Long
Private mlngHeight As Long
Private mlngAltHeight As Long
Private Sub UserControl_Initialize()
With Screen
mlngWidth = (400 \ .TwipsPerPixelX) * .TwipsPerPixelX
mlngHeight = (400 \ .TwipsPerPixelY) * .TwipsPerPixelY
mlngAltHeight = (200 \ .TwipsPerPixelY) * .TwipsPerPixelY
End With
End Sub
Private Sub Command1_Click()
With UserControl
If .Height = mlngHeight Then
.Size mlngWidth, mlngAltHeight
Else
.Size mlngWidth, mlngHeight
End If
End With
End Sub
-
Jun 9th, 2000, 05:34 AM
#5
First off i'm going to be more detailed about what i'm doing. I want the control to shrink when i click on a button and then expand when i click on it again.
So it starts out expanded. and when i click on it, it won't shrink until i clck on it again.
thus requiring two clicks to shrink but only one click to expand.
Sascha,
Thanks for your help. I think what you have provided for me will aid in making it size correctly. My issue is that it won't size at all until the second click.
I am actually doing the calculation in Twips i just used pixels as my example in order to simplify it.
So the real issue is whether or not I can get it to shrink correctly with only one click. Metatron alluded to the problem but didn't provide a solution yet.
Thanks.
-
Jun 9th, 2000, 07:05 AM
#6
try adding the following code to my previous snippet:
Private Sub UserControl_Show()
With UserControl
.Size mlngWidth, mlngHeight
End With
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|