Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "windows.bi"
- #include "crt.bi"
- dim shared as HWND GameWindow
- dim shared as HINSTANCE hInstance
- ' ================================= Window Events =========================
- function WindowProc(hwnd as HWND,uMsg as uinteger, wParam as WPARAM, lParam as LPARAM) as LRESULT
- select case uMsg 'which message was received??
- case WM_DESTROY 'window was destroyed
- PostQuitMessage(0)
- return 0
- case WM_PAINT 'window must be painted (drawn)
- dim as PAINTSTRUCT ps
- dim as HDC hdc = BeginPaint(hwnd, @ps) 'start drawing
- FillRect(hdc, @ps.rcPaint, cast(HBRUSH,(COLOR_WINDOW+1)))
- EndPaint(hwnd, @ps) 'drawing done
- return 0
- end select
- 'or do the default internal action for the unhandled message
- return DefWindowProc(hwnd, uMsg, wParam, lParam)
- end function
- ' =============================== MAIN PROGRAM ===========================
- hInstance = GetModuleHandle( null ) '// use this executable as "instance"
- GameWindow = FindWindow( "R6Game" , "Rainbow Six" )
- if GameWindow = NULL then
- puts("Failed to locate Rainbow Six window")
- sleep: end 1 'wait for key and finish program
- end if
- ''' Register the window class. '''
- const CLASS_NAME = "Sample Window Class"
- dim as WNDCLASS wc
- wc.lpfnWndProc = @WindowProc '// function that will receive window events
- wc.hInstance = hInstance '// instance that will be assigned to the class
- wc.lpszClassName = @CLASS_NAME '// pointer to class name
- RegisterClass(@wc) '// register our window class
- dim as HWND hwnd = CreateWindowEx( _
- 0, _ '// Optional window styles.
- CLASS_NAME, _ '// Window class
- "Learn to Program Windows", _ '// Window text
- WS_OVERLAPPEDWINDOW, _ '// Window style
- 0,0,320,240, _ '// Size and position
- NULL, _ '// Parent window
- NULL, _ '// Menu
- hInstance, _ '// Instance handle
- NULL ) '// Additional application data
- if hwnd = NULL then
- puts("Failed to create our window")
- sleep: end 1 'wait for key and finish program
- end if
- ShowWindow(hwnd, SW_SHOW) 'show the window we created
- '// Run the message loop. (process window events)
- dim as MSG msg
- while (GetMessage(@msg, NULL, 0, 0)) 'will finish this loop when quit
- TranslateMessage(@msg)
- DispatchMessage(@msg)
- wend
- puts("Finished sucessfully.")
- sleep: end 0 'wait for key and finish program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement