Click here to Skip to main content
15,903,856 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to Trap Close Application in a Console Application Pin
Pankaj.Jain24-Apr-07 20:40
professionalPankaj.Jain24-Apr-07 20:40 
AnswerRe: How to Trap Close Application in a Console Application Pin
Garth J Lancaster24-Apr-07 21:17
professionalGarth J Lancaster24-Apr-07 21:17 
AnswerRe: How to Trap Close Application in a Console Application Pin
Pankaj.Jain24-Apr-07 21:22
professionalPankaj.Jain24-Apr-07 21:22 
AnswerRe: access denied error Pin
Arman S.24-Apr-07 20:42
Arman S.24-Apr-07 20:42 
GeneralRe: access denied error Pin
Michael Dunn24-Apr-07 20:48
sitebuilderMichael Dunn24-Apr-07 20:48 
QuestionRunning 2 MFC apps in one Window Pin
erajsri24-Apr-07 20:13
erajsri24-Apr-07 20:13 
AnswerRe: Running 2 MFC apps in one Window Pin
Michael Dunn24-Apr-07 20:47
sitebuilderMichael Dunn24-Apr-07 20:47 
GeneralRe: Running 2 MFC apps in one Window Pin
Stephen Hewitt25-Apr-07 15:51
Stephen Hewitt25-Apr-07 15:51 
You can do it. Run the following twice. The first instance creates a main window and the second a child within the first. If you use Spy you'll see that both windows belong to different processes. OLE relies on this feature of Win32 to implement in-place editing with out-of-process servers. Some messages should not be sent across processes (such as WM_NOTIFY) so obviously the window would have to be written to take this into account. In real world applications using edit controls as I’ve done is probably not sensible if parent notification is required, but using them simplifies the example code.
===========================================

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

#include "stdafx.h"

#pragma data_seg(".shared")
HWND s_hMainWindow = NULL;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.shared,RWS")

WNDPROC g_pSuper;

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_NCDESTROY:
PostQuitMessage(0);
break;
}

return CallWindowProc(g_pSuper, hwnd, uMsg, wParam, lParam);
}

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
if (s_hMainWindow==NULL)
{
s_hMainWindow = CreateWindow(
"EDIT", "Main",
WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | ES_MULTILINE,
0, 0, 500, 500,
NULL,
NULL,
hInstance,
NULL
);
LONG res = SetWindowLong(s_hMainWindow, GWL_WNDPROC, reinterpret_cast<LONG>(&WindowProc));
g_pSuper = reinterpret_cast<WNDPROC>(res);
}
else
{
HWND hChild = CreateWindow(
"EDIT", "Child",
WS_VISIBLE | WS_CHILD | WS_BORDER | ES_MULTILINE,
100, 100, 300, 300,
s_hMainWindow,
NULL,
hInstance,
NULL
);
LONG res = SetWindowLong(hChild, GWL_WNDPROC, reinterpret_cast<LONG>(&WindowProc));
g_pSuper = reinterpret_cast<WNDPROC>(res);
}

MSG m;
while (GetMessage(&m, NULL, 0, 0))
{
TranslateMessage(&m);
DispatchMessage(&m);
}

return 0;
}

Steve
AnswerRe: Running 2 MFC apps in one Window Pin
Stephen Hewitt25-Apr-07 15:54
Stephen Hewitt25-Apr-07 15:54 
AnswerRe: Running 2 MFC apps in one Window Pin
erajsri25-Apr-07 19:14
erajsri25-Apr-07 19:14 
QuestionA Bug in Release version of VC++ Pin
jossion24-Apr-07 20:05
jossion24-Apr-07 20:05 
AnswerRe: A Bug in Release version of VC++ Pin
Cedric Moonen24-Apr-07 20:25
Cedric Moonen24-Apr-07 20:25 
GeneralRe: A Bug in Release version of VC++ Pin
jossion24-Apr-07 21:30
jossion24-Apr-07 21:30 
GeneralRe: A Bug in Release version of VC++ Pin
jhwurmbach25-Apr-07 1:54
jhwurmbach25-Apr-07 1:54 
QuestionProblem during transfer of dialog resources from one app to other app Pin
Neeraj Sinha24-Apr-07 19:07
Neeraj Sinha24-Apr-07 19:07 
AnswerRe: Problem during transfer of dialog resources from one app to other app Pin
Arman S.24-Apr-07 20:32
Arman S.24-Apr-07 20:32 
Questionhow to convert dwrod to cstring Pin
sonavi24-Apr-07 18:47
sonavi24-Apr-07 18:47 
AnswerRe: how to convert dwrod to cstring Pin
prasad_som24-Apr-07 18:55
prasad_som24-Apr-07 18:55 
AnswerRe: how to convert dwrod to cstring Pin
Arman S.24-Apr-07 20:36
Arman S.24-Apr-07 20:36 
Questionvista and MFC Pin
suraj Chhetry24-Apr-07 18:31
suraj Chhetry24-Apr-07 18:31 
AnswerRe: vista and MFC Pin
prasad_som24-Apr-07 18:48
prasad_som24-Apr-07 18:48 
GeneralRe: vista and MFC Pin
suraj Chhetry24-Apr-07 19:47
suraj Chhetry24-Apr-07 19:47 
AnswerRe: vista and MFC Pin
prasad_som24-Apr-07 21:12
prasad_som24-Apr-07 21:12 
GeneralRe: vista and MFC Pin
suraj Chhetry24-Apr-07 21:39
suraj Chhetry24-Apr-07 21:39 
AnswerRe: vista and MFC Pin
prasad_som24-Apr-07 22:23
prasad_som24-Apr-07 22:23 

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.