Window written in SDK programming

zhaozj2021-02-16  55

Option expedition

Public Declare Function CreateWindowEx Lib "user32" 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 LongPublic Declare Function LoadIcon Lib "user32" Alias ​​"LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As String) As LongPublic Declare Function LoadCursor Lib "user32" Alias ​​"LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As String) As LongPublic Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As LongPublic Declare Function RegisterClassEx Lib "user32" Alias ​​"RegisterClassExA" (pcWndClassEx As WNDCLASSEX) As IntegerPublic Declare Function ShowWindow Lib "user32" (ByVal handle_of_window As Long, ByVal nCmdShow As Long) As LongPublic Declare Function UpdateWindow Lib "user32" (ByVal handle_of_window As Long) As LongPublic Declare Function SetFocus Lib "user32" (ByVal handle_of_window As Long) As LongPublic Declare Function PostMessage Lib "user32" Alias ​​"PostMessageA" (ByVal handle_of_window As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long ) As LongPublic Declare Function DefWindowProc Lib "user32" Alias ​​"DefWindowProcA" (ByVal handle_of_window As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPublic Declare Function GetMessage Lib "user32" Alias ​​"GetMessageA"

(LpMsg As MSG, ByVal handle_of_window As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As LongPublic Declare Function TranslateMessage Lib "user32" (lpMsg As MSG) As LongPublic Declare Function DispatchMessage Lib "user32" Alias ​​"DispatchMessageA" (lpMsg As MSG) As LongPublic Declare Sub PostQuitMessage Lib "user32" (ByVal nExitCode As Long) Public Declare Function BeginPaint Lib "user32" (ByVal handle_of_window As Long, lpPaint As PAINTSTRUCT) As LongPublic Declare Function EndPaint Lib "user32" (ByVal handle_of_window As Long, lpPaint As PAINTSTRUCT) As LongPublic Declare Function GetClientRect Lib "user32" (ByVal handle_of_window As Long, lpRect As RECT) As LongPublic Declare Function DrawText Lib "user32" Alias ​​"DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, LPRECT AS RECT, BYVAL WFORMAT AS Long AS Long Type WndClassex Cbsize As LO ng 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 hIconSm As LongEnd TypeType POINTAPI x As Long y As LongEnd Type

TYPE MSG HANDLE_OF_WINDOW AS Long Messes As Long Time As Long Pt As Pointapore Teype

TYPE RECT Left As long top as long Right As Long Bottom As LONGEND TYPE

TYPE PAINTSTRUCT HDC AS Long FeRase As Long Fincupdate As Long Rgbreserved (32) AS BYTE 'THIS WAS DECLARED INCORRECTLY IN VB API Viewrend Type

Public Const WS_VISIBLE As Long = & H10000000Public Const WS_VSCROLL As Long = & H200000Public Const WS_TABSTOP As Long = & H10000Public Const WS_THICKFRAME As Long = & H40000Public Const WS_MAXIMIZE As Long = & H1000000Public Const WS_MAXIMIZEBOX As Long = & H10000Public Const WS_MINIMIZE As Long = & H20000000Public Const WS_MINIMIZEBOX As Long = & H20000Public Const WS_SYSMENU As Long = & H80000Public Const WS_BORDER As Long = & H800000Public Const WS_CAPTION As Long = & HC00000 'WS_BORDER Or WS_DLGFRAMEPublic Const WS_CHILD As Long = & H40000000Public Const WS_CHILDWINDOW As Long = (WS_CHILD) Public Const WS_CLIPCHILDREN As Long = & H2000000Public Const WS_CLIPSIBLINGS As Long = & H4000000Public Const WS_DISABLED As Long = & H8000000Public Const WS_DLGFRAME As Long = & H400000Public Const WS_EX_ACCEPTFILES As Long = & H10 & Public Const WS_EX_DLGMODALFRAME As Long = & H1 & Public Const WS_EX_NOPARENTNOTIFY As Long = & H4 & Public Const WS_EX_TOPMOST As Long = & H8 & Public Const WS_EX_TRANSPA RENT As Long = & H20 & Public Const WS_GROUP As Long = & H20000Public Const WS_HSCROLL As Long = & H100000Public Const WS_ICONIC As Long = WS_MINIMIZEPublic Const WS_OVERLAPPED As Long = & H0 & Public Const WS_OVERLAPPEDWINDOW As Long = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX) Public Const WS_POPUP As long = & h80000000public const WS_POPUPWINDOW AS long = (ws_popup or ws_border or ws_sysmenu) public const ws_sizebox as long =

WS_THICKFRAMEPublic Const WS_TILED As Long = WS_OVERLAPPEDPublic Const WS_TILEDWINDOW As Long = WS_OVERLAPPEDWINDOWPublic Const CW_USEDEFAULT As Long = & H80000000Public Const CS_HREDRAW As Long = & H2Public Const CS_VREDRAW As Long = & H1Public Const IDI_APPLICATION As Long = 32512 & Public Const IDC_ARROW As Long = 32512 & Public Const WHITE_BRUSH As Integer = 0Public Const BLACK_BRUSH As Integer = 4Public Const WM_KEYDOWN As Long = & H100Public Const WM_CLOSE As Long = & H10Public Const WM_DESTROY As Long = & H2Public Const WM_PAINT As Long = & HFPublic Const SW_SHOWNORMAL As Long = 1Public Const DT_CENTER As Long = & H1Public Const DT_SINGLELINE As Long = & H20Public Const DT_VCENTER As Long = & h4sub main ()

Call vbwinmain end Sub public function vbwinmain () AS Long

Const CLASSNAME = "hello_world_vb" Const TITLE = "hello, world!" Dim handle_of_window As Long Dim window_class As WNDCLASSEX Dim message As MSG window_class.cbSize = Len (window_class) window_class.style = CS_HREDRAW Or CS_VREDRAW window_class.lpfnWndProc = GetFuncPtr (AddressOf WindowProc ) window_class.cbClsExtra = 0 & window_class.cbWndExtra = 0 & window_class.hInstance = App.hInstance window_class.hIcon = LoadIcon (App.hInstance, IDI_APPLICATION) window_class.hCursor = LoadCursor (App.hInstance, IDC_ARROW) window_class.hbrBackground = GetStockObject (WHITE_BRUSH) window_class.lpszMenuName = 0 & window_class.lpszClassName = CLASSNAME window_class.hIconSm = LoadIcon (App.hInstance, IDI_APPLICATION) RegisterClassEx window_class handle_of_window = CreateWindowEx (0 &, CLASSNAME, TITLE, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0 &, 0 &, App. Hinstance, 0 &) ShowWindow Handle_Of_Window, SW_SHOW NORMAL UpdateWindow handle_of_window SetFocus handle_of_window Do While 0 <> GetMessage (message, 0 &, 0 &, 0 &) TranslateMessage message DispatchMessage message Loop vbWinMain = message.wParamEnd Function

转载请注明原文地址:https://www.9cbs.com/read-24793.html

New Post(0)