Francesco Geri

Il blog di Francesco Geri
posts - 68, comments - 60, trackbacks - 60

My Links

News



Anch'io metto nel mio blog cose che scrivo così, tanto per fare, tanto per condividere miei appunti, senza prendermi la briga di garantirne l'infallibilità, né l'assoluta correttezza, senza pretese e con grande umilté.

Quanti mi hanno visto dal 25/10/2007:
...dettagli

Quanta gente che c'è in questo blog!!

site statistics

Archives

Post Categories

Altre

Blogs

venerdì 12 dicembre 2008

UpdatePanel e focus delle Textbox

Inserendo una Textbox in un UpdatePanel (AJAX) può succedere (o succede sempre?) che la textbox perda il focus, o non lo possa prendere affatto.

Un modo per ovviare alla cosa è di registrare uno script che imposti il focus con un piccolo ritardo rispetto alla load:

   1: Dim script As String = "setTimeout(""$('" & MyTextBox.ClientID & "').focus(); "", 100);"
   2: ScriptManager.RegisterStartupScript(updSearch, GetType(String), "set_focus_script", script, True)

posted @ venerdì 12 dicembre 2008 15.30 | Feedback (0) | Filed Under [ ASP.NET 2.0 Tips .Net AJAX ]

giovedì 4 dicembre 2008

Eseguire lo Shrink del database di contenuto di WSS

Come fare ad eseguire lo shrink del database di contenuto di WSS, quando WSS utilizza l'istanza di Sql Server propria (quella che crea il setup di WSS)?

Il problema è che da SQL Server Management Studio non ci si può connettere all'istanza di SQL Server de iWSS (almeno questo mi risulta).

Allora si può ricorrere alla linea di comando.

  • Aprire il prompt dei comandi
  • Posizionarsi sulla cartella (SQL Server 2008):

    <drive>:\Program Files\Microsoft SQL Server\90\Tools\Binn
  • eseguire il comando:

    sqlcmd -S MY_SERVER\MICROSOFT##SSEE -q "dbcc shrinkdatabase(MY_WSS_CONTENT_DB)"

 

Dove:

MY_SERVER\MICROSOFT##SSEE è l'istanza di SQL Server

MY_WSS_CONTENT_DB è il database di WSS

 

Naturalmente ringrazio il collega Osvaldo che mi ha supportato nel determinare il comando sql da eseguire!

posted @ giovedì 4 dicembre 2008 4.50 | Feedback (0) | Filed Under [ MOSS07 SQL Server ]

Come verificare se un punto è visibile nello schermo

Il post mostra un semplice tip per vedere se un punto è visibile nello schermo (anche in presenza di più schermi).

La grafica dell'esempio è "mozzafiato":

image

 

Il codice è invece il seguente:

   1: Public Class Form1
   2:  
   3:     Private Sub Button1_Click(ByVal sender As System.Object, _
   4:                 ByVal e As System.EventArgs) Handles Button1.Click
   5:         Me.TxtEsito.Text = "..."
   6:         Dim p As Point
   7:         Try
   8:             Me.Cursor = Cursors.WaitCursor
   9:             Threading.Thread.Sleep(120)
  10:             p = New Point(Me.TxtX.Text, Me.TxtY.Text)
  11:             Dim s As Screen = Screen.FromPoint(p)
  12:             If s Is Nothing Then
  13:                 Me.TxtEsito.Text = "non nello schermo"
  14:             Else
  15:                 Me.TxtEsito.Text = "Schermo '" & s.DeviceName & "'"
  16:                 ' Verifica se il punto è contenuto
  17:                 If s.WorkingArea.Contains(p) Then
  18:                     Me.TxtEsito.Text &= ": il punto è contenuto!"
  19:                 Else
  20:                     Me.TxtEsito.Text &= ": il punto NON è contenuto!"
  21:                 End If
  22:             End If
  23:         Catch ex As Exception
  24:             Me.TxtEsito.Text = ex.Message
  25:         Finally
  26:             Me.Cursor = Cursors.Default
  27:         End Try
  28:     End Sub
  29:  
  30:  
  31: End Class

 

In pratica è sufficiente determinare lo schermo che "dovrebbe" mostrare il punto che ci interessa:

Dim s As Screen = Screen.FromPoint(p)

Ho scritto "dovrebbe" in quanto, se nessuno schermo contiene quel punto allora il metodo restituisce lo schermo più "vicino" al punto.

