Public paste
Undefined
By: Guest | Date: Jan 10 2009 16:23 | Format: C++ | Expires: never | Size: 1.71 KB | Hits: 1402

  1. / gdi_draw.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "class.h"
  6. #include <iostream>
  7. #include <string>
  8. #include <windows.h>
  9. #include "process.h"
  10. #include <cstdlib>
  11. #include <winbase.h>
  12.  
  13. // hat ich auch schonmal versucht..
  14. void draw(){
  15.         HWND hWnd=FindWindow(NULL,"Counter-Strike");
  16.     HDC hdc=GetDC(hWnd);
  17.     RECT r;
  18.    
  19.     // Obtain the window's client rectangle
  20. GetClientRect(hWnd, &r);
  21.  
  22. // THE FIX: by setting the background mode
  23. // to transparent, the region is the text itself
  24. // SetBkMode(hdc, TRANSPARENT);
  25.  
  26. // Bracket begin a path
  27. BeginPath(hdc);
  28.  
  29. // Send some text out into the world
  30. TCHAR text[ ] = "Defenestration can be hazardous";
  31. TextOut(hdc,r.left,r.top,text, ARRAYSIZE(text));
  32.  
  33. // Bracket end a path
  34. EndPath(hdc);
  35.  
  36. // Derive a region from that path
  37. SelectClipPath(hdc, RGN_AND);
  38.  
  39. // This generates the same result as SelectClipPath()
  40. // SelectClipRgn(hdc, PathToRegion(hdc));
  41.  
  42. // Fill the region with grayness
  43.  
  44.  
  45. }
  46. using namespace std;
  47. //using namespace System::Threading;
  48.  
  49. BOOL TextOut(int x, int y,
  50.              LPCTSTR lpszString,
  51.              int nCount);
  52.  
  53.  
  54.  
  55. void runInThread();
  56. ///////////////
  57. int main(int argc, char *argv[]) {
  58. unsigned long threadId;
  59.  
  60. HWND hWnd=FindWindow(NULL,"Counter-Strike");
  61. HDC hdc=GetDC(hWnd);
  62.  
  63. cout<<"hWnd: "<<hWnd<<endl;
  64. cout<<"hcd: "<<hdc<<endl;
  65.  
  66. HANDLE hThread = CreateThread(
  67. NULL, 2000, (LPTHREAD_START_ROUTINE)runInThread,"", 0, &threadId
  68. );
  69. for(int i=0;i<30;++i) {
  70. Sleep(10);
  71. RECT r;
  72. DrawText(hdc,"text",4,&r,DT_CENTER);
  73. }
  74.  
  75. return EXIT_SUCCESS;
  76. }
  77.  
  78. ///////////////
  79. void runInThread() {
  80. for(int i=0;i<30;++i) {
  81.  
  82.  
  83. printf("runinthread");    
  84.    
  85.    
  86. }
  87. }