|
Generally BSTR creates memory leak.Hence in order to avoid it use either _bstr_t or CComBstr.
And even instead of BSTR* use BSTR object and pass the address to the function.
And free it through SysFreeString function.
BSTR m_bstr;
IHash->Digest(szTemp.m_str, &m_bstr);
...
..
SysFreeString(m_bstr);;P
:p
|
|
|
|
|
I have just started to make my first MFC programs, and I am having a big problem. Whenever I alter the code and need to insert a heared file I recieve all kinds of errors. For example I am writing a program that contains a splitter window, with forms on both sides. In it I call splinterwnd.CreatView with a reference to the form class. But when I put the form header at the top I get errors (mainly c:\program files\microsoft visual studio\myprojects\temp\tempview.h(27) : error C2143: syntax error : missing ';' before '*')
How do I know where to put the header file?
|
|
|
|
|
This means that you need to include a header for whatever it is this line references. The header file goes in the top of the .h if it's for a member variable, otherwise the .cpp. It needs to be under the main ones (stdafx.h, the classes own header file ) and you need to make sure ( mainly by not putting it in the .h unless you need to ) that you don't create a circular reference where two headers load each other.
More than that, I cannot tell without seeing the code.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
This is something I wish someone would write an article on - with an aim of avoiding having to nest header includes in MFC projects. The problem arises as translation units include headers you're not expecting them to, and a nice directed include graph of an MFC app would be a boon.
But here's a tip that might help - if you add a new class, include its header in the cpp file that holds the application class (MyApp.cpp) right after stdafx.h. Then, include it in whatever .cpp file will be using it, before the header for that file.
The application class is typically the first translation unit to get compiled in these projects, and often the scope of its includes (doc and view, e.g.) are what cause the kaffufle.
later...
Actually, on reading your message again, you might be able to just get by with a forward declation of the form class at the top of the header, since you are just declaring a pointer.
----
"If you would see the invisible, you must look carefully at the visible."
Santayana
|
|
|
|
|
Hi
I am starting the netmeeting application from vc++ application using
createprocess.
But it just starts the netmeeting application. But My reqmt is to start
and connect to ip address x.x.x.x. and username xxx and password xxx.
How do i achieve this. If i use netmeeting sdk can i do that...what is exact api
for this..
how do i use callto function ?
Also if i want to run a netmeeting shortcut in my desktop, how do I achieve this. i.e i want to simulate the double click of a shortcut icon, which will launch the application associated with it.
any idea..thanks in advance
raju
|
|
|
|
|
I think you want to use ShellExecute, which allows you to specify command line parameters.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
In OnNewDocument in my MDI, I go out and get a bunch of information. Depending on what is retrieved, I need to use a different view, in my case a CEditView or CHtmlView. I have looked over the article "Replacing a view in a doc-view application" but that article assumes you already have a view. Specifically the lack of a AfxGetMainWnd()->MDIGetActive() causes problems.
I want to use one type of view if the CDocument data meets a certain condition and a different view if it meets another condition. Can anyone point me in the right direction?
|
|
|
|
|
Check the Paul DiLascia article that appeared in Feb'96 issue of MSJ:
http://msdn.microsoft.com/library/periodic/period96/SFFD.htm
The solution doesn't use OnNewDocument. Instead, it overrides the InitialUpdateFrame, which is a virtual method of CDocTemplate. The decision which view to use is delegated to user-defined method. This allows you to display CEditView or CHtmlView depending on context.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
With a few modifications it worked like a champ. Thanks.
|
|
|
|
|
Someone can send me an example of an MDI Application where I can open file of different extension, (extension created by myself)
If not, how register the extensions...and no more obtain the following message : IDP_FAILED_TO_CREATE ?
Thank a lot.
Leo.
|
|
|
|
|
It's all done in OnOpenDocument in your View class, although from memory some of it routes back through your App class as well with the first file you open. Just overload it, show your own dialog, with the extensions shown you want to support, then examine the return and load the file appropropriately.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
i'm trying to use SetScrollSizes() and ScrollToPosition() in my program. I've put #include <afxwin.h> in my program. However, the debugger still keep saying "undeclared identifier".
What happen??????
p.s.: again....it works in my previous program....i just copy the code to my new program....
|
|
|
|
|
i have two C files and want to add to my new project. I've used these files in MFC programming before and everything fines. However, this time when i compiled these files, i got the following error message:
"fatal error C1010: unexpected end of file while looking for precompiled header directive"
I didn't change anything.......then i tried to just compile the file (this lead me to create a new project).....i used the same directory...same location...nothing change.......and it works!!!!!!!!!!
Does anyone know what happeneD?
|
|
|
|
|
Your project is configured to use precompiled headers. Usually precompiled headers are included in the stdafx.h file. To solve your problem do one of the following:
(a) put the line
#include "stdafx.h"
in your .c files
(b)
go to FileView in the workspace window. Right-click on your .c file and select "Settings". Go to C/C++ page and select "Precompiled headers" category. Click on "Not using precompiled headers" and OK. YOu have to repeat this for all .c files.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi Tomasz,
Thanks for your quick response!!! You are superb!!!!!
Richard
|
|
|
|
|
Hi,,
I'm having problem with loading and saving (serializable) bmp files...
but i know how to do that in a dialog base application,,,,
I like to know how to do that in MDI...
Thanks
Ehsan
Ehsan Behboudi
|
|
|
|
|
Hi Ehsan, I have the same problem with my MDI application and i don't find out the bug.
Maybe you found it
Fred
|
|
|
|
|
I am using a listbox control to show a report on a record.
I can load the listbox the first time but i can not clear it for a second loading.
The new data just gets appended to the end of the list.
I am using the following to load the listbox
nIndex gets reset everytime the listbox is set.
m_choslist.InsertString(nIndex,msg);
|
|
|
|
|
call ResetContent() method on the listbox.
|
|
|
|
|
try yourlist.ResetContent();
gm
|
|
|
|
|
I have one problem with my MDI Application.
I don't manage to implement correctly OnOpenDocument in my view Class. Someone can give one examlpe ?
Thank for advance for your help
Fred.
|
|
|
|
|
class CData
{
// members
CData* pChildList;
}
CList<cstruct, cstruct&="">* pDataList, pTempList;
pTempList = pDataList->GetHead()->pChildList; //how to correct this line?
How can I make pTempList to point to pChildList?
|
|
|
|
|
Change 'class CData' to 'struct CData' or make pChildList a public member. Members of classes are private by default, while default struct members access is set to public.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
the class CData is public alright?. the compiler gave this error msg:
error C2582: 'operator =' function is unavailable
|
|
|
|
|
Change your variable declaration to:
CList* pDataList, pTempList;
to
CList* pDataList, *pTempList;
pTempList without asterisk declares object, not a pointer to an object.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|