| LockWindowUpdate, InvalidateRect, App.PrevInstance |
| |
| |
| Prozedur im Modul | |
| Private Declare Function LockWindowUpdate _ | Flackern bei Fensterupdate verhindern. |
| Lib "user32" (ByVal hwnd As Long) As Long | |
| |
| Private Declare Function InvalidateRect Lib "user32" _ | Zeichnet alle Fenster (d.h. den gesamten Bildschirm) neu. |
| (ByVal hwnd As Long, _ | |
| lpRect As Long, ByVal bErase As Long) As Long | |
| |
| Sub LockWindow(lnghWnd As Long) | Flackern bei Fensterupdate verhindern. |
| Call LockWindowUpdate(lnghWnd) | |
| End Sub | |
| Sub UnlockWindow() | |
| Call LockWindowUpdate(0) | |
| End Sub | |
| |
| Sub UpdateDesktop() | Zeichnet alle Fenster neu. |
| Call InvalidateRect(0&, 0&, False) | |
| End Sub | |
| |
| |
| Prozedur im Formular | Bei einigen Anwendungen ist es notwendig, beim Start |
| Private Sub Form_Load() | festzustellen, ob die Anwendung bereits in einer Instanz |
| If App.PrevInstance Then | ausgeführt wird. Dazu verwendet man folgenden Code |
| MsgBox "Application is already running." | (in Sub Form_Load oder Sub Main)... |
| Set frmMain = Nothing | Löscht das Formular aus dem Speicher (bleibt aber sichtbar). |
| Unload Me | Entlädt das aktive Formular (wird unsichtbar). |
| End If | |
| End Sub | |
| |
| Private Sub Form_Click() | Flackern bei Fensterupdate verhindern (nur wenn man |
| LockWindow (Me.hwnd) | LockWindow auskommentiert, wird Hallo ausgegeben). |
| frmMain.Print "Hallo" | |
| UnlockWindow | |
| End Sub | |
| |
| Private Sub cmdFont_Click() | Schriftart formularweit ändern. |
| On Error Resume Next | |
| Dim ctrControl As Control | |
| For Each ctrControl In frmMain.Controls | |
| ctrControl.Font.Name = "Arial" | |
| ctrControl.Font.Size = 12 | |
| ctrControl.Font.Bold = True | |
| Next ctrControl | |
| optTest.Value = False | |
| End Sub | |
| |
| Private Sub cmdTest_Click() | Ersten Buchstaben jedes Wortes in einer Zeichenfolge |
| Dim strOld As String, strNew As String | groß schreiben. |
| strOld = frmFrame.Caption | |
| strNew = StrConv(strOld, vbProperCase) | |
| frmFrame.Caption = strNew | |
| optTest.Value = False | |
| End Sub | |
| |
| Private Sub optTest_Click() | Zeichnet alle Fenster neu. |
| UpdateDesktop | |
| End Sub | |
| |