MDIChildred collection and security


Author
Message
Randy Jean
Randy Jean
StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
Scenario:

MDI application where in my launchform method I have:





Private Sub LaunchForm(ByVal FormType As System.Type)

'-- Establish Locals



For Each f As Form In Me.MdiChildren

If Not String.IsNullOrEmpty(f.Name) Then

If f.Name.ToUpper = FormType.Name.ToUpper Then

MessageBox.Show("Form """ & f.Text.Trim() & """ already running.")

Exit Sub

End If

End If

Next



Dim loForm As Form



'-- Create the form

Try



loForm = CType(Activator.CreateInstance(FormType), Form)



'-- Set the MDI parent

loForm.MdiParent = Me



'-- Add a handler to the form close

' AddHandler loForm.FormClosed, AddressOf HandlefFormClosed





'-- Show the form

loForm.Show()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try



End Sub





As we do not want users to be able to launch the same form twice. This works well except when a user does not have access to a form based on the ViewSecurityKey and then another user signs in after a call to SessionLock.LockSession using F11 - this new user may have access to the same form the other user did not, but when they try to launch it it says it's already running because its still in the MDIChildren collection even though it is not visible anymore - So, when a user gets "access denied" what really happens to the form as it doesn't appear to completely get released.



Thanks,

Randy
Replies
Randy Jean
Randy Jean
StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
Thanks Edhy,

This may be something I can use. I originally was not displaying a message but they asked for a message saying form was already running. But bringing it to front makes sense if you're not displaying a message.



So, I'm still trying to figure out how to generically check the security on a form before I show it. Seems I can check the specific permission if I know its name but I hate hard-coding that somewhere. I think the ViewSecurityKey is a hidden/private property.



So, my other question is: how the heck do I put code in here so it still looks like code with coloring, etc. I just used the code tag but obviously that didn't work well...



Thanks,

Randy
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Randy Jean (04/17/2008)

So, my other question is: how the heck do I put code in here so it still looks like code with coloring, etc. I just used the code tag but obviously that didn't work well...

Use the [codesnippet][/codesnippet] link from the left of the message panel and for the tabs I manually add 5 spaces to format it nicelyBigGrin.  I copy the code from the VS IDE and that is pasted here with the colors.

Edhy Rijo

Randy Jean
Randy Jean
StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)StrataFrame User (233 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
Thanks Edhy. OK, I figured out how to test the ViewSecurityKey in a generic way before showing the form. Its working great! Any thoughts on if there is a better way are appreciated.





loForm = CType(Activator.CreateInstance(FormType), Form)

If TypeOf loForm Is MicroFour.StrataFrame.UI.Windows.Forms.StandardForm Then

If SecurityBasics.CurrentUser.GetPermission(CType(loForm, _

MicroFour.StrataFrame.UI.Windows.Forms.StandardForm).ViewSecurityKey.Trim()).Action = _

PermissionAction.Deny Then



MessageBox.Show("Access Denied", "Access has been denied to " & loForm.Text.Trim() & ".", _

MessageBoxButtons.OK, MessageBoxIcon.Stop)

Exit Sub

End If

End If





Still can't figure out why my code looks so bad when I copy/paste. I'm using the codesnippet tags now.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
It depends on how you have your IDE setup to copy from the code window.  However, the CodeSnippet tag just strips formatting with a PRE tag so that we don't have other tags bring down the forum...this happened a while back.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Randy Jean - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Randy Jean - 17 Years Ago
Edhy Rijo - 17 Years Ago
Randy Jean - 17 Years Ago
                         [quote][b]Randy Jean (04/17/2008)[/b][hr] So, my other question is:...
Edhy Rijo - 17 Years Ago
                             Thanks Edhy. OK, I figured out how to test the ViewSecurityKey in a...
Randy Jean - 17 Years Ago
                                 It depends on how you have your IDE setup to copy from the code...
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search