Deklaration: Declare Function RegisterClass Lib "user32.dll" _ Alias "RegisterClassA" ( _ lpWndClass As WNDCLASS) As Long Beschreibung: Parameter:
Rückgabewert: Beispiel: Private Declare Function CreateWindowEx Lib "user32.dll" _ Alias "CreateWindowExA" ( _ ByVal dwExStyle As Long, _ ByVal lpClassName As String, _ ByVal lpWindowName As String, _ ByVal dwStyle As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal hWndParent As Long, _ ByVal hMenu As Long, _ ByVal hInstance As Long, _ lpParam As Any) As Long Private Declare Function RegisterClass Lib "user32.dll" _ Alias "RegisterClassA" ( _ lpWndClass As WNDCLASS) As Long Private Declare Function UnregisterClass Lib "user32.dll" _ Alias "UnregisterClassA" ( _ ByVal lpClassName As Any, _ ByVal hInstance As Long) As Long Private Declare Function DefWindowProc Lib "user32.dll" _ Alias "DefWindowProcA" ( _ ByVal hWnd As Long, _ ByVal Msg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long Private Declare Function ShowWindow Lib "user32" ( _ ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Type WNDCLASS style As Long lpfnWndProc As Long cbClsExtra As Long cbWndExtra As Long hInstance As Long hIcon As Long hCursor As Long hbrBackground As Long lpszMenuName As String lpszClassName As String End Type Private Const WS_EX_ACCEPTFILES = &H10 Private Const WS_EX_APPWINDOW = &H40000 Private Const WS_EX_CLIENTEDGE = &H200 Private Const WS_EX_CONTEXTHELP = &H400 Private Const WS_EX_CONTROLPARENT = &H10000 Private Const WS_EX_DLGMODALFRAME = &H1 Private Const WS_EX_LEFT = &H0 Private Const WS_EX_LEFTSCROLLBAR = &H4000 Private Const WS_EX_LTRREADING = &H0 Private Const WS_EX_MDICHILD = &H40 Private Const WS_EX_NOACTIVATE = &H8000000 Private Const WS_EX_NOPARENTNOTIFY = &H4 Private Const WS_EX_OVERLAPPEDWINDOW = &H300 Private Const WS_EX_PALETTEWINDOW = &H188 Private Const WS_EX_RIGHT = &H1000 Private Const WS_EX_RIGHTSCROLLBAR = &H0 Private Const WS_EX_RTLREADING = &H2000 Private Const WS_EX_STATICEDGE = &H20000 Private Const WS_EX_TOOLWINDOW = &H80 Private Const WS_EX_TOPMOST = &H8 Private Const WS_EX_TRANSPARENT = &H20 Private Const WS_EX_WINDOWEDGE = &H100 Private Const WS_BORDER = &H800000 Private Const WS_CAPTION = &HC00000 Private Const WS_CHILD = &H40000000 Private Const WS_CHILDWINDOW = &H40000000 Private Const WS_CLIPCHILDREN = &H2000000 Private Const WS_CLIPSIBLINGS = &H4000000 Private Const WS_DISABLED = &H8000000 Private Const WS_DLGFRAME = &H400000 Private Const WS_GROUP = &H20000 Private Const WS_HSCROLL = &H100000 Private Const WS_ICONIC = &H20000000 Private Const WS_MAXIMIZE = &H1000000 Private Const WS_MAXIMIZEBOX = &H10000 Private Const WS_MINIMIZE = &H20000000 Private Const WS_MINIMIZEBOX = &H20000 Private Const WS_OVERLAPPED = &H0 Private Const WS_OVERLAPPEDWINDOW = &HCF0000 Private Const WS_POPUP = &H80000000 Private Const WS_POPUPWINDOW = &H80880000 Private Const WS_SIZEBOX = &H40000 Private Const WS_SYSMENU = &H80000 Private Const WS_TABSTOP = &H10000 Private Const WS_THICKFRAME = &H40000 Private Const WS_TILED = &H0 Private Const WS_TILEDWINDOW = &HCF0000 Private Const WS_VISIBLE = &H10000000 Private Const WS_VSCROLL = &H200000 Private Const CS_BYTEALIGNCLIENT = &H1000 Private Const CS_BYTEALIGNWINDOW = &H2000 Private Const CS_CLASSDC = &H40 Private Const CS_DBLCLKS = &H8 Private Const CS_HREDRAW = &H2 Private Const CS_NOCLOSE = &H200 Private Const CS_OWNDC = &H20 Private Const CS_PARENTDC = &H80 Private Const CS_SAVEBITS = &H800 Private Const CS_VREDRAW = &H1 Private Const COLOR_ACTIVEBORDER = 10 Private Const COLOR_ACTIVECAPTION = 2 Private Const COLOR_APPWORKSPACE = 12 Private Const COLOR_BACKGROUND = 1 Private Const COLOR_BTNFACE = 15 Private Const COLOR_BTNHIGHLIGHT = 20 Private Const COLOR_BTNSHADOW = 16 Private Const COLOR_BTNTEXT = 18 Private Const COLOR_CAPTIONTEXT = 9 Private Const COLOR_GRAYTEXT = 17 Private Const COLOR_HIGHLIGHT = 13 Private Const COLOR_HIGHLIGHTTEXT = 14 Private Const COLOR_INACTIVEBORDER = 11 Private Const COLOR_INACTIVECAPTION = 3 Private Const COLOR_INACTIVECAPTIONTEXT = 19 Private Const COLOR_MENU = 4 Private Const COLOR_MENUTEXT = 7 Private Const COLOR_SCROLLBAR = 0 Private Const COLOR_WINDOW = 5 Private Const COLOR_WINDOWFRAME = 6 Private Const COLOR_WINDOWTEXT = 8 Private Const CW_USEDEFAULT = &H80000000 Private Const HWND_BROADCAST = &HFFFF ' Einige der Fensternachrichten Private Const WM_DESTROY = &H2 Private Const WM_MOVE = &H3 Private WindowClose As Boolean ' ------------------------------ ' Ein Fenster per Code erstellen Sub Create_HalloWelt() Dim OwnClass As WNDCLASS Dim hWnd As Long Dim RetVal As Long Dim ClassAtom As Long ' Klasse beschreiben With OwnClass .style = CS_OWNDC Or CS_HREDRAW Or CS_VREDRAW .lpfnWndProc = GetFuncAddress(AddressOf WindowProc) .hInstance = App.hInstance .lpszClassName = "MeineKlasse" .hbrBackground = COLOR_APPWORKSPACE End With ' Neue Klasse registrieren ClassAtom = RegisterClass(OwnClass) If ClassAtom = 0 Then MsgBox "Die Fensterklasse konnte nicht registriert" & _ " werden.", vbInformation, "Fehler" End End If ' Fenster erstellen Dim NormalStyles As Long Dim xPos As Long, yPos As Long NormalStyles = WS_OVERLAPPEDWINDOW Or WS_CAPTION Or _ WS_BORDER ' Position (zentriert)</font< xPos = (Screen.Width / Screen.TwipsPerPixelX - 320) / 2 yPos = (Screen.Height / Screen.TwipsPerPixelY - 200) / 2 ' Größe 320x200 hWnd = CreateWindowEx(WS_EX_APPWINDOW, "MeineKlasse", _ "Hallo Welt !!!", NormalStyles, xPos, yPos, 320&, _ 200&, 0&, 0&, App.hInstance, ByVal 0&) ' Fenster konnte nicht erstellt werden If hWnd = 0 Then MsgBox "Das Fenster konnte nicht erstellt werden.", _ vbInformation, "Fehler" Else ' Fenster anzeigen und Schleife durchlaufen, ' bis das Fenster geschlossen wird ShowWindow hWnd, 1 Do DoEvents Loop While WindowClose = False End If ' Klasse wieder deregistrieren RetVal = UnregisterClass("MeineKlasse", App.hInstance) If RetVal = 0 Then MsgBox "Fehler beim Deregistrieren der " & _ "Fensterklasse", vbCritical, "Fehler" End If End Sub ' Dient nur zum Ermitteln der Funktionsadresse von WindowProc Private Function GetFuncAddress(ByVal Address As Long) As Long GetFuncAddress = Address End Function ' Die Fensterprozedur unseres selbsterzeugten Fensters ' Hier treffen alle Ereigniss ein Public Function WindowProc(ByVal hWnd As Long, _ ByVal uMsg As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long ' Auf bestimmte Ereignisse reagieren Select Case uMsg Case WM_DESTROY ' Fenster schließen WindowClose = True Case WM_MOVE ' Fenster verschieben Debug.Print "Das Fenster wird verschoben" End Select ' Standard-Prozedur aufrufen und Ergebnis zurückgeben WindowProc = DefWindowProc(hWnd, uMsg, wParam, _ lParam) End Function Diese Seite wurde bereits 13.189 mal aufgerufen. |
vb@rchiv CD Vol.6 Geballtes Wissen aus mehr als 8 Jahren vb@rchiv! Online-Update-Funktion Entwickler-Vollversionen u.v.m. Buchempfehlung Tipp des Monats Dezemeber 2024 Roland Wutzke MultiSort im ListView-Control Dieses Beispiel zeigt, wie sich verschiedene Sortierfunktionen für ein ListView Control realisieren lassen. Neu! sevEingabe 3.0 Einfach stark! Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. |
||||||||||||
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein. |