|
Hi all,
I'm trying to create some exported functions in a DLL; these functions are called from my main application(the main application is a console application). When a user type 'X' and enter, I want launch my Doc/View usign a DLL.
Therefore I've to create a window supporting MFC doc/view architecture.
Problem is that I don't know how create this window????
Thks for you help,
HES
|
|
|
|
|
You could look at this http://www.codeproject.com/docview/docviewfromdll.asp
Cathy
|
|
|
|
|
Is there a simple method to draw anti-alias'ed circles or lines? For example, if I use the code:
pdc->Ellipse( ARect );
It draw an ellipse. Is there a simple method to define a pen type that will perform anti-aliasing for me?
Thanks in advance..
|
|
|
|
|
Use the new GDI+.
Search for GDI+ or GDI plus on CodeProject
Bys,
Rui Lopes
|
|
|
|
|
How to display different icons for a tree control item when it is expanded and colapsed?
Nitesh
|
|
|
|
|
You need to set an imagelist for the state: SetImageList( &il, TVSIL_STATE );
Beyond that, I'm not quite sure.
Joel Lucsy (jjlucsy@concentric.net)
|
|
|
|
|
This will work nicely (apart from the typos ):
void CWindowWithTreeCtrlInIt::OnTreeItemExpanding( NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
NMTREEVIEW* pNMTreeView = (NMTREEVIEW*)pNMHDR;
HTREEITEM hCurrent = pNMTreeView->itemNew.hItem;
BOOL bExpanded = TVIS_EXPANDED & m_wndTree.GetItemState(hCurrent, TVIS_EXPANDED);
if ( m_wndTree.ItemHasChildren(hCurrent) )
{
int nNewImage = bExpanded ? 0 : 1;
m_wndTree.SetItemImage(hCurrent, nImage, nImage);
}
}
Important bits: use TVN_ITEMEXPANDING, not TVN_ITEMEXPANDED; TVN_ITEMEXPANDED is only called the first time an item is expanded, or after TVE_COLLAPSERESET has been called on it.
|
|
|
|
|
Hello guru's. I've experienced pretty strange OS specific bug or something using SDI app with database support (ODBC), using microsoft access database. I wrote the program under Win2K and it worked perfectly untill I tested it under Win98. It seemed that neither m_pSet->Edit();m_pSet->Update();m_pSet->Delete() work as they are supposed to. It gives me the following error "Query is too complex". I dug really deep in the MFC documentation and did not found any solution. Any workarounds, or ideas of fixing that eror and making my program work?
PS: After the error it doesen't allow me to save changes - the error occurs when I edit some fields and i try to move to the next record (that's the way it saves modifications). It only let's me create new records and edit the key field.
|
|
|
|
|
Hmmm, it's been a while since I've done anything with ODBC in MFC, but I do remember a few things. First, MFC internally composes the SQL commands to do your inserts, updates, and deletes. Use the debugger to do some more digging into the MFC code, until you get to the part where the command is fully composed and ready to be executed. Then grab it, open up the MSQuery tool, and try to execute it there. In theory you should get the same error message, which would probably indicate a driver issue.
Search for "Query is too complex" in MSDN and you may get some feedback.
Good luck,
Alvaro
|
|
|
|
|
Thanks for the reply, I found a fix, and I do think that the error was because of some Win98 specific code. In the MSDN you can't find any information on that error - I found it in some header file - with no explanation on when it occures and why. The fix was simple - I changed the parameter in the recordset's class from snapshot to dynaset and it started working. Under W2K it works fine, but in win9x it works as a read-only method.
Cheers,
Deian
|
|
|
|
|
I've got a problem while debugging a programm. When exiting the program in debug mode, i've got memory leaks and i would like to analyse them in order to free objects which are not deleted. The code is a bit long and verifying all code would be impossible. Is there a tool I could use? or a method to applicate?
Thanx for your response and excuse me for the errors in text, i'm french...
|
|
|
|
|
* the easiest way to analyze memory leaks would be to use numegas bound's checker (http://www.microway.com.au/compuware/products.stm)but this is a product you have to buy.. but it should be very good and it reports both memory and resource leaks..
* there is the mfc way to detect memory leaks.. if you are very lucky you can double click on your memory leaks and then the devstudio shows you the code, where the memory got allocated (works sometimes for me.. but i actually dunno when, maybe the objects have to be derived from cobject or whatever)
another way (happened in one of my coworker's programs) the program crashed when the program got closed (it was an invalid timer - handle he wanted to delete) and the result was that noone of the destructors ever got called.. (it is pretty simple to check that case.. if you are using cstring.. and the dump tells you that there occured memory leaks in strcore.h then this is most likely)
if you want to know if one of your methods is leaking memory you can use the CMemoryState Class...
i hope one of your ideas can help you..
bernhard
excuse my bad english, i'm austrian...
""Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|
|
I've used BoundsChecker a few times over the past several years and it's helped me very little. Often times it's just plain annoying in the amount of "who cares" stuff it reports. Other times it's just too slow to wait for. Still, a lot of people seem to like it, especially for finding GDI resource leaks, so...
The MFC way is pretty reliable for memory leaks. All you need is this at the top of every CPP file, after the includes:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
... and you'll get the name of the source files in the memory dump at the end of the program. Then you can double click on the file and you'll see who's allocating memory that doesn't get freed. Concentrate on fixing the ones in your own code, of course.
Regards,
Alvaro
Oh, and please excuse my bad English, I'm American
|
|
|
|
|
If you find that the dumped memory leaks can't be located by double-clicking, you can also try a method described in MSDN. The article is called:
HOWTO: Use _crtBreakAlloc to Debug a Memory Allocation
Basically, you use the numbers shown next to the memory leak dumps, set a variable in the debugger, and the program will break when the leaking memory is allocated. Handy.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
i have to admit that i never used BoundsChecker.. cause.. i haven't felt a real urge to use it.. the mfc way worked pretty well for me all the time.. (the thingie you wrote with the double click.. i never found that out..)
but now my question: is there a handy way to find resource leaks in a mfc program ?
(seems to be an advantage of using boundschecker..)
have a good one
bernhard
oh.. and yaya.. you know the game..
""Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|
|
thank you a lot for your ideas.. I found out a leak thanks to you, but there are some others I can't find bexause the title of the file is not complete. I can't see why... probably a bug with the debugger...lol
|
|
|
|
|
have you tried derek water's tip above.. maybe this could help you..
bernhard
""Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|
|
Resource leaks? What are those?
For those I'm pretty sure you need a tool like BoundsChecker or Purify.
If you use MFC, the CGdiObject-derived and CDC-derived classes, like CFont, CPaintDC, CPen, and CBrush clean themselves up via their destructors. This reduces your chances of having resource leaks. Still, if I had a GDI intensive app, I'd consider getting a tool to ensure it cleaned itself up properly.
Regards,
Alvaro
|
|
|
|
|
Though I go along with the others, specially the likes of bounds checker, I tend to build in a bit of quicky debugging. Afteral, you get told you have memory leaks so all you need to know is 'can my code exit without passing the cleanup' and 'does my clean up clean them all'.
Typically a node creation/deletion will follow the same few paths. If none of your memory is freed then that will be pretty obvious to fix, if only some are not freed then it is likely to be a program path problem
So, I count them in and count them out in the debug. Then print the debug value.
For example, lets say I have something like this below that is part of a xml scema parser. I have global counters,
#ifdef TRACE_TREE_MEMLEAKS
long m_Count_Tree_Leaks;
#endif
const int IN_SCHEMA_TREE = 1;
const int IN_XML_TREE = 0;
void SchemaTree::StoreSingleLineRootItem(LPCTSTR Line, int WhichTree)
#ifdef TRACE_TREE_MEMLEAKS
//include at every insert point. I had 5 ways into my two trees.
++m_Count_Tree_Leaks;
#endif
ElementTypeTree* ETType = new ElementTypeTree;
CString sLine, lSearchFor;
//fill item details
if(WhichTree == IN_SCHEMA_TREE)
m_DataTree.InsertDataItem(ETType,NULL);
else
m_XMLTree.InsertDataItem(ETType,NULL);
}
The multiline element type can create none or many subelements, so I would have these counted in too.
void SchemaTree::StoreMultiLineRootItem(int TreeLevel, LPCTSTR ItemString)
{
static CString RootItemName;
ElementTypeTree* ETType;
SubElements* subType;
CString sLine, lString, lSearchFor;
#ifdef TRACE_TREE_MEMLEAKS
//include at every insert point. I had 5 ways into my two trees.
++m_Count_Tree_Leaks;
++m_Count_Tree_Sub_Leaks;
#endif
ETType = new ...
subType = new ...
Then use
#ifdef TRACE_TREE_MEMLEAKS
--m_Count_Tree_Leaks;
--m_Count_Tree_Sub_Leaks;
#endif
at each point there are deleted.
I put this sort of stuff in from the beginning, it easy then, your not likely to miss one.
printing the debug counters values before exit (each possible exit) will tell you you have memory leaks, and which of your structures in is doing it.
We do it for the joy of seeing the users struggle.
|
|
|
|
|
This query is related to using an ActiveX control in VC++(Volo view Express of
AutoDesk AutoCad,free download availabe at
http://www3.autodesk.com. This is an ActiveX control
to view drawing files).
I used Volo View to view a drawing file on different computers.The volo view
always displays the same part of the drawing irrespective of the resolution of the
computers.
I have created a Dialog based application in VC++ and
inserted the Volo view Express into it(Through the Insert ActiveX control command).
As usual a wrapper class is created and inserted into project along with various
helper functions.I've also mapped the File Open menu to allow the user to select a drawing file.
If I now open the same drawing file which I had tested on different computers,the
drawing displayed is not similar to the one shown by volo view.The VC++ application displays
part of the drawing not shown by Volo. I want to know why the
drawing file is displayed differently when it is viewed through Volo view embedded in VC++
application.More over the VC++ application displays different parts of the drawing on different
computers.
How can I make the VC++ application to always display the same part of drawing irrespective
of the application running on different computers.
Any inputs in this regard would be of great help..
Thanks Ravi
|
|
|
|
|
Are the resolutions of the displays different. And do you size your drawing taking this into account.
10 pixels on 800x600 is bigger than on 1024x{whatsit}
We do it for the joy of seeing the users struggle.
|
|
|
|
|
Hi all,
How can i add Hot spot to my .HLP ?
Please write simple example ...
Thanks ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Help files are built from .RTF files. In the RTF file, you can create a link (or hot spot) from one topic to another using this syntax:
{\uldb Hot spot topic text}{\v HID_OF_TOPIC_TO_SHOW}
Various flags can be used as follows:
\uldb - jumps to this topic from the current topic
\ul - Link to a pop-up topic
Roger Allen
Sonork 100.10016
|
|
|
|
|
Hi Allen !
Can i use of it in my .HLP file ?
Because my help file is in .HLP mode (Context help)
and my help not .CHM mode !
So, can i use of it in .HLP ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Your applications .hlp file is compiled when your project is compiled (if any of the files have changed). If you look in the Hlp sub directory of your project, you should see some .rtf files call AfxPrint.rtf and AfxCore.rtf. These are the default help topic for a typical application. You need to edit one of these. I normaly do this in the VC editor, but when I open the file, I change the Open as option in the file open dialog to Text so it doesn't hide all the .rtf format strings.
If you open one of these files, you can add a new topic with a hot spot to a different topic in it. You will then need to re-compiler yout .hlp file and make sure its in the same directory as your applications .exe file.
You can compile the .hlp file manually yourself, by using the tool MS V6->MS VC tools->Help workshop You should then browse to your projects .hpj file in the Hlp directory. You can then access the options to compile the .hlp file when you do changes to the .rtf files. Once compiled copy the generated .hlp file to the release/debug directory and test it with your application.
Roger Allen
Sonork 100.10016
|
|
|
|