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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problems moving date and time control on MFC dialog [modified]

Problems moving date and time control on MFC dialog [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
2 Posts 1 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.
  • B Offline
    B Offline
    Barry True
    wrote on last edited by
    #1

    I've got an MFC CDialog class that displays and manages a dialog. There are several controls on the dialog (combo boxes, edit boxes, static text boxes, etc.). Included in the mix are four Microsoft date and time controls. The dialog is used in three separate instances. Not all of the controls are relevant in all three instances so we hide the controls that aren't relevant in each instance, move the controls around on the screen, and resize the dialog to eliminate dead areas on the dialog. We are getting the CWnd for each control and using the CWnd::SetWindowPos() method for each control to move it where we want. To eliminate the need to know which control appears before it in the Z-Order, we pass a NULL for the first parameter and use the SWP_NOZORDER parameter for the flags to keep from changing the tab order of the controls. This works perfectly for all the controls except the four date time pickers. When the dialog is displayed, the date/time picker controls are not visible. It appears that they were moved off the screen somehow or the dialog itself is now at a higher Z-Order than the date and time picker controls. The code was originally invoking SetWindowPos with the first parameter set to NULL and the nFlags parameter set to 0. This changed the tab order for all the controls but the date and time picker controls were visible after everything was moved. The only thing I've changed is to pass the SetWindowPos call the SWP_NOZORDER flag. I've also tried invoking CWnd::MoveWindow instead of CWnd::SetWindowPos but the results were no different. Why is just setting the nFlags parameter to SWP_NOZORDER causing the date and time picker controls to not show up on the dialog after the move? -- modified at 16:08 Monday 23rd April, 2007

    B 1 Reply Last reply
    0
    • B Barry True

      I've got an MFC CDialog class that displays and manages a dialog. There are several controls on the dialog (combo boxes, edit boxes, static text boxes, etc.). Included in the mix are four Microsoft date and time controls. The dialog is used in three separate instances. Not all of the controls are relevant in all three instances so we hide the controls that aren't relevant in each instance, move the controls around on the screen, and resize the dialog to eliminate dead areas on the dialog. We are getting the CWnd for each control and using the CWnd::SetWindowPos() method for each control to move it where we want. To eliminate the need to know which control appears before it in the Z-Order, we pass a NULL for the first parameter and use the SWP_NOZORDER parameter for the flags to keep from changing the tab order of the controls. This works perfectly for all the controls except the four date time pickers. When the dialog is displayed, the date/time picker controls are not visible. It appears that they were moved off the screen somehow or the dialog itself is now at a higher Z-Order than the date and time picker controls. The code was originally invoking SetWindowPos with the first parameter set to NULL and the nFlags parameter set to 0. This changed the tab order for all the controls but the date and time picker controls were visible after everything was moved. The only thing I've changed is to pass the SetWindowPos call the SWP_NOZORDER flag. I've also tried invoking CWnd::MoveWindow instead of CWnd::SetWindowPos but the results were no different. Why is just setting the nFlags parameter to SWP_NOZORDER causing the date and time picker controls to not show up on the dialog after the move? -- modified at 16:08 Monday 23rd April, 2007

      B Offline
      B Offline
      Barry True
      wrote on last edited by
      #2

      I was able to work around the issue but I really don't like the solution. I used the CWnd::SetWindowPos method passing a NULL for the pWndInsertAfter parameter and 0 for the flags. This, in essence, reverses the tab order of all the controls on the dialog since the code is invoking this for each of the controls on the dialog in order from top-to-bottom and left-to-right on the dialog. After doing this, I added code to go back through each of the controls in the same order calling CWnd::SetWindowPos with the proper CWnd pointer for the pWndInsertAfter parameter and SWP_NOMOVE and SWP_NOSIZE for the nFlags parameter. Some additional information: The date and time picker controls don't show up in the Controls window when the dialog is displayed in the Resources panel in the IDE. It appears the date and time pickers are being accessed through the IDTPicker interface in mscomct2.ocx. This OCX is being imported in the class definition header file and the four controls are defined as MSComCT2::IDTPickerPtr data types in the class definition. I'm not sure if this has anything to do with my intial problem. While the workaround is probably sufficient for our needs, I'd still like to know why CWnd::SetWindowPos with the SWP_NOZORDER flag or CWnd::MoveWindow didn't work on the date and time pickers.

      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