Advertisement
Mysoft

Untitled

Mar 1st, 2016
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "windows.bi"
  2. #include "crt.bi"
  3.  
  4. dim shared as HWND GameWindow
  5. dim shared as HINSTANCE hInstance
  6.  
  7. ' ================================= Window Events =========================
  8. function WindowProc(hwnd as HWND,uMsg as uinteger, wParam as WPARAM, lParam as LPARAM) as LRESULT
  9.  
  10.   select case uMsg 'which message was received??
  11.   case WM_DESTROY       'window was destroyed
  12.     PostQuitMessage(0)
  13.     return 0
  14.  
  15.   case WM_PAINT         'window must be painted (drawn)
  16.     dim as PAINTSTRUCT ps
  17.     dim as HDC hdc = BeginPaint(hwnd, @ps) 'start drawing
  18.     FillRect(hdc, @ps.rcPaint, cast(HBRUSH,(COLOR_WINDOW+1)))
  19.     EndPaint(hwnd, @ps)                    'drawing done
  20.     return 0
  21.    
  22.   end select
  23.  
  24.   'or do the default internal action for the unhandled message
  25.   return DefWindowProc(hwnd, uMsg, wParam, lParam)
  26. end function
  27.  
  28. ' =============================== MAIN PROGRAM ===========================
  29.  
  30. hInstance = GetModuleHandle( null ) '// use this executable as "instance"
  31. GameWindow = FindWindow( "R6Game" , "Rainbow Six" )
  32. if GameWindow = NULL then
  33.   puts("Failed to locate Rainbow Six window")
  34.   sleep: end 1 'wait for key and finish program
  35. end if
  36.  
  37. ''' Register the window class. '''
  38. const CLASS_NAME  = "Sample Window Class"
  39.  
  40. dim as WNDCLASS wc
  41. wc.lpfnWndProc   = @WindowProc      '// function that will receive window events
  42. wc.hInstance     = hInstance        '// instance that will be assigned to the class
  43. wc.lpszClassName = @CLASS_NAME      '// pointer to class name
  44.  
  45. RegisterClass(@wc)                  '// register our window class
  46.  
  47. dim as HWND hwnd = CreateWindowEx( _
  48. 0, _                            '// Optional window styles.
  49. CLASS_NAME, _                   '// Window class
  50. "Learn to Program Windows", _   '// Window text
  51. WS_OVERLAPPEDWINDOW, _          '// Window style
  52. 0,0,320,240, _  '// Size and position
  53. NULL, _         '// Parent window    
  54. NULL, _         '// Menu
  55. hInstance,  _   '// Instance handle
  56. NULL )          '// Additional application data
  57.  
  58. if hwnd = NULL then
  59.   puts("Failed to create our window")
  60.   sleep: end 1 'wait for key and finish program
  61. end if
  62.  
  63. ShowWindow(hwnd, SW_SHOW) 'show the window we created
  64.  
  65. '// Run the message loop. (process window events)
  66. dim as MSG msg
  67. while (GetMessage(@msg, NULL, 0, 0)) 'will finish this loop when quit
  68.   TranslateMessage(@msg)
  69.   DispatchMessage(@msg)
  70. wend
  71.  
  72. puts("Finished sucessfully.")
  73. sleep: end 0 'wait for key and finish program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement