Click here to Skip to main content
16,010,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRegistry stuff Pin
Anonymous22-Jul-04 11:30
Anonymous22-Jul-04 11:30 
GeneralRe: Registry stuff Pin
Archer28222-Jul-04 13:10
Archer28222-Jul-04 13:10 
GeneralRe: Registry stuff Pin
Ravi Bhavnani22-Jul-04 15:11
professionalRavi Bhavnani22-Jul-04 15:11 
GeneralNetwork connection dialogs Pin
PJ Arends22-Jul-04 11:30
professionalPJ Arends22-Jul-04 11:30 
GeneralRe: Network connection dialogs Pin
Ryan Binns22-Jul-04 18:16
Ryan Binns22-Jul-04 18:16 
GeneralRe: Network connection dialogs - edited Pin
PJ Arends23-Jul-04 5:19
professionalPJ Arends23-Jul-04 5:19 
GeneralRe: Network connection dialogs - edited Pin
Ryan Binns25-Jul-04 15:36
Ryan Binns25-Jul-04 15:36 
GeneralRe: Network connection dialogs - edited Pin
PJ Arends25-Jul-04 16:19
professionalPJ Arends25-Jul-04 16:19 
Actually, it does seem to be workingBig Grin | :-D

MSDN[^] says "At the time of the HCBT_CREATEWND notification, the window has been created" so calling GetWindowThreadProcessId returns the correct window handle to the dialup dialog.

Thanks for the tipBig Grin | :-D


In the dll:
HINSTANCE hInst = 0;
HHOOK hook = 0;
HWND hWnd = 0;
DWORD ProcessID = 0;
 
static LRESULT CALLBACK CBTHook(int, WPARAM, LPARAM);
 
__declspec(dllexport) BOOL SetDUDWCHook(DWORD _ProcessID)
{
   if (!hook)
   {
      hook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHook, hInst, 0);
      if (hook)
      {
         ProcessID = _ProcessID;
         return TRUE;
      }
   }
   return FALSE;
}
 
__declspec(dllexport) void ClearDUDWCHook()
{
   if (hook && UnhookWindowsHookEx(hook))
   {
      hook = 0;
      hWnd = 0;
      ProcessID = 0;
   }
}
 
__declspec(dllexport) void KillDUD()
{
   if (hWnd && IsWindow(hWnd))
   {
      PostMessage(hWnd, WM_CLOSE, 0, 0);
      PostMessage(hWnd, WM_CLOSE, 0, 0);
      ClearDUDWCHook();
   }
}
 
static LRESULT CALLBACK CBTHook(int nCode, WPARAM wParam, LPARAM lParam)
{
   if (nCode == HCBT_CREATEWND && !hWnd)
   {
      HWND Window = (HWND)wParam;
      CBT_CREATEWND *pCW = (CBT_CREATEWND *)lParam;
      DWORD Process = 0;
      GetWindowThreadProcessId(Window, &Process);
      if (Process == ProcessID)
         hWnd = Window;
   }
   return CallNextHookEx(hook, nCode, wParam, lParam;
}


In the my program I call SetDUDWCHook() before InternetConnectAttempt() and ClearDUDWCHook() after. If the user presses the "Stop" button I call KillDUD(). Works like a charm. Thanks again.Big Grin | :-D








"You're obviously a superstar." - Christian Graus about me - 12 Feb '03

"Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04

Within you lies the power for good - Use it!
GeneralRe: Network connection dialogs - edited Pin
Ryan Binns25-Jul-04 17:43
Ryan Binns25-Jul-04 17:43 
Questionhow to load image and detect greylevel for each pixel? Pin
copico22-Jul-04 11:05
copico22-Jul-04 11:05 
AnswerRe: how to load image and detect greylevel for each pixel? Pin
l a u r e n22-Jul-04 11:23
l a u r e n22-Jul-04 11:23 
AnswerRe: how to load image and detect greylevel for each pixel? Pin
V.22-Jul-04 21:16
professionalV.22-Jul-04 21:16 
AnswerRe: how to load image and detect greylevel for each pixel? Pin
erkanina22-Jul-04 22:32
erkanina22-Jul-04 22:32 
GeneralSendInput and the Mouse Wheel Pin
User 1278222-Jul-04 8:51
User 1278222-Jul-04 8:51 
GeneralDatabase schama using MFC ODBC Pin
omair shafiq22-Jul-04 7:18
omair shafiq22-Jul-04 7:18 
GeneralRe: Database schama using MFC ODBC Pin
User 58385222-Jul-04 16:25
User 58385222-Jul-04 16:25 
GeneralHelp on Connecting ODBC!! Pin
Member 123981322-Jul-04 6:31
Member 123981322-Jul-04 6:31 
GeneralRe: Help on Connecting ODBC!! Pin
jmkhael22-Jul-04 6:49
jmkhael22-Jul-04 6:49 
GeneralRe: Help on Connecting ODBC!! Pin
David Crow22-Jul-04 7:13
David Crow22-Jul-04 7:13 
Generalproblem in my own message box Pin
magee8122-Jul-04 5:48
sussmagee8122-Jul-04 5:48 
GeneralRe: problem in my own message box Pin
Ryan Binns22-Jul-04 18:23
Ryan Binns22-Jul-04 18:23 
Generalmodeless dialog trouble Pin
ryuki22-Jul-04 5:26
ryuki22-Jul-04 5:26 
GeneralRe: modeless dialog trouble Pin
Chris Losinger22-Jul-04 7:00
professionalChris Losinger22-Jul-04 7:00 
GeneralRe: modeless dialog trouble Pin
ryuki22-Jul-04 9:36
ryuki22-Jul-04 9:36 
GeneralRe: modeless dialog trouble Pin
Chris Losinger22-Jul-04 10:00
professionalChris Losinger22-Jul-04 10:00 

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.