Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Elegant Ribbon Tech Support » adding license key to application Collapse All
Subject Author Date
Shaine MaGuire Feb 15, 2009 - 1:40 AM

I have an MDI application and I use subs to be able to show a relevant form by its name; however, I am attempting to add the license key to the application and I am not able to successfully do it.


The way I call a form is as follows (in a module):


 


 


 


Public Sub ShowFormNonMDI(ByVal frm As Form)With frm’centered

.StartPosition = FormStartPosition.CenterScreen


 


’above all forms

.BringToFront()


 


’show the form

.Show()


 


End With

 


End Sub

When I try to add the license key code from your site, I am getting an error message.  Pretty much, I am calling the MDI application from an authentication screen.  The way I call the form from the authentication screen is as follows:



 


 


Private Sub AuthenicateUser()’show the main application

 


ShowFormNonMDI(fMain)


 


Dim fMain As New frmMain’hide me

 


Me.Visible = False

Sub End


The error I get is:



System.InvalidOperationException: Starting a second message loop on a single thread is not a valid operation. Use Form.ShowDialog instead.


at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)


at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)


at System.Windows.Forms.Application.Run(Form mainForm)


at Customer_Relationship_Manager.modGlobal.ShowFormNonMDI(Form frm) in C:\Documents and Settings\Paddy MaGuire\Desktop\Customer Relationship Manager\Customer Relationship Manager\Modules\modGlobal.vb:line 90


at Customer_Relationship_Manager.frmAuthentication.AuthenicateUser() in C:\Documents and Settings\Paddy MaGuire\Desktop\Customer Relationship Manager\Customer Relationship Manager\Forms\frmAuthentication.vb:line 364


at Customer_Relationship_Manager.frmAuthentication.TempPasswordCheck() in C:\Documents and Settings\Paddy MaGuire\Desktop\Customer Relationship Manager\Customer Relationship Manager\Forms\frmAuthentication.vb:line 377


at Customer_Relationship_Manager.frmAuthentication.cmdLogin_Click(Object sender, EventArgs e) in C:\Documents and Settings\Paddy MaGuire\Desktop\Customer Relationship Manager\Customer Relationship Manager\Forms\frmAuthentication.vb:line 227



When I add the license key code to the form load event of the main form (where the ribbon is located), I still get the demo screen come up.  Any ideas?


 


Shaine MaGuire Feb 15, 2009 - 2:08 AM

OK, I think I have figured this out. My code looks like the following:
Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Globalization
Imports System.Windows.Forms
Imports System.Windows.Forms.Application
Imports Elegant.Ui.RibbonLicenser

Public Class frmMessagingCenter_Inbox
Shared Sub New()
LicenseKey = "Your License Key Goes Here"
End Sub

Private Sub frmMessagingCenter_Inbox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
’form layout
FormLayout(Me)

’title text
Me.Text = ProductName & " Messaging Center: Inbox"

’take the subject column and make sure the width takes up the rest of the form
With lvwInbox
Dim lvwWidth As Integer = .Width
Dim StatusColumn As Integer = .Columns(0).Width
Dim DateColumn As Integer = .Columns(1).Width
Dim TimeColumn As Integer = .Columns(2).Width
Dim FromColumn As Integer = .Columns(3).Width

.Columns(4).Width = lvwWidth - StatusColumn - DateColumn - TimeColumn - FromColumn
End With
End Sub

Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
’refresh the listview content
lvwInbox.Refresh()
End Sub

Private Sub lvwInbox_DrawColumnHeader(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawListViewColumnHeaderEventArgs) Handles lvwInbox.DrawColumnHeader
Dim lgb As New LinearGradientBrush(Me.ClientRectangle, Color.FromArgb(70, 117, 197), _
Color.FromArgb(18, 65, 146), _
LinearGradientMode.Vertical)

Dim txt As New SolidBrush(Color.FromArgb(225, 231, 243))
Dim FontSize As Single = 8.25
Dim DisplayFont As New Font("Microsoft Sans Serif", FontSize, FontStyle.Bold)

With e.Graphics
.FillRectangle(lgb, e.Bounds)
.DrawRectangle(Pens.White, e.Bounds)

.DrawString("Date", DisplayFont, txt, 34, 4)
.DrawString("Time", DisplayFont, txt, 94, 4)
.DrawString("From", DisplayFont, txt, 154, 4)
.DrawString("Subject", DisplayFont, txt, 304, 4)
End With
End Sub
End Class