1

I am making an SDI MDF application that uses a frameview to provid the user with a set of controls (buttons, editboxes and such). The view also owns a set of CDialogs used to desplay aditional controls that can be can be shown or hidden via a tabcontrol and other means. Untill recently the dialogs have been staticly placed at creation to be in their proper location on the screen but I wanted to add a dialog that the user could move around but is still a child of the view. When I created a dialog with a caption and sysmenu that the user can move around the issue I am running into is that when the window is placed over another control owned by the view, (lets say a button) when the paint method is called on the button, it draws over the dialog. The dialog is still on top and the dialogs controls can still be interacted with but the button is drawn over them untill the dialog is repainted. I have tryed to change the clipchild and clipsiblings settings of the dialog and have been able to get the dialogs to properly clip eachother but can not seem to get the child dialog to properly clip the parent view controls. Does anyone have any ideas on what setting might fix this clipping issue.

JBode
  • 23
  • 3
  • how do you create the floating dialog? – cha Feb 21 '13 at 21:23
  • I just give the dialog the caption style and allow the default handeler to give the user the ability to drag the dialog around by clicking on the title bar – JBode Feb 22 '13 at 12:39
  • Select "Popup" as the style of the floating dialog instead of "Child". – mfc Feb 22 '13 at 14:41
  • That would work and I have tryed that but I have message passing happening between the parent and all children so I dont know how to include a non child dialog in that message passing in an extendable way. Right now I use the sendToAllChildren function so adding new dialogs doesnt require any modification to the message passing. – JBode Feb 25 '13 at 12:15
  • Do you mean CWnd::SendMessageToDescendants ? You can alway add a SendMessage call to sent the same message to the additional floating dialog(s). – mfc Feb 25 '13 at 13:17
  • Yes I did mean SendMessageToDescendants, sorry I didnt bother to look the name up. That solution would probably work but it introduces a few more issues, A popup dialog isnt bound by the parent window like a child dialog is and also the code becomes harder to maintain. The message redirecting method will have to be modified to send messages to all popup dialogs made by the application which means that whenever a dialog of that type is added or removed the method will have to be altered. Also a dialog should be able to paint without clipping issues. Is this just a shortcomming of MFC? – JBode Feb 26 '13 at 15:31
  • Yes, indeed you are right about your problems about popup dialog, I actually tested out your problem before I commented about the popup style. I initially thought that it is quite a simple problem to solve, but I ended up spending a couple of hours and found no reliable solution/hack to it. I then look at professional softwares like paintbrush etc. and found that they are also using the same popup way of floating dialog for palette, tools, colors selection too. – mfc Feb 26 '13 at 21:15
  • One work-around is to embed the floating dialog as a member variable inside of one visually-related child-object-class that can receive message from SendMessageToDescendants. Let this child class manage the floating dialog instead of the view. So in this way, the state of the floating dialog will follow this child object when it is being created/destroyed/moved/resized in sync. You can also handle the OnMove in the dialog to prevent it from being moved too far away by moving it back by code. – mfc Feb 26 '13 at 21:58
  • That is a pretty good idea and probably the best solution to the problem. I appreciate the help. It is just a little dissapointing that MFC cant handle some pretty basic but fundemental concepts. I guess I should probably go with a more recent interface library if I want to do anything that isnt a fairly static window. – JBode Feb 27 '13 at 12:45

0 Answers0