Latest OxygenBasic.zip at GitHub (Click on the Wizard)
0 Members and 4 Guests are viewing this topic.
Can you tell me what it is supposed to do
'This project needs one form' Also set StartupObject to 'Sub Main'' original from VB6Type WNDCLASSstyle As Longlpfnwndproc As LongcbClsextra As LongcbWndExtra2 As LonghInstance As LonghIcon As LonghCursor As LonghbrBackground As LonglpszMenuName As StringlpszClassName As StringEnd TypeType POINTAPIx As Longy As LongEnd TypeType MsghWnd As Longmessage As LongwParam As LonglParam As Longtime As Longpt As POINTAPIEnd Type' Class stylesPublic Const CS_VREDRAW = &H1Public Const CS_HREDRAW = &H2Public Const CS_KEYCVTWINDOW = &H4Public Const CS_DBLCLKS = &H8Public Const CS_OWNDC = &H20Public Const CS_CLASSDC = &H40Public Const CS_PARENTDC = &H80Public Const CS_NOKEYCVT = &H100Public Const CS_NOCLOSE = &H200Public Const CS_SAVEBITS = &H800Public Const CS_BYTEALIGNCLIENT = &H1000Public Const CS_BYTEALIGNWINDOW = &H2000Public Const CS_PUBLICCLASS = &H4000' Window stylesPublic Const WS_OVERLAPPED = &H0&Public Const WS_POPUP = &H80000000Public Const WS_CHILD = &H40000000Public Const WS_MINIMIZE = &H20000000Public Const WS_VISIBLE = &H10000000Public Const WS_DISABLED = &H8000000Public Const WS_CLIPSIBLINGS = &H4000000Public Const WS_CLIPCHILDREN = &H2000000Public Const WS_MAXIMIZE = &H1000000Public Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAMEPublic Const WS_BORDER = &H800000Public Const WS_DLGFRAME = &H400000Public Const WS_VSCROLL = &H200000Public Const WS_HSCROLL = &H100000Public Const WS_SYSMENU = &H80000Public Const WS_THICKFRAME = &H40000Public Const WS_GROUP = &H20000Public Const WS_TABSTOP = &H10000Public Const WS_MINIMIZEBOX = &H20000Public Const WS_MAXIMIZEBOX = &H10000Public Const WS_TILED = WS_OVERLAPPEDPublic Const WS_ICONIC = WS_MINIMIZEPublic Const WS_SIZEBOX = WS_THICKFRAMEPublic Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)Public Const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOWPublic Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)Public Const WS_CHILDWINDOW = (WS_CHILD)' ExWindowStylesPublic Const WS_EX_DLGMODALFRAME = &H1&Public Const WS_EX_NOPARENTNOTIFY = &H4&Public Const WS_EX_TOPMOST = &H8&Public Const WS_EX_ACCEPTFILES = &H10&Public Const WS_EX_TRANSPARENT = &H20&' Color constantsPublic Const COLOR_SCROLLBAR = 0Public Const COLOR_BACKGROUND = 1Public Const COLOR_ACTIVECAPTION = 2Public Const COLOR_INACTIVECAPTION = 3Public Const COLOR_MENU = 4Public Const COLOR_WINDOW = 5Public Const COLOR_WINDOWFRAME = 6Public Const COLOR_MENUTEXT = 7Public Const COLOR_WINDOWTEXT = 8Public Const COLOR_CAPTIONTEXT = 9Public Const COLOR_ACTIVEBORDER = 10Public Const COLOR_INACTIVEBORDER = 11Public Const COLOR_APPWORKSPACE = 12Public Const COLOR_HIGHLIGHT = 13Public Const COLOR_HIGHLIGHTTEXT = 14Public Const COLOR_BTNFACE = 15Public Const COLOR_BTNSHADOW = 16Public Const COLOR_GRAYTEXT = 17Public Const COLOR_BTNTEXT = 18Public Const COLOR_INACTIVECAPTIONTEXT = 19Public Const COLOR_BTNHIGHLIGHT = 20' Window messagesPublic Const WM_NULL = &H0Public Const WM_CREATE = &H1Public Const WM_DESTROY = &H2Public Const WM_MOVE = &H3Public Const WM_SIZE = &H5' ShowWindow commandsPublic Const SW_HIDE = 0Public Const SW_SHOWNORMAL = 1Public Const SW_NORMAL = 1Public Const SW_SHOWMINIMIZED = 2Public Const SW_SHOWMAXIMIZED = 3Public Const SW_MAXIMIZE = 3Public Const SW_SHOWNOACTIVATE = 4Public Const SW_SHOW = 5Public Const SW_MINIMIZE = 6Public Const SW_SHOWMINNOACTIVE = 7Public Const SW_SHOWNA = 8Public Const SW_RESTORE = 9Public Const SW_SHOWDEFAULT = 10Public Const SW_MAX = 10' Standard ID's of cursorsPublic Const IDC_ARROW = 32512&Public Const IDC_IBEAM = 32513&Public Const IDC_WAIT = 32514&Public Const IDC_CROSS = 32515&Public Const IDC_UPARROW = 32516&Public Const IDC_SIZE = 32640&Public Const IDC_ICON = 32641&Public Const IDC_SIZENWSE = 32642&Public Const IDC_SIZENESW = 32643&Public Const IDC_SIZEWE = 32644&Public Const IDC_SIZENS = 32645&Public Const IDC_SIZEALL = 32646&Public Const IDC_NO = 32648&Public Const IDC_APPSTARTING = 32650&Public Const GWL_WNDPROC = -4'---- DeclarationsDeclare Function RegisterClass Lib "user32" Alias "RegisterClassA" (wc As WNDCLASS) As LongDeclare Function UnregisterClass Lib "user32" Alias "UnregisterClassA" (ByVal lpClassName As String, ByVal hInstance As Long) As LongDeclare 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 LongDeclare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongDeclare Sub PostQuitMessage Lib "user32" (ByVal nExitCode As Long)Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As LongDeclare Function TranslateMessage Lib "user32" (lpMsg As Msg) As LongDeclare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As Msg) As LongDeclare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As LongDeclare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As LongDeclare Function DefMDIChildProc Lib "user32" Alias "DefMDIChildProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long' Define information of the window (pointed to by hWnd)Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As LongDeclare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDeclare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongDim wndcls As WNDCLASS'look forward#lookaheadDim hwnd2 As Long, hwnd3 As Long, old_proc As Long, new_proc As LongPublic Sub Main()Dim lngTemp As Long' Register classIf MyRegisterClass Then' Window created?If MyCreateWindow Then' Change the button's procedures' Point to new addressnew_proc = GetMyWndProc(@ButtonProc)old_proc = SetWindowLong(hwnd2, GWL_WNDPROC, new_proc)' Message loopMyMessageLoopEnd If' Unregister ClassMyUnregisterClassEnd IfEnd SubFunction MyRegisterClass()as bool' WNDCLASS-structure'Dim wndcls As WNDCLASS ' original codewndcls.style = CS_HREDRAW | CS_VREDRAWwndcls.lpfnwndproc = GetMyWndProc(@MyWndProc)wndcls.cbClsextra = 0wndcls.cbWndExtra2 = 0wndcls.hInstance = App.hInstancewndcls.hIcon = 0wndcls.hCursor = LoadCursor(0, IDC_ARROW)wndcls.hbrBackground = COLOR_WINDOWwndcls.lpszMenuName = 0wndcls.lpszClassName = "myWindowClass"' Register classMyRegisterClass = RegisterClass(&wndcls)Function = MyRegisterClassEnd FunctionSub MyUnregisterClass()UnregisterClass "myWindowClass", App.hInstanceEnd SubFunction MyCreateWindow() As BoolDim hWnd As Long' Create the windowhWnd = CreateWindowEx(0, "myWindowClass", "My Window", WS_OVERLAPPEDWINDOW, 0, 0, 400, 300, 0, 0, App.hInstance, ByVal 0&)' The Button and Textbox are child windowshwnd2 = CreateWindowEx(0, "Button", "My button", WS_CHILD, 50, 55, 100, 25, hWnd, 0, App.hInstance,0)hwnd3 = CreateWindowEx(0, "edit", "My textbox", WS_CHILD, 50, 25, 100, 25, hWnd, 0, App.hInstance, 0)If hWnd <> 0 Then ShowWindow hWnd, SW_SHOWNORMAL' Show themShowWindow hwnd2, SW_SHOWNORMALShowWindow hwnd3, SW_SHOWNORMAL' Go backMyCreateWindow = (hWnd <> 0)End FunctionFunction MyWndProc(ByVal hWnd As Long, ByVal message As Long, ByVal wParam As Long, ByVal lParam As Long) As LongSelect Case messageCase WM_DESTROY' Destroy windowPostQuitMessage (0)End Select' calls the default window procedureMyWndProc = DefWindowProc(hWnd, message, wParam, lParam)End FunctionFunction GetMyWndProc(ByVal lWndProc As Long) As LongGetMyWndProc = lWndProcEnd FunctionSub MyMessageLoop()Dim aMsg As MsgDo While GetMessage(aMsg, 0, 0, 0)DispatchMessage aMsgLoopEnd SubFunction ButtonProc(ByVal hWnd As Long, ByVal message As Long, ByVal wParam As Long, ByVal lParam As Long) As LongDim x As IntegerIf (message = 533) Thenx = MsgBox("You clicked on the button", vbOKOnly)End If' calls the window procedureButtonProc = CallWindowProc(old_proc, hWnd, message, wParam, lParam)End Function