Click here to Skip to main content
15,923,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: syntax error : 'catch' Pin
moredip23-Jul-02 8:41
moredip23-Jul-02 8:41 
GeneralRe: syntax error : 'catch' Pin
Joaquín M López Muñoz23-Jul-02 8:55
Joaquín M López Muñoz23-Jul-02 8:55 
GeneralRe: syntax error : 'catch' Pin
moredip23-Jul-02 9:24
moredip23-Jul-02 9:24 
GeneralRe: syntax error : 'catch' Pin
Joaquín M López Muñoz23-Jul-02 9:33
Joaquín M López Muñoz23-Jul-02 9:33 
GeneralRe: syntax error : 'catch' Pin
moredip23-Jul-02 9:34
moredip23-Jul-02 9:34 
GeneralGetWindowText Pin
RobJones23-Jul-02 6:41
RobJones23-Jul-02 6:41 
GeneralRe: GetWindowText Pin
Joaquín M López Muñoz23-Jul-02 7:33
Joaquín M López Muñoz23-Jul-02 7:33 
GeneralRe: GetWindowText Pin
Williams23-Jul-02 7:57
Williams23-Jul-02 7:57 
I think the better way is to use SendMessage and OnCopyData.

1. First you search your target window handle.
2. You send a WM_COPYDATA to target window.
3. Write in your target app a function to handlw WM_COPYDATA

Code:

char szWindowName[60];
// "Target App" is the target app main window caption
CString szTargetWindowName = "Target App";

int nFound;
int nLength = strlen(szTargetWindowName);

HWND hSearchHandle;

for(hSearchHandle=::GetWindow(::GetDesktopWindow(), GW_CHILD);hSearchHandle; hSearchHandle = ::GetWindow(hSearchHandle, GW_HWNDNEXT))
{
::GetWindowText(hSearchHandle, szWindowName, 58);
szWindowName[nLength] = '\0';
nFound = lstrcmpi(szWindowName, szTargetWindowName);

if(nFound == 0)
{
CWnd pCwnd;
COPYDATASTRUCT cds;
char myStr[60];

strcpy(myStr,"Lets go.");

cds.dwData = 0;
cds.lpData = myStr;
cds.cbData = sizeof(myStr);

LONG lResult;
lResult = ::SendMessage(hSearchHandle, WM_COPYDATA,(WPARAM)&pCwnd.m_hWnd, (LPARAM)(COPYDATASTRUCT*)&cds);
}
}
-----------------------------------------
Now in your target app:

BOOL CAppADlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{

MessageBox((char *)pCopyDataStruct->lpData);

return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}

Try it.

GeneralRe: GetWindowText Pin
RobJones23-Jul-02 8:06
RobJones23-Jul-02 8:06 
GeneralRe: GetWindowText Pin
Peter Occil23-Jul-02 10:07
Peter Occil23-Jul-02 10:07 
GeneralRe: GetWindowText Pin
firecow23-Jul-02 10:33
firecow23-Jul-02 10:33 
QuestionWhy "static" functions? Pin
#realJSOP23-Jul-02 6:33
professional#realJSOP23-Jul-02 6:33 
AnswerRe: Why "static" functions? Pin
Chris Losinger23-Jul-02 7:04
professionalChris Losinger23-Jul-02 7:04 
GeneralRe: Why "static" functions? Pin
#realJSOP23-Jul-02 7:35
professional#realJSOP23-Jul-02 7:35 
AnswerRe: Why "static" functions? Pin
Scott H. Settlemier23-Jul-02 7:09
Scott H. Settlemier23-Jul-02 7:09 
AnswerRe: Why "static" functions? Pin
Joaquín M López Muñoz23-Jul-02 7:26
Joaquín M López Muñoz23-Jul-02 7:26 
GeneralRe: Why "static" functions? Pin
Shog923-Jul-02 9:10
sitebuilderShog923-Jul-02 9:10 
GeneralRe: Why "static" functions? Pin
Joaquín M López Muñoz23-Jul-02 11:28
Joaquín M López Muñoz23-Jul-02 11:28 
GeneralRe: Why "static" functions? Pin
Shog923-Jul-02 11:50
sitebuilderShog923-Jul-02 11:50 
GeneralRe: Why "static" functions? Pin
Christian Graus23-Jul-02 12:26
protectorChristian Graus23-Jul-02 12:26 
GeneralRe: Why "static" functions? Pin
Joaquín M López Muñoz23-Jul-02 12:39
Joaquín M López Muñoz23-Jul-02 12:39 
GeneralRe: Why "static" functions? Pin
Christian Graus23-Jul-02 12:51
protectorChristian Graus23-Jul-02 12:51 
GeneralRe: Why "static" functions? Pin
Joaquín M López Muñoz23-Jul-02 12:57
Joaquín M López Muñoz23-Jul-02 12:57 
GeneralRe: Why "static" functions? Pin
Christian Graus23-Jul-02 13:02
protectorChristian Graus23-Jul-02 13:02 
AnswerRe: Why "static" functions? Pin
-Dy24-Jul-02 0:43
-Dy24-Jul-02 0:43 

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.