|
Subclass your childview[of MDI] and create a child[WS_CHILD] dialog on it.
--
======
Arman
|
|
|
|
|
Franken wrote: What I want is a modeless dialog, which behaves like a MDIView but without the overhead of the document.
yuck.
Franken wrote: It should be moveable only inside the client area of the application and not on the whole desktop.
double yuck.
but I'm a good sport.
Can't you create the modeless dialog with the MainFrame as a WS_CHILD of the main frame ? or something similar ?
I think I remember that you can set of the dialog style to do this.
|
|
|
|
|
Maximilien wrote: ...the MainFrame as a WS_CHILD of the main frame ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
ok, that was bad!
|
|
|
|
|
I also thought that it should be possible to set WS_CHILD style but haven't found a way to do this.
|
|
|
|
|
Do you want the MDIFrame window to be the parent or do you want to place the dialog in a
MDIChild frame?
Either way, the dialog needs to be a child and you need to specify the parent in the Create()
call.
You can set the child style in the resource editor, properties, style.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I set the style to child in the dialog editor properties and did the following during the creation of the dialog:
CMainFrame* pFrame = (CMainFrame*)GetMainWnd();
CChildFrame* pChild = (CChildFrame*)pFrame->GetActiveFrame();
CmyDlg* pDlg = new CmyDlg;
pDlg->Create(IDD_DIALOG_myDlg, pChild->GetParent());
pDlg->ShowWindow(SW_SHOW);
This is almost what I wanted but it shows some weird behaviour. When a region of the dialog is covered by another child window this region shows still the part of the child window even if I drag the dialog to another place. It only restores the correct dialog, when I resize the dialog. Is there somewhere a flag like redraw or something?
Many thanks ,
Frank.
|
|
|
|
|
hmm I'm not sure if there's different invalidation with MDI windows (which differ from other
windows because they're controlled by an "MDICLIENT" class window).
I have a feeling it's due to activation issues. Mixing a non-MDI child window in a MDI client
window isn't necessarily going to work properly.
I still think it's much easier to make the dialog a client window of a CMDIChildWnd frame. There
shouldn't be any issues then.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Here's some more info: Using the Multiple Document Interface[^]
As you can see in the Window Procedure sections, the MDI windows use different default window
procs so they can/will behave differently than normal parent/child windows.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
You could do something like:
BOOL CModelessDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rc;
GetWindowRect(rc);
m_lWidth = rc.Width();
m_lHeight = rc.Height();
AfxGetMainWnd()->GetWindowRect(m_rcParent);
return TRUE;
}
void CModelessDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
CDialog::OnMoving(fwSide, pRect);
pRect->left = min(pRect->left, m_rcParent.right - m_lWidth);
pRect->left = max(pRect->left, m_rcParent.left);
pRect->top = min(pRect->top, m_rcParent.bottom - m_lHeight);
pRect->top = max(pRect->top, m_rcParent.top);
pRect->right = min(pRect->right, m_rcParent.right);
pRect->right = max(pRect->right, m_rcParent.left + m_lWidth);
pRect->bottom = min(pRect->bottom, m_rcParent.bottom);
pRect->bottom = max(pRect->bottom, m_rcParent.top + m_lHeight);
} It works regardless of whether WS_POPUP or WS_CHILD is used. A parent can be specified or not.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
after playing with some LockWindowUpdate / UnlockWindowUpdate and SetRedraw(FALSE) / SetRedraw()
i have a problem with a view, a grid on this view disappears after drawing.
I removed all LockWindowUpdates,Unlock,SetRedraws and the problem is still there.
I added a this->RedrawWindow(); at the end of the initialisation but this line
erases the hole view,the grid and all other components ( it will be redrawn if the MainForm will be minimized/restored)
It seems as the Invalidations are working inverted
big thanks in advance
-- modified at 7:55 Tuesday 20th March, 2007
I removed the line where i add the row to the grid and all is ok.
I re-insert the line and the Grid becomes invisible(not drawn)
But i have nothing changed at the grid, at the moment i have so strange problems
The same with a class which i allocate in a thread and delete at the end of the function.
If i set 0 to a variable, the debugheap is corrupted at the destruction of the element.
if i dont set a value to the variable, i don't get an error...
|
|
|
|
|
I resolved the problem partially.
I put a Grid->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME);
into the EraseBackground Handler.
But it's not the reason of the problem.
If i put the view directly into a frame( not into a TabWnd of another view ) it works also without errors.
|
|
|
|
|
Hello,
Is it safe to use:
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap *m_pOld = memDC.SelectObject(&some_bitmap1);
memDC.SelectObject(&some_bitmap2);
memDC.SelectObject(&some_bitmap3);
memDC.SelectObject(&some_bitmap4);
....
memDC.SelectObject(m_pOld);
memDC.DeleteDC;
or I should use SelectObject(m_pOld)/DeleteDC() after each SelectObject(&some_bitmapX)??
|
|
|
|
|
PatrykDabrowski wrote: Is it safe to use:[...]
Yes.
PatrykDabrowski wrote: or I should use SelectObject(m_pOld)/DeleteDC() after each SelectObject(&some_bitmapX)??
No.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks
|
|
|
|
|
No it is not safe to use.It will cause memory leak in your application.
I think,II Option is better one.Use SelectObject(m_pOld)/DeleteDC() after each SelectObject(&some_bitmapX)??
priyank
|
|
|
|
|
I have already tried both versions. None of them reports memory leaks in VS2003 in Debug mode. But maybe those resources are not monitored by VS... That's why I'm askng
Thanks!
|
|
|
|
|
pri_skit wrote: No it is not safe to use
Its safe.. its nothing to do with leaks (if we delete the selected objects)
or simply we can do like this,
CDC dc;
dc.SaveDC();
dc.RestoreDC( -1 );
No need to worry about the old objects..
Do your Duty and Don't expect the Result
|
|
|
|
|
Yes, I delete some_bitmapX objects (when exiting the app as they are 'global').
What I care about is:
1) Performance
2) Avoid memory/resource leaks.
Is CDC::CreateCompatibleDC()/DeleteDC() slower comparing to CDC::SaveDC()/RestoreDC()??
Thanks for help.
|
|
|
|
|
|
CPallini wrote: Please revise the order of your list
so true !
|
|
|
|
|
I should put 1) && 2)...in fact as long as I dont have leaks, I care more about performance So the order is fine
|
|
|
|
|
|
I have written "as long as I dont have leaks, I care more about performance ";)...so my priority is to avoid memory leaks and then I optimize my code.
I assume that both solutions don't cause leaks so I would like to choose faster one. (I mean CDC::CreateCompatibleDC()/DeleteDC against CDC::SaveCD()/RestoreDC() )
|
|
|
|
|
PatrykDabrowski wrote: I have written "as long as I dont have leaks, I care more about performance ";)...so my priority is to avoid memory leaks and then I optimize my code.
ok for me then
|
|
|
|