Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application Icon 1

Status
Not open for further replies.

mbaddar

Programmer
May 10, 2001
120
US
Hi,

I'm trying to put in a custom application icon for my access project. I'm afraid I won't be able to set the path under the Tools/Startup/Application icon settings because I don't know what the path of the icon will be when this is distributed on a client's machine. I tried to put in a UNC Path (like app.path) but it doesn't seem you can do that here.

Right now, I'm trying to set the application icon programmatically. The problem with this is that for a split second when my project loads you can see an Access icon before my icon appears.

Any suggestion?

Thanks,
MBaddar
 
Hi!

There are codes for StartUp setting. You can call function on start of application for StartUp setting. Also this function set &quot;By pass key&quot; (allow or not to open application with <Shift> key ie. suspend StartUp), &quot;Special keys> False or True etc. It's important for users work. I made special form for calling this function and setting StartUp: form open is allowed only to Admins group users.

Private Sub On_Open()
If CurrentDb.Properties(&quot;AllowBypassKey&quot;)=True Then
'Here I check for permission of CurrentUser and
'If CurrentUser have not Admins group then I set

NewAllowBypassKey = False
Call SetStartupProperties
'All settings will be in work after restarting app.
msgbox &quot;Please restart application!&quot;
docmd.quit
end if
end sub

Public NewAllowBypassKey As Variant

Function SetStartupProperties()

'Set icon what location is same DB location's
ChangeProperty &quot;AppIcon&quot;, dbText, DirOfFile & &quot;Cat.ico&quot;
ChangeProperty &quot;AppTitle&quot;, dbText, &quot;Sample Database Special For Tek-Tips forums&quot;
ChangeProperty &quot;StartupForm&quot;, dbText, &quot;frmSample&quot;
ChangeProperty &quot;StartupShowDBWindow&quot;, dbBoolean, False
ChangeProperty &quot;StartupShowStatusBar&quot;, dbBoolean, True
'or NewAllowBypassKey
ChangeProperty &quot;AllowBuiltinToolbars&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;AllowFullMenus&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;AllowBreakIntoCode&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;AllowSpecialKeys&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;AllowBypassKey&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;StartUpMenuBar&quot;, dbText, &quot;MyUserMenu&quot;
ChangeProperty &quot;AllowToolbarChanges&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;AllowShortcutMenus&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;StartupShortcutMenuBar&quot;, dbBoolean, NewAllowBypassKey
End Function

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else

' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function

Function DirOfFile(Optional strPath As String = &quot;&quot;, Optional blnMasterDir As Boolean = False) As String
'Directory of file
DirOfFile = strPath
Dim i As Byte

If strPath = &quot;&quot; Then strPath = CurrentDb.Name

For i = 1 To Len(strPath)
If Mid(strPath, i, 1) = &quot;\&quot; Then
DirOfFile = Left(strPath, i)
If blnMasterDir = True Then
If i > 1 Then
If Mid(strPath, i - 1, 1) <> &quot;:&quot; Then
Exit For
End If
End If
End If
End If
Next i
End Function


Aivars

P.S. I can send sample DB what include several solution of users aministration, print setup, command buttons enabled/disabled and some other. I must only know what Access version do you use (2000 or 97)

alaganovskis@hotmail.com
 
Hi,

Thanks for the informative answer. Will this approach solve that issue I mentioned (of getting rid of that Access icon that appears for a few seconds before the icon changes to the one whose path I'm setting in the startup properties)? Because I'm having this problem now.

I'd be happy to look at the database (if you can send it to this email, mbaddar@yahoo.com). I use Access 2000.

Thanks again,
mbaddar
 
Hi!

You can use function for file search.

dim strMyFileLocation as string
strMyFileLocation = SearchForFileLocation(&quot;IcoName.ico&quot;)
ChangeProperty &quot;AppIcon&quot;, dbText, strMyFileLocation

Function SearchForFileLocation(strFileName As String, Optional strFolder As String = &quot;C&quot;) As String
With Application.FileSearch
.LookIn = strFolder & &quot;:\&quot;
.SearchSubFolders = True
.FileName = strFileName
If .Execute > 0 Then
SearchForFileLocation = .FoundFiles(1)
Else
MsgBox &quot;File ''&quot; & strFileName & &quot;'' not found&quot;
End If
End With
End Function

Aivars

P.S. Message with ZIP attachment is going to you.
 
Hi Aivars,

Thanks, I'll post my success or failure.

Mbaddar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top