同時起動時ActiveなDialogWindowを非Activeにする

解決


hannya  2012-05-17 15:37:26  No: 73382  IP: 192.*.*.*

環境  WindowsXp、VSC++6.0
現状  使用変数を取り入れるModelessDialogWindowはCKolamDesignerAppプログラムを起動すると 同時に表示され、かつactiveになります。本体(ChildViewで表示している)のWindowはカーソルで一度クリックしてactiveになります。
希望は表示はするが、activeなWindowはDialogではなく、本体のViewにしたい。
どのようなコードがあればよいか助言をおねがいします

dialogWindowの表示設定は以下のとおりです

void CChildView::OnParameterSet() 
{
  // 2009/10/27 t.yoshino モードレス表示
  // 親ウィンドウの位置を得る
  CRect rectParent;
  GetWindowRect(&rectParent);
  // 子ウィンドウの位置を得る
  CRect rectChild;
  m_wndParam.GetWindowRect(&rectChild);
  // 親の右端から子の幅分オフセットさせた位置に配置
  long width = rectChild.right - rectChild.left;
  rectChild.right = rectParent.right;
  rectChild.left = rectChild.right - width;
  // 親ウィンドウの中ほどの高さに配置 by ミッヒー
  long parentHeight = rectParent.bottom - rectParent.top;
  long childHeight = rectChild.bottom - rectChild.top;
  rectChild.top = rectParent.top + parentHeight / 4;
  rectChild.bottom = rectChild.top + childHeight;
  // ここまで
  m_wndParam.MoveWindow(&rectChild);
  m_wndParam.BringWindowToTop();  // 前に持ってくる
  m_wndParam.ShowWindow(SW_SHOW); // 表示
} //endof OnParameterSet(

// CKolamDesignerApp initialization
BOOL CKolamDesignerApp::InitInstance()
{
  AfxEnableControlContainer();

  pFrame->PostMessage(WM_COMMAND, ID_PARAMETER_SET);
  
  return TRUE;
}

編集 削除
forty-five  2012-05-29 20:13:21  No: 73383  IP: 192.*.*.*

> m_wndParam.MoveWindow(&rectChild);
> m_wndParam.BringWindowToTop();  // 前に持ってくる
> m_wndParam.ShowWindow(SW_SHOW); // 表示

ここを

m_wndParam.SetWindowPos(
  wndTop,
  rectChild.left,
  rectChild.top,
  rectChild.right - rectChild.left,
  rectChild.bottom - rectChild.top,
  SWP_NOACTIVATE | SWP_SHOWWINDOW);

に変えてみたらどうですか?

編集 削除
はんにゃ  2012-06-09 06:45:27  No: 73384  IP: 192.*.*.*

助言ありがとう
残念ながら  以下のエラーになりました
mDesigner4.6.2\ChildView.cpp(551) : error C2664: 'SetWindowPos' : 1 番目の引数を 'const class CWnd' から 'const class CWnd *' に変換できません。 (新しい機能 ; ヘルプを参照)
        この変換を実行可能なユーザー定義変換演算子がないか、または演算子を呼び出せません。
この対処法は初歩のことかもしれませんが  教えてください

編集 削除
forty-five  2012-06-15 22:41:51  No: 73385  IP: 192.*.*.*

m_wndParam.SetWindowPos(
  &wndTop,
  rectChild.left,
  rectChild.top,
  rectChild.right - rectChild.left,
  rectChild.bottom - rectChild.top,
  SWP_NOACTIVATE | SWP_SHOWWINDOW);

でいいんじゃない?

編集 削除
はんにゃ  2012-06-17 07:28:52  No: 73386  IP: 192.*.*.*

ありがとうございました
期待どうりになりました。

一度は  &wndTopポインター変数にしてみたのですが、同じ様なエラーが出たのです、
なにか他も変えたためにエラーになったのでしょう。
今回は注意深く  そこだけ変えて  正しく動作しました

編集 削除