|
Hello,
I have an application that carries out multiple tasks in succession. I was hoping to mimic the Windows style install list akin http://imageshack.us/photo/my-images/85/win7installex.png/
I have the required icons and animation files but as of yet an unable to display an .ani file on the dialog.
Thanks in advance.
|
|
|
|
|
You need to give some more detail about exactly what you are trying to do and what parts of your code you are having a problem with.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
Essentially I was just trying to display an ani file on the dialog.
I've converted the ani file to byte array and using CreateIconFromResourceEx to create the cursor.
All working now, thanks for the advice.
|
|
|
|
|
Hello
I would like to add a CDialog-derived template as a pane in a CMFCOutlookbar (instead of simple controls as shown on lots of samples) ... I saw some code on the Web but nothing is working...
Thanks for any clue or sample code to do this ...
Thierry
|
|
|
|
|
You could try adding a CDialogBar class to the pane.
|
|
|
|
|
Ok ... It works ... Thanks for the clue ...
Thierry
|
|
|
|
|
Hi all,
I have a problem when trying to resize main window of my application. I spent some time reserching possible solutions, but so for nothing works for me. I guess I make some basic mistake.
So - the code bellow is executed when user clicks on one of the buttons. I tried 3 different approaches to achieve it, everytime getting assertion error (looks to me like the window handle is invalid...)
My first approach:
WINDOWPLACEMENT wpc;
CRect rc(0, 0, 0, 0);
this->GetWindowRect(&rc);
rc.right += 50;
this->GetWindowPlacement (&wpc);
wpc.rcNormalPosition = rc;
this->SetWindowPlacement(&wpc);
Second approach:
CRect rc(0, 0, 0, 0);
this->GetWindowRect(&rc);
rc.right += 50;
ScreenToClient( &rc );
this->MoveWindow(rc);
and the third one:
CRect rc(0, 0, 0, 0);
this->GetWindowRect(&rc);
rc.right += 50;
ScreenToClient( &rc );
this->SetWindowPos(this->m_hWnd, rc.left, rc.top, rc.Width(), rc.Height(), SWP_SHOWWINDOW);
The SetWindowPos() function doesn't return assertion error when I use this combination of flags: SWP_SHOWWINDOW|SWP_NOSIZE. However then it doesn't resize the window and it's useless for me.
I also checked than 'this' pointer is not corrupted by checking the
window text:
char title[80];
::GetWindowText (m_hWnd, title, sizeof(title));
It comes as I expect so I guess 'this' pointer itself is OK.
Any ideas?
|
|
|
|
|
what assertion error are you getting? when you call this , that's the object instance of whatever object you're calling that within, what object type is that?
btw... if the error is telling you that the window handle is invalid, then you're probably not passing the argument correctly (it usually does a check as to whether that handle corresponds to any available windows)...and you're using SetWindowPos() wrong, look at the documentation again:
http://msdn.microsoft.com/en-us/library/a1yzfz6d%28v=VS.80%29.aspx[^]
|
|
|
|
|
I'm going through the code line by line in debug mode and on the line with SetWindowPos() Visual Studio comes with 'Debug Assertion Failed!' window. It doesn't give me any specific information. When I click on 'Retry' then it takes me to 'wingdi.cpp' file, to BOOL CDC::Attach(HDC hDC) function with yellow arrow at the first line of it:
ASSERT(m_hDC == NULL);
So that's why I assumed it's something wrong with the window handle.
My this is 'CGraphDlg* const' type. CGraphDlg is my main dialog class:
class CGraphDlg : public CDialog
I've changed the way I'm using SetWindowPos() to that:
this->SetWindowPos(&CWnd::wndBottom, rc.left, rc.top, rc.Width(), rc.Height(), SWP_SHOWWINDOW);
but I'm still getting the same problem.
I guess I can't use this here. I need some other pointer to the main window, but I'm not sure how to get it.
Or is this problem occurring because I'm using dialogs?
|
|
|
|
|
That assert is telling you the device context is NULL, a separate issue. Where are you calling this from? From the OnPaint()? If so, that may be causing the issue (although I'm not sure it would or not). Try pulling the call to some other method that doesn't handle the device context.
|
|
|
|
|
I'm calling it from push button event.
I moved the resizing code to the OnInitDialog() and the window was resized without any problems. I'm drawing a graph in this window. I do that in InitGraph() function which is called from InitDialog. So if I place the SetWindowPos() before call to InitGraph() then it works. If I place it after, then I have an error.
Looks to me that I do something wrong with DC in InitGraph() :
void CGraphDlg::InitGraph()
{
CRect rectControl5; CBitmap image;
CDC * pDC = GetDC();
if (!not_first_paint)
{
image.LoadBitmap(IDB_GRAPHBLANK); dcGraphMem.CreateCompatibleDC(pDC);
dcGraphMem.SelectObject(&image);
}
GetClientRect(GraphWindow);
YSCALE = GraphWindow.Height() - 191;
graphx = GraphWindow.Width() - 212;
StretchBlt (dcGraphMem, 0, 0, GraphWindow.Width(), GraphWindow.Height()-25, dcGraphMem, 0, 0, 1600, 1044 , SRCCOPY);
ReleaseDC(pDC) ;
m_divline.GetParent()->GetClientRect(GraphWindow);
m_divline.GetWindowRect(rectControl5);
m_divline.MoveWindow(0, GraphWindow.Height()-BOTTOMCONTROLS-2, rectControl5.Width(), rectControl5.Height());
image.DeleteObject();
not_first_paint = true;
return;
}
|
|
|
|
|
How often do you call this? ...if it's called every time the graph is painted, you're trying to resize the window every single time and that's probably not what you want.
|
|
|
|
|
I found what the problem is.
I tried to resize the window with DC still attached to it. That's why I had the assertion failure.
I added this code before resizing:
if (dcGraphMem.m_hDC != NULL)
dcGraphMem.DeleteDC();
and this after resizing:
CDC * pDC = GetDC();
if (dcGraphMem.m_hDC == NULL)
dcGraphMem.CreateCompatibleDC(pDC);
and now it works OK.
Thank you all for your help.
|
|
|
|
|
You should not be holding a DC like this in the first place. You only need a DC at the time you need to display anything, which is in your OnPaint() function, it has no purpose when resizing.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
If you have to do this... you may be resizing the window in a method where it's not appropriate to do so. See Richard's comment about the device context. You should only be holding the DC when you're actually doing any GDI drawing, otherwise, it should be released. That's sort of what's causing your problem in the first place, you're making a call to a method that requires the DC when you're already holding it up.
Hope you understand all this gibberish... good luck!
|
|
|
|
|
Well I'm not holding the DC. What I do is open DC in the InitDialog for short time only to create compatibile memory DC, and then I draw my graph in memory DC. When necessary I open the DC again and copy the memory DC into DC.
if (dcGraphMem.m_hDC == NULL) {
CDC * pDC = GetDC();
dcGraphMem.CreateCompatibleDC(pDC);
ReleaseDC(pDC) ;
}
then I operate on dcGraphMem and when it's ready I do that:
CDC * pDC = GetDC();
if(pDC == NULL)
{
return;
}
pDC->BitBlt(0, 0, GraphWindow.Width(), GraphWindow.Height()-BOTTOMCONTROLS-2, &dcGraphMem, 0, 0, SRCCOPY);
ReleaseDC(pDC);
I thought that memory DC is not linked with window directly, however it looks like I need to delete it before I resize the window, and then create it again. Why is that?
|
|
|
|
|
You don't need to delete it, you just can't hold it up, it's not hooked to the window directly, but your application won't be able to attach to the drawing context twice (it will eventually fail, as you've found out). You also should be drawing on your InitDialog() (this is for initializing controls really), that's not the proper place for that.
Any drawing should occur on OnPaint(), alternatively, no resizing should occur within OnPaint() (can't think of any legitimate reason to do so). Reason to keep all drawing in OnPaint()... that's the method the framework will call every time the framework determines your window needs to be redrawn, for whatever reason, anything from a resize to a window getting placed over your window then removed, etc, will trigger a call to OnPaint().
|
|
|
|
|
blackbolek wrote: The SetWindowPos() function doesn't return ...
The call to ScreenToClient() is changing the values in rc so that is not going to do what you want.
blackbolek wrote: I also checked than 'this' pointer is not corrupted by checking the window text:
But you did not call it with the this pointer so the code is not the same as all your other calls to windows functions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
To add on to what Richard said... using this on a window object is not the same as using it's handle. Reason is, this refers to the object instance and not the handle to the window, which is different (they are linked together when a window is created, not when the object is created, but even then, they are not the same).
...Just in case in needs to be clarified....
|
|
|
|
|
With ScreenToClient() commented off it gives me still the same 'Debug Assertion Failed' message.
Also I've modified the line which gets the window title to this:
::GetWindowText (this->m_hWnd, title, sizeof(title));
And I still get proper window title.
|
|
|
|
|
blackbolek wrote: ::GetWindowText (this->m_hWnd, title, sizeof(title));
and that is how I would attempt to get and set window position and size too, with an explicit hWnd, and not trough this->...
|
|
|
|
|
You need to get your debugger working and check exactly where this assertion occurs and which variable it is complaining about. Also you should be calling these Windows functions via the class methods. If ::GetWindowText() works as shown above then it should also work with the following:
GetWindowText(title, sizeof(title));
which is the correct way to code it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
This is in reference to a MFC COM project I'm working on VC6.
The question is in regard to the top level menu.
The project contains a top level menu, say "Options"
I need to do certain “operations”, say toggle a BOOL value when the menu pane is open and when the menu pane is closed.
On selecting “Options”, WM_INITMENUPOPUP message is received and I can handle the functionality under this and make the BOOL variable TRUE.
The issue arises when the menu pane closes without selecting any menu option, I do not receive any windows message to handle and there is no confirmation that the menu pane is closed. Hence no location to toggle the BOOL variable.
I’ve checked on WM_UNINITMENUPOPUP message, but this message is not handled for VC6.
I’ve tried to retrieve the HMENU handle to the menu, but this is not possible as the menu is created in a different project altogether and hence I cannot use MENUBARINFO structure to find out if the menu is open or not.
Hence, the current challenge I face is whether or not the menu pane has been closed.
Is there any way to know if the menu pane is visible using the ids of the menu items or any other approach?
Thanks in advance for your thoughts
Regards,
Ravish
|
|
|
|
|
How about WM_EXITMENULOOP[^]?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|