Click here to Skip to main content
15,921,454 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Timers Pin
Anilkumar K V3-Apr-06 20:09
Anilkumar K V3-Apr-06 20:09 
Questionread and write email in lotus notes Pin
rcao3-Apr-06 17:20
rcao3-Apr-06 17:20 
Questionusing process to look for hwnd Pin
zt97883-Apr-06 17:10
zt97883-Apr-06 17:10 
AnswerRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 17:46
Stephen Hewitt3-Apr-06 17:46 
GeneralRe: using process to look for hwnd Pin
zt97883-Apr-06 19:13
zt97883-Apr-06 19:13 
GeneralRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 19:16
Stephen Hewitt3-Apr-06 19:16 
GeneralRe: using process to look for hwnd Pin
zt97883-Apr-06 19:43
zt97883-Apr-06 19:43 
GeneralRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 19:53
Stephen Hewitt3-Apr-06 19:53 
Here's an example that uses the technique:
------------------------------------------

// Win32App.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

#include <assert.h>
#include <vector>
#include <algorithm>
#include <malloc.h>

typedef std::vector<HWND> HWNDS;

namespace
{
struct EnumInfo
{
DWORD dwProcessID;
HWNDS *pHWNDS;
};

BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
{
const EnumInfo *pInfo = reinterpret_cast<const EnumInfo *>(lParam);

DWORD dwProcessID;
GetWindowThreadProcessId(hWnd, &dwProcessID);
if ( dwProcessID == pInfo->dwProcessID )
{
pInfo->pHWNDS->push_back(hWnd);
}

return TRUE;
}
}

BOOL GetProcessTopLevelWindows( DWORD dwProcessId, HWNDS *pOut )
{
assert(pOut);
EnumInfo ei = {dwProcessId, pOut};
return EnumWindows(&EnumWindowsProc, reinterpret_cast<LPARAM>(&ei));
}

struct ShowWindowTitle
{
bool operator()(HWND hWnd) const
{
int Len = GetWindowTextLength(hWnd);
if ( Len>0 )
{
char *pText = reinterpret_cast<char*>(_alloca(Len+1));
GetWindowText(hWnd, pText, Len+1);
MessageBox(NULL, pText, "Window title", MB_OK);
return true;
}

return false;
}
};

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWNDS wins;
if ( GetProcessTopLevelWindows(2216, &wins) ) // PID HARDCODED!
{
std::for_each(wins.begin(), wins.end(), ShowWindowTitle());
}

return 0;
}


Steve
Questioncode like this. Pin
sting_lee3-Apr-06 16:27
sting_lee3-Apr-06 16:27 
AnswerRe: code like this. Pin
Rick York3-Apr-06 17:44
mveRick York3-Apr-06 17:44 
GeneralRe: code like this. Pin
toxcct3-Apr-06 21:56
toxcct3-Apr-06 21:56 
QuestionHelp me,I happen to a error about the compliler in VC6.0 Pin
onlysaint3-Apr-06 16:24
onlysaint3-Apr-06 16:24 
AnswerRe: Help me,I happen to a error about the compliler in VC6.0 Pin
includeh103-Apr-06 20:48
includeh103-Apr-06 20:48 
QuestionHow to touch member variable from a exported dll class Pin
sting_lee3-Apr-06 16:23
sting_lee3-Apr-06 16:23 
QuestionDSOFramer in MFC Dialog Pin
Jenleonard3-Apr-06 14:13
Jenleonard3-Apr-06 14:13 
Question2D array help Pin
juztten3-Apr-06 14:07
juztten3-Apr-06 14:07 
AnswerRe: 2D array help Pin
Saurabh.Garg3-Apr-06 15:26
Saurabh.Garg3-Apr-06 15:26 
AnswerRe: 2D array help Pin
juztten3-Apr-06 16:25
juztten3-Apr-06 16:25 
Questionhelppp Pin
slurpyz3-Apr-06 13:06
slurpyz3-Apr-06 13:06 
AnswerRe: helppp Pin
Ryan Binns3-Apr-06 18:35
Ryan Binns3-Apr-06 18:35 
GeneralRe: helppp Pin
toxcct3-Apr-06 22:00
toxcct3-Apr-06 22:00 
GeneralRe: helppp Pin
Rudolf Jan4-Apr-06 0:35
Rudolf Jan4-Apr-06 0:35 
QuestionCList question concerning arrays Pin
brdavid3-Apr-06 12:48
brdavid3-Apr-06 12:48 
AnswerRe: CList question concerning arrays Pin
Iain Clarke, Warrior Programmer3-Apr-06 13:32
Iain Clarke, Warrior Programmer3-Apr-06 13:32 
GeneralRe: CList question concerning arrays Pin
brdavid3-Apr-06 14:21
brdavid3-Apr-06 14:21 

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.