用哪个参数?没找着.太小看着不舒服,想改大一点.

解决方案 »

  1.   

    不可以,除非你在MessageBox前新建一个线程来FindWindow
    不过这样做还不如用 DoModal 来显示一个新的对话框
      

  2.   


    INT CBTMessageBox(HWND hwnd, LPSTR lpText, LPSTR lpCaption,
                      UINT uType)
    {
      hhk = SetWindowsHookEx(WH_CBT, &CBTProc, 0,
                             GetCurrentThreadId());
      return MessageBox(hwnd, lpText, lpCaption, uType);
    }LRESULT CALLBACK CBTProc(INT nCode, WPARAM wParam, LPARAM lParam)
    {
      HWND  hParentWnd, hChildWnd;    // msgbox is "child"
      RECT  rParent, rChild, rDesktop;
      POINT pCenter, pStart;
      INT   nWidth, nHeight;  // notification that a window is about to be activated
      // window handle is wParam
      if (nCode == HCBT_ACTIVATE)
      {
        // set window handles
        hParentWnd = GetForegroundWindow();
        hChildWnd  = (HWND)wParam;    if((hParentWnd != 0) &&
           (hChildWnd != 0) &&
           (GetWindowRect(GetDesktopWindow(), &rDesktop) != 0) &&
           (GetWindowRect(hParentWnd, &rParent) != 0) &&
           (GetWindowRect(hChildWnd, &rChild) != 0))
        {
           // calculate message box dimensions
           nWidth  = (rChild.right - rChild.left);
           nHeight = (rChild.bottom - rChild.top);       // calculate parent window center point
           pCenter.x = rParent.left+((rParent.right
                     - rParent.left)/2);
           pCenter.y = rParent.top+((rParent.bottom
                     - rParent.top)/2);       // calculate message box starting point
           pStart.x = (pCenter.x - (nWidth/2));
           pStart.y = (pCenter.y - (nHeight/2));       // adjust if message box is off desktop
           if(pStart.x < 0) pStart.x = 0;
           if(pStart.y < 0) pStart.y = 0;
           if(pStart.x + nWidth > rDesktop.right)
              pStart.x = rDesktop.right - nWidth;
           if(pStart.y + nHeight > rDesktop.bottom)
              pStart.y = rDesktop.bottom - nHeight;       // move message box
           MoveWindow(hChildWnd,
                      pStart.x, pStart.y,
                      nWidth, nHeight,
                      FALSE);
        }
        // exit CBT hook
        UnhookWindowsHookEx(hhk);
      }
      // otherwise, continue with any possible chained hooks
      else CallNextHookEx(hhk, nCode, wParam, lParam);
      return 0;
    }