|
Hi,
I am trying to compile a .cpp program which contains RichOle.h I get compiler error which make no sense to me
typedef struct _reobject
line 18 {
line 19 DWORD cbStruct;
LONG cp;
CLSID clsid;
LPOLEOBJECT poleobj;
LPSTORAGE pstg;
LPOLECLIENTSITE polesite;
SIZEL sizel;
DWORD dvaspect;
DWORD dwFlags;
DWORD dwUser;
} REOBJECT;
compiler errors
C:\Program Files\Microsoft Platform SDK\Include\RichOle.h(18) : error C2146: syntax error : missing ; before identifier ;once;
C:\Program Files\Microsoft Platform SDK\Include\RichOle.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Platform SDK\Include\RichOle.h(19) : error C2143: syntax error : missing ; before ;class-head;
C:\Program Files\Microsoft Platform SDK\Include\RichOle.h(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
;progdialog.cpp
I think I need some pragma directive to to compile the above structure as a "C" type progam
any help would
|
|
|
|
|
There's nothing wrong with that line, it's a C-style structure definition, which is also valid in C++. You probably have a problem somewhere before that header is loaded and it's just causing the compiler to think there's a problem with that definition. Look for missing ';' characters in the file where you included this header.
|
|
|
|
|
look at the lines in your cpp code before the include of richole.h, there might be a syntax error there that is manifesting itself in the h file. Don't forget, "include" is the equivalent of "paste the file here" so you should think of the cpp file as one continuous piece.
|
|
|
|
|
ForNow wrote: I get compiler error which make no sense to me
It is telling you there's a syntax error in the included RichOle.h header file, at line 18.
Pardon the silly question: "Did you include windows.h, before it?"
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified 10-Jan-12 16:55pm.
|
|
|
|
|
Nothing silly about that question. IMHO.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thank you, Richard. I was downvoted for the previous sentence (though my sarcasm was completely switched OFF while writing it).
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Sometime some Visual Studio compiler error is really confusing.
As far I can understand may be there is no error in neither your source code or your RichOle.h Source code. Probably its missing some special header file that defines lots of macros. Make sure your windows.h is defined before RichOle.h
|
|
|
|
|
I, too, consider this the most likely cause.
It's sad how in so many years of compiler history, MS still fails to create their headers in a way that does not require a specific order of inclusion. It wouldn't be so bad, if that wouldn't trigger totally unrelated error messages, but apparently they don't get that either.
A practical solution is to use the VS Project Wizard to create a new Windows application (MDI, SDI, or dialog-based, depending on your needs), and switch on precompiled headers, then copy the resulting stdafx.h into your own project. It should contain the inclusion statements for windows.h and pretty much everything else you need, and in the correct order. (this is only to get the full list of include statements, and in the right order - you can also just copy the include lines from stdafx.h to the relevant cpp files in your project instead if you don't use PCH)
|
|
|
|
|
include "windows.h", "richedit.h", and "richole.h" in your "stdafx.h" header file. Then include "stdafx.h" in my main cpp file.
As in MSDN[^]!
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
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!
|
|
|
|