Click here to Skip to main content
15,891,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Drawing on a CRichEditCtrl Pin
Hamid_RT29-Aug-06 7:37
Hamid_RT29-Aug-06 7:37 
QuestionTCP/IP question Pin
G_S28-Aug-06 5:30
G_S28-Aug-06 5:30 
AnswerRe: TCP/IP question Pin
Dave Calkins28-Aug-06 5:46
Dave Calkins28-Aug-06 5:46 
GeneralRe: TCP/IP question Pin
G_S28-Aug-06 6:22
G_S28-Aug-06 6:22 
AnswerRe: TCP/IP question Pin
Zac Howland28-Aug-06 5:50
Zac Howland28-Aug-06 5:50 
GeneralRe: TCP/IP question Pin
G_S28-Aug-06 6:21
G_S28-Aug-06 6:21 
GeneralRe: TCP/IP question Pin
Zac Howland28-Aug-06 6:39
Zac Howland28-Aug-06 6:39 
QuestionCross process subclassing by hooking Pin
AlexBecker28-Aug-06 5:23
AlexBecker28-Aug-06 5:23 
I'm writing a tiny app that subclasses a window in another process. For this I have a DLL that is injected into the other process by the means of a code>GetMessage hook. So far so good.
Since I'm not interested in the hook itself, on the DLL's DllMain->DLL_ATTACH I call LoadLibrary on the same library to increase it's ref count and then I call UnhookWindowsHookEx to release the hook. After this I subclass the window. At this point everything is fine.

The problem comes when the subclassed window is closed. At this point I want to unload the DLL from memory but I'm at this point unable to do so. The process hangs and is automatically terminated.

What I'm doing is as follows (thanks Emilio_grv!):
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  static unsigned int iRefCount = 1;

  ++iRefCount;
	
  switch (uMsg)
  {	
    case WM_NCDESTROY:
      --iRefCount;
      break;
  }

  --iRefCount;
  if (!iRefCount)
  {
    UnSubclass();
    FreeLibrary(m_hInstDLL);
  }
  return CallWindowProc(lpfnOldProc, hwnd, uMsg, wParam, lParam);
}


Any ideas? Frown | :(
Thanks !!!!!!!!
AnswerRe: Cross process subclassing by hooking Pin
JWood28-Aug-06 7:50
JWood28-Aug-06 7:50 
GeneralRe: Cross process subclassing by hooking Pin
AlexBecker28-Aug-06 16:44
AlexBecker28-Aug-06 16:44 
AnswerRe: Cross process subclassing by hooking Pin
Stephen Hewitt28-Aug-06 14:41
Stephen Hewitt28-Aug-06 14:41 
GeneralRe: Cross process subclassing by hooking Pin
AlexBecker28-Aug-06 16:43
AlexBecker28-Aug-06 16:43 
GeneralRe: Cross process subclassing by hooking Pin
Stephen Hewitt28-Aug-06 17:24
Stephen Hewitt28-Aug-06 17:24 
QuestionEnable Scrolling in MDI Pin
Nyarlatotep28-Aug-06 5:16
Nyarlatotep28-Aug-06 5:16 
QuestionPersonalized menu items question : What Setting is this ? Pin
Maximilien28-Aug-06 5:14
Maximilien28-Aug-06 5:14 
Questioncalling a function two ways Pin
Jay0328-Aug-06 5:13
Jay0328-Aug-06 5:13 
AnswerRe: calling a function two ways Pin
Maximilien28-Aug-06 5:28
Maximilien28-Aug-06 5:28 
GeneralRe: calling a function two ways Pin
Jay0328-Aug-06 5:46
Jay0328-Aug-06 5:46 
AnswerRe: calling a function two ways Pin
Zac Howland28-Aug-06 5:34
Zac Howland28-Aug-06 5:34 
GeneralRe: calling a function two ways Pin
Jay0328-Aug-06 5:43
Jay0328-Aug-06 5:43 
GeneralRe: calling a function two ways Pin
Jay0328-Aug-06 5:47
Jay0328-Aug-06 5:47 
GeneralRe: calling a function two ways Pin
Zac Howland28-Aug-06 5:53
Zac Howland28-Aug-06 5:53 
GeneralRe: calling a function two ways Pin
Jay0328-Aug-06 5:56
Jay0328-Aug-06 5:56 
GeneralRe: calling a function two ways Pin
David Crow28-Aug-06 6:08
David Crow28-Aug-06 6:08 
GeneralRe: calling a function two ways Pin
Jay0328-Aug-06 6:38
Jay0328-Aug-06 6:38 

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.