A questo punto, per essere sicuri che il punto sia contenuto nell'area visibile dello schermo, basta eseguire la seguente chiamata:

If s.WorkingArea.Contains(p) Then

posted @ giovedì 4 dicembre 2008 1.23 | Feedback (0) | Filed Under [ Tips .Net ]

venerdì 24 ottobre 2008

Mouse Wheel in un Panel con Controlli non Focusable (2)

Riprendo un mio precedente post su come ottenere lo scroll con il mouse wheel su un controllo che non possa avere il focus.

La soluzione suggerita aveva dei problemi, ed in particolare non gestiva bene il caso in cui il controllo si trovasse all'interno di una form di tipo mdichild, da cui si poteva aprire una form modale.... Ok, non vado avanti nei particolari, ma dico semplicemente che aveva dei problemi.

Per cui qui suggerisco un'altra soluzione, che mi sembra funzionare correttamente e che ho trovato googlando a partire dalla prima.

 

   1: Public Class MyForm
   2:   Inherits System.Windows.Forms.Form
   3:   Implements IClassWithLanguage, IMessageFilter
   4:  
   5:   Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
   6:     Try
   7:         If (m.Msg = &H20A) Then
   8:             ' WM_MOUSEWHEEL, find the control at screen position m.LParam
   9:             Dim pos As Point = New Point(m.LParam.ToInt32() And &HFFFF, m.LParam.ToInt32() >> 16)
  10:             Dim hWnd As IntPtr = WindowFromPoint(pos)
  11:             If (hWnd <> IntPtr.Zero AndAlso hWnd <> m.HWnd AndAlso Not Control.FromHandle(hWnd) Is Nothing) Then
  12:                 SendMessage(hWnd, m.Msg, m.WParam, m.LParam)
  13:                 Return True
  14:             End If
  15:         End If
  16:         Return False
  17:     Catch ex As Exception
  18:         ' Trascura l'eccezione
  19:     End Try
  20:   End Function
  21:  
  22:   ' P/Invoke declarations
  23:   <DllImport("user32.dll")> _
  24:   Private Shared Function WindowFromPoint(ByVal pt As Point) As Int32
  25:   End Function
  26:   <DllImport("User32.dll")> _
  27:   Private Shared Function SendMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Int32
  28:   End Function

posted @ venerdì 24 ottobre 2008 2.57 | Feedback (0) | Filed Under [ VS2005 .Net ]

domenica 19 ottobre 2008

Personalizzare il template dei commenti in Visual Studio (per VB.NET)

Come tutti sanno in Visual Studio 2005 si può creare la documentazione automatica del proprio codice semplicemente scrivendo i commenti con il triplice apice (''').

Di default, se si scrivono i tre apici davanti ad un metodo o a quello che volete, automaticamente Visual Studio completa con qualcosa del tipo:

   1: ''' <summary>
   2: ''' 
   3: ''' </summary>
   4: ''' <remarks></remarks>

Io non faccio molto uso di del tag remarks, per cui mi da un po' noia il fatto che ci sia.

Beh, ovviamente, si può personalizzare il template dei commenti e decidere, ad esempio, di non autogenerae il tag remarks o qualunque altra cosa.

Per otterene la personalizzazione bisogna individuare la cartella \Documents and Settings\<user-name>\Application Data\Microsoft\VisualStudio\8.0 (o l'analoga in Vista \Users\<user-name>\AppData\Roaming\Microsoft\VisualStudio\8.0), creare un file di nome VBXMLDoc.xml con il template che desiderate.

Quello di default, che quindi ciascuno può modificare a piacere, è il seguente:

 

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <XMLDocCommentSchema>
   3:  
   4:     <CodeElement type="Module">
   5:         <Template>
   6:             <summary/>
   7:             <remarks/>
   8:         </Template>
   9:         <CompletionList>
  10:             <include file="" path=""/>
  11:             <permission cref=""/>
  12:             <remarks/>
  13:             <summary/>
  14:         </CompletionList>
  15:     </CodeElement>
  16:    
  17:     <CodeElement type="Class">
  18:         <Template>
  19:             <summary/>
  20:             <remarks/>
  21:         </Template>
  22:         <CompletionList>
  23:             <include file="" path=""/>
  24:             <permission cref=""/>
  25:             <remarks/>
  26:             <summary/>
  27:         </CompletionList>
  28:     </CodeElement>
  29:  
  30:     <CodeElement type="Structure">
  31:         <Template>
  32:             <summary/>
  33:             <remarks/>
  34:         </Template>
  35:         <CompletionList>
  36:             <include file="" path=""/>
  37:             <permission cref=""/>
  38:             <remarks/>
  39:             <summary/>
  40:         </CompletionList>
  41:     </CodeElement>
  42:    
  43:     <CodeElement type="Interface">
  44:         <Template>
  45:             <summary/>
  46:             <remarks/>
  47:         </Template>
  48:         <CompletionList>
  49:             <include file="" path=""/>
  50:             <permission cref=""/>
  51:             <remarks/>
  52:             <summary/>
  53:         </CompletionList>
  54:     </CodeElement>
  55:    
  56:     <CodeElement type="Enum">
  57:         <Template>
  58:             <summary/>
  59:             <remarks/>
  60:         </Template>
  61:         <CompletionList>
  62:             <include file="" path=""/>
  63:             <permission cref=""/>
  64:             <remarks/>
  65:             <summary/>
  66:         </CompletionList>
  67:     </CodeElement>
  68:    
  69:     <CodeElement type="Property">
  70:         <Template>
  71:             <summary/>
  72:             <param/>
  73:             <value/>
  74:             <remarks/>
  75:         </Template>
  76:         <CompletionList>
  77:             <exception cref=""/>
  78:             <include file="" path=""/>
  79:             <param name=""/>
  80:             <permission cref=""/>
  81:             <remarks/>
  82:             <summary/>
  83:             <value/>
  84:          </CompletionList>
  85:     </CodeElement>
  86:    
  87:     <CodeElement type="Sub">
  88:         <Template>
  89:             <summary/>
  90:             <param/>
  91:             <remarks/>
  92:         </Template>
  93:         <CompletionList>
  94:             <exception cref=""/>
  95:             <include file="" path=""/>
  96:             <param name=""/>
  97:             <permission cref=""/>
  98:             <remarks/>
  99:             <summary/>
 100:         </CompletionList>
 101:     </CodeElement>
 102:    
 103:     <CodeElement type="Function">
 104:         <Template>
 105:             <summary/>
 106:             <param/>
 107:             <returns/>
 108:         </Template>
 109:         <CompletionList>
 110:             <exception cref=""/>
 111:             <include file="" path=""/>
 112:             <param name=""/>
 113:             <permission cref=""/>
 114:             <remarks/>
 115:             <returns/>
 116:             <summary/>
 117:         </CompletionList>
 118:     </CodeElement>
 119:    
 120:     <CodeElement type="Operator">
 121:         <Template>
 122:             <summary/>
 123:             <param/>
 124:             <returns/>
 125:             <remarks/>
 126:         </Template>
 127:         <CompletionList>
 128:             <exception cref=""/>
 129:             <include file="" path=""/>
 130:             <param name=""/>
 131:             <permission cref=""/>
 132:             <remarks/>
 133:             <returns/>
 134:             <summary/>
 135:         </CompletionList>
 136:     </CodeElement>
 137:    
 138:     <CodeElement type="Declare">
 139:         <Template>
 140:             <summary/>
 141:             <param/>
 142:             <returns/>
 143:             <remarks/>
 144:         </Template>
 145:         <CompletionList>
 146:             <exception cref=""/>
 147:             <include file="" path=""/>
 148:             <param name=""/>
 149:             <permission cref=""/>
 150:             <remarks/>
 151:             <returns/>
 152:             <summary/>
 153:         </CompletionList>
 154:     </CodeElement>
 155:    
 156:     <CodeElement type="Field">
 157:         <Template>
 158:             <summary/>
 159:             <remarks/>
 160:         </Template>
 161:         <CompletionList>
 162:             <include file="" path=""/>
 163:             <permission cref=""/>
 164:             <remarks/>
 165:             <summary/>
 166:         </CompletionList>
 167:     </CodeElement>
 168:    
 169:     <CodeElement type="Delegate">
 170:         <Template>
 171:             <summary/>
 172:             <param/>
 173:             <returns/>
 174:             <remarks/>
 175:         </Template>
 176:         <CompletionList>
 177:             <include file="" path=""/>
 178:             <param name=""/>
 179:             <permission cref=""/>
 180:             <remarks/>
 181:             <returns/>
 182:             <summary/>
 183:         </CompletionList>
 184:     </CodeElement>
 185:    
 186:     <CodeElement type="Event">
 187:         <Template>
 188:             <summary/>
 189:             <param/>
 190:             <remarks/>
 191:         </Template>
 192:         <CompletionList>
 193:             <include file="" path=""/>
 194:             <param name=""/>
 195:             <permission cref=""/>
 196:             <remarks/>
 197:             <summary/>
 198:         </CompletionList>
 199:     </CodeElement>
 200:    
 201:     <ChildCompletionList>
 202:         <c/>
 203:         <code/>
 204:         <example/>
 205:         <list type="">
 206:             <listheader>
 207:                 <term/>
 208:                 <description/>
 209:             </listheader>
 210:         </list>
 211:         <para/>
 212:         <paramref name=""/>
 213:         <see cref=""/>
 214:         <seealso cref=""/>
 215:     </ChildCompletionList>
 216:    
 217: </XMLDocCommentSchema>

 

[Vedi fonte]

posted @ domenica 19 ottobre 2008 19.04 | Feedback (0) | Filed Under [ VS2005 .Net ]

giovedì 25 settembre 2008

Problemi con DropDownList e XMLDataSource creati dinamicamente

Oggi ho avuto dei problemi a collegare due dropdownlist a fonti dati basate su XML. Andiamo per ordine. Ho creato un'applicazione con 2 DropDownList, ciascuna collegata ad un XmlDataSource che si legge un suo file XML: ...

posted @ giovedì 25 settembre 2008 3.51 | Feedback (2) | Filed Under [ ASP.NET 2.0 Tips ]

mercoledì 24 settembre 2008

Errore LoaderLock was detected in Visual Studio 2005

Ho un progetto in Visual Studio 2005 che fa uso di una DLL esterna che, in DEBUG, mi genera il seguente errore:

 

LoaderLock was detected
Message: DLL 'C:\Windows\assembly\GAC\dllEsterna\4.0.22.1__80d669b8b606a2da\dllEsterna.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

 

L'errore interrompe il debug e mi costringe a fare un po' di click di "OK" o "Continua" prima di poter andare avanti.

La cosa non è piacevole e rallenta il debug.

Per evitare il problema (non risolverlo... per quello dovrei sentire il produtto della dllEsterna) si può fare come segue:

 

  1. Da Visual Studio andare sul menu "Debug", poi "Exceptions" per aprire la finestra seguente:

    image

  2. Espandere "Managed Debugging Assistants"
  3. Individuare la voce (checkbox) "LoaderLock" che sarà spuntato e togliere la spunta!

posted @ mercoledì 24 settembre 2008 22.40 | Feedback (0) | Filed Under [ Tips VS2005 .Net ]

martedì 23 settembre 2008

Rendere gli URL "clickabili" in Microsoft Office Communicator 2005 (e 2007)

Se usate Microsoft Office Communicator per la messaggistica istantanea e vi sembra scomodo il fatto che i link non siano clickabili.... ecco come risolvere il problema:

image

 

Tutto chiaro?

Riassumo:

  1. Aprire Regedit
  2. Navigare fino a:
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Communicator
  3. Creare un nuovo valore di tipo DWORD con nome EnableURL e valore 1

posted @ martedì 23 settembre 2008 2.57 | Feedback (0) | Filed Under [ Tips MS Office ]

martedì 16 settembre 2008

[OT] Chrome per Linux o Mac? CrossOver Chominium

Per chi si è già innamorato di Google Chrome e vuole provarlo anche su Linux o Mac può provare CrossOver Chrominium in attesa del Chrome ufficiale!

 

 

posted @ martedì 16 settembre 2008 20.54 | Feedback (0) |

domenica 14 settembre 2008

Mouse Wheel in un Panel con Controlli non Focusable

Se si ha un pannello con "Autoscroll=True" lo si può sfruttare per fare lo scroll con la rotella del mouse.

Tuttavia se il pannello contiene solo controlli non Focusable (...che non possono avere il Focus) allora l'autoscroll al mousewhell non funziona.

Per questo segnalo un interessante post in cui si spiega come risolvere il problema.

posted @ domenica 14 settembre 2008 22.20 | Feedback (0) | Filed Under [ .Net ]

Powered by: