Francesco Geri

Il blog di Francesco Geri
posts - 65, comments - 60, trackbacks - 49

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
Che libro leggo in questo periodo?*

Sabato - Ian McEwan
* L'immagine è presa da IBS (http://www.ibs.it), spero non me ne vogliano...

Archives

Post Categories

Altre

Blogs

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=""/>