Click here to Skip to main content
15,896,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCLISTBOX Owner Drawn ListBox , DrawText does not return correct height. Pin
Killer319-Feb-07 3:35
Killer319-Feb-07 3:35 
Questionfile input program Pin
klutez12319-Feb-07 3:19
klutez12319-Feb-07 3:19 
AnswerRe: file input program Pin
David Crow19-Feb-07 3:22
David Crow19-Feb-07 3:22 
AnswerRe: file input program Pin
toxcct19-Feb-07 3:23
toxcct19-Feb-07 3:23 
GeneralRe: file input program Pin
jhwurmbach19-Feb-07 3:32
jhwurmbach19-Feb-07 3:32 
GeneralRe: file input program Pin
Sebastian Schneider19-Feb-07 3:59
Sebastian Schneider19-Feb-07 3:59 
Questiondrawing pixels in a different game Pin
Parallan19-Feb-07 2:34
Parallan19-Feb-07 2:34 
AnswerRe: drawing pixels in a different game [modified] Pin
Newbie0019-Feb-07 4:11
Newbie0019-Feb-07 4:11 
You can draw pixels on the whole area of your screen, by locking on the display context device

//this example draws sloping straight line

case WM_PAINT:<br />
            hdc=CreateDC("DISPLAY",NULL,NULL,NULL); <br />
            ///othe lines of your program<br />
            MoveToEx(hdc,15,15,NULL);<br />
            LineTo(hdc,150,150);<br />
            DeleteDC(hdc);<br />
           break;


You can draw on the window you choose with it's process PID using these functions:
long lp=0;<br />
EnumWindows((WNDENUMPROC)EnumProc,lp); //enum all windows <br />
                                       //using EnumProc function <br />
                                       //defined below as example<br />
bool __stdcall EnumProc(HWND hWnd,/*LPARAM*/long/*lp*/)<br />
{<br />
   unsigned long* pPid;   //LPDWORD<br />
   unsigned long result;      //DWORD<br />
   void *hg;                  //HGLOBAL<br />
   unsigned long id;<br />
<br />
   if(hWnd==NULL)<br />
      return false;<br />
<br />
   hg = GlobalAlloc(GMEM_SHARE,sizeof(unsigned long));<br />
   pPid = (unsigned long *)GlobalLock(hg);<br />
<br />
   result = GetWindowThreadProcessId(hWnd,pPid);<br />
<br />
   if(result){<br />
    if(*pPid==MyPID) //if enumed pPid==your concrete PID <br />
                     //defined somewhere outside <br />
     {<br />
      WindowYouWantToDrawOn=hWnd;<br />
      return false;<br />
     }<br />
   }<br />
   else{<br />
      GlobalUnlock(hg);<br />
      GlobalFree(hg);<br />
      return false;<br />
   }<br />
   GlobalUnlock(hg);<br />
   GlobalFree(hg);<br />
   return true;<br />
}<br />
//If you chose correct PID you have got your desired handle to the <br />
//window you want to draw on<br />
//next you can get the desired window's context device <br />
hdc=GetWindowDC(WindowYouWantToDrawOn);

And now you can use your new hdc to draw pixels on the concrete window but I don't know how to synchronize your drawing program with some other program's window and it's refresh method.






-- modified at 5:56 Tuesday 20th February, 2007
GeneralRe: drawing pixels in a different game Pin
Parallan19-Feb-07 4:33
Parallan19-Feb-07 4:33 
GeneralRe: drawing pixels in a different game [modified] Pin
Parallan19-Feb-07 4:52
Parallan19-Feb-07 4:52 
QuestionRe: drawing pixels in a different game Pin
Mark Salsbery19-Feb-07 8:07
Mark Salsbery19-Feb-07 8:07 
QuestionRe: drawing pixels in a different game [modified] Pin
Parallan19-Feb-07 8:25
Parallan19-Feb-07 8:25 
QuestionSystem Menu Pin
urid19-Feb-07 2:02
urid19-Feb-07 2:02 
QuestionRe: System Menu Pin
David Crow19-Feb-07 3:08
David Crow19-Feb-07 3:08 
AnswerRe: System Menu Pin
urid19-Feb-07 3:21
urid19-Feb-07 3:21 
GeneralRe: System Menu Pin
jhwurmbach19-Feb-07 3:36
jhwurmbach19-Feb-07 3:36 
GeneralRe: System Menu Pin
Hamid_RT19-Feb-07 5:00
Hamid_RT19-Feb-07 5:00 
QuestionListBox control Pin
Kiethnt19-Feb-07 0:48
Kiethnt19-Feb-07 0:48 
QuestionRe: ListBox control Pin
Nibu babu thomas19-Feb-07 0:51
Nibu babu thomas19-Feb-07 0:51 
AnswerRe: ListBox control Pin
Naveen19-Feb-07 1:14
Naveen19-Feb-07 1:14 
GeneralRe: ListBox control Pin
Kiethnt19-Feb-07 15:38
Kiethnt19-Feb-07 15:38 
GeneralRe: ListBox control Pin
Naveen19-Feb-07 16:27
Naveen19-Feb-07 16:27 
AnswerRe: ListBox control Pin
Hamid_RT19-Feb-07 5:01
Hamid_RT19-Feb-07 5:01 
QuestionListControl Pin
Kiethnt19-Feb-07 0:21
Kiethnt19-Feb-07 0:21 
AnswerRe: ListControl Pin
Hamid_RT19-Feb-07 5:01
Hamid_RT19-Feb-07 5:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.