Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Dialog Hidden on Initialization

Dialog Hidden on Initialization

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingquestionlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    c121hains
    wrote on last edited by
    #1

    Why doesn't this work? I made a dialog based application in MFC. When the program is launched, I want it to be hidden. I'm using a global keyboard hook to respond to a key press and restore the window. This part works fine. It seems that i can hide the dialog by putting ShowWindow(SW_HIDE); in a button handler. So.. it works if i press a button on the dialog but not when the program starts. This code from Microsoft MSDN does not do anything. But it should: /* MyDialog.cpp */ #include "MyDialog.h" BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_cMyEdit.SetWindowText("My Name"); // Initialize control values m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } I've read in so many places that by putting ShowWindow(SW_HIDE); in the OnInitDialog(), it will hide the dialog when the program starts. It doesn't do anything for my program. But ShowWindow(SW_MINIMIZE) works in that location for some reason!!!!!!!! Even by setting the dialogs extended properties in the resource manager (unselecting the Visible checkbox), doesn't do anything. If i put the ShowWindow(SW_HIDE); in the application's initialization (before the command to CMyDialog.DoModal()), I get an exception message "Debug Assertion Failure"!! Why?!!??!!?!?!??

    T 1 Reply Last reply
    0
    • C c121hains

      Why doesn't this work? I made a dialog based application in MFC. When the program is launched, I want it to be hidden. I'm using a global keyboard hook to respond to a key press and restore the window. This part works fine. It seems that i can hide the dialog by putting ShowWindow(SW_HIDE); in a button handler. So.. it works if i press a button on the dialog but not when the program starts. This code from Microsoft MSDN does not do anything. But it should: /* MyDialog.cpp */ #include "MyDialog.h" BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_cMyEdit.SetWindowText("My Name"); // Initialize control values m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } I've read in so many places that by putting ShowWindow(SW_HIDE); in the OnInitDialog(), it will hide the dialog when the program starts. It doesn't do anything for my program. But ShowWindow(SW_MINIMIZE) works in that location for some reason!!!!!!!! Even by setting the dialogs extended properties in the resource manager (unselecting the Visible checkbox), doesn't do anything. If i put the ShowWindow(SW_HIDE); in the application's initialization (before the command to CMyDialog.DoModal()), I get an exception message "Debug Assertion Failure"!! Why?!!??!!?!?!??

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      see here http://www.voidnish.com/articles/ShowArticle.aspx?code=dlgboxtricks[^]

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups