what means "out of stack space"?
when i do:
Code:If lngRotate <> 0 Then UserControl.Width = GRP.Width * Screen.TwipsPerPixelX UserControl.Height = GRP.Height * Screen.TwipsPerPixelY End If
what means "out of stack space"?
when i do:
Code:If lngRotate <> 0 Then UserControl.Width = GRP.Width * Screen.TwipsPerPixelX UserControl.Height = GRP.Height * Screen.TwipsPerPixelY End If
Read MSDN description of this error.
I guess this code is in a recursive procedure.
Last edited by 4x2y; Oct 7th, 2012 at 10:01 PM.
ok. i have the resize event on usercontrol. but why i get the error only in that lines and not before(yes before that lines i resize the control. but when i use the rotate effect, i must resize the control)?
wait... you have that code in the resize event? which will also cause a resize event to be triggered... running that code... which triggers the resize event, which runs that code, which triggers the resize event, which fires off that code... you see where this is going?
-tg
* I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
*Proof positive that searching the forums does work: View Thread *
* How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
* How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
* Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
"There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
i have 1 code for show the image and resize the control(usercontrol). but if we resize the control the control(itself) activate the resize event
Code:Private Sub UserControl_Resize() On Error Resume Next If UserControl.hWnd = 0 Then Exit Sub If blnShowed = True Then Call ShowImage If (UserControl.Width <> lngOldWidth And UserControl.Height <> lngOldHeight) Then ResizeTyp = ResizeVerticalHorizontal ElseIf UserControl.Width <> lngOldWidth Then ResizeTyp = ResizeHorizontal ElseIf UserControl.Height <> lngOldHeight Then ResizeTyp = ResizeVertical End If lngOldWidth = UserControl.Width lngOldHeight = UserControl.Height RaiseEvent Resize(UserControl.Width, UserControl.Height, ResizeTyp) End Sub
When you resize the control inside its Resize event, it is fire infinity, to control this, add a flag to exit the Resize event when perform resize inside it, Ex
Code:Private Sub Form_Resize() Static blnResizing As Boolean If blnResizing Then Exit Sub' comment this line and see the difference :-) blnResizing = True Me.Width = Me.Width + Screen.TwipsPerPixelX * 8 blnResizing = False End Sub
Like i didi don't know how avoid that
I don't know if this will be compatible with your code or not, just give it a try.Code:Private Sub UserControl_Resize() Static blnResizing As Boolean ' ----------------- New Code On Error Resume Next If blnResizing Then Exit Sub ' ----------------- New Code If UserControl.hWnd = 0 Then Exit Sub If blnShowed = True Then Call ShowImage If (UserControl.Width <> lngOldWidth And UserControl.Height <> lngOldHeight) Then ResizeTyp = ResizeVerticalHorizontal ElseIf UserControl.Width <> lngOldWidth Then ResizeTyp = ResizeHorizontal ElseIf UserControl.Height <> lngOldHeight Then ResizeTyp = ResizeVertical End If lngOldWidth = UserControl.Width lngOldHeight = UserControl.Height blnResizing = True ' ----------------- New Code RaiseEvent Resize(UserControl.Width, UserControl.Height, ResizeTyp) blnResizing = False ' ----------------- New Code End Sub
Last edited by 4x2y; Oct 8th, 2012 at 08:26 AM.
and i did and works:
i have a new question that i think you can advice meCode:Private Sub UserControl_Resize() Static blnResizing As Boolean If blnResizing Then Exit Sub ' comment this line and see the difference :-) blnResizing = True On Error Resume Next If UserControl.hWnd = 0 Then Exit Sub If blnShowed = True Then Call ShowImage If (UserControl.Width <> lngOldWidth And UserControl.Height <> lngOldHeight) Then ResizeTyp = ResizeVerticalHorizontal ElseIf UserControl.Width <> lngOldWidth Then ResizeTyp = ResizeHorizontal ElseIf UserControl.Height <> lngOldHeight Then ResizeTyp = ResizeVertical End If lngOldWidth = UserControl.Width lngOldHeight = UserControl.Height RaiseEvent Resize(UserControl.Width, UserControl.Height, ResizeTyp) blnResizing = False End Sub
i want do the same to showimage() sub. but like you know, we, always, change the graphics effects properties. then how i can do that boolean way? in same way?
thanks
I cannot give you a sample code because i don't know which properties are affected by ShowImage sub, but in general if i have one ore more property i don't want to execute it when changing its value (by code), i declare a module level boolean variable, set it to true before changing the property value and false after it, and in the property or the event it is fire i check the module level boolean variable. Here is a sample i frequently use with TextBox, i hope it help you.i want do the same to showimage() sub. but like you know, we, always, change the graphics effects properties. then how i can do that boolean way? in same way?
Code:Private mblnChangedByCode As Boolean Private Sub Test() mblnChangedByCode = True Text1.Text = "Value" mblnChangedByCode = False End Sub Private Sub Text1_Change() If mblnChangedByCode = True Then Exit Sub ' Here is some code i want to execute it ONLY if the user changed the text by typing something, ' but never execute when i change the text via the Text property. End Sub