|
in general, only MFC clients can use MFC extension DLLs.
if you want to export functions to non-MFC clients, you will need to use plain C interfaces on all of your exported functions.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I inserted my this project to regular dll by the wizard.
I have a dialog class and I writed export global function so:
/********************************************************/
extern "C" __declspec(dllexport) int func()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
MyDialog dlg;
dlg.DoModal();
return dlg.num;
}
/********************************************************/
But when I test it with client program it dont show me the dialog.
It is only return me the return value.
WHY ???
Gil
|
|
|
|
|
Have you debugged into the DLL and found which line it is failing on. It's probably failing somewhere in the InitDialog code. You'll need to debug it to find out what the problem is.
However, I recommend that you try and implement it as a COM object, Delphi should have no problem with a COM object.
Michael
|
|
|
|
|
May be this is an easy question, however i did not find so far an easy answer.
How can I hide the menu in an application
|
|
|
|
|
Use SetMenu() with a NULL handle
AfxGetMainWindow()->SetMenu( NULL );
|
|
|
|
|
Hi,
I've added CMemDC class to my project, and it has a memory
leak somewhere that I can't locate.
I need 2 DC's that stay in memory for the life of the
application, however, I'd rather not have them constantly
created inside the OnPaint() function, since I have some
intensive calculations done to them.
Can I get some suggestions on correct methods of initializing
my CMemDC. My app is Dialog based, and I've been using
different methods to initialize them inside my OnInitDialog()
function.
Also, is it bad form to use the 'new' operator on CMemDC,
considering I didn't see it defined within the class?
Best Regards,
-t
|
|
|
|
|
If you could get the dialog to use a window class that you register yourself that had the CS_OWNDC style bit set, you could move the CDC::CreateCompatibleDC stuff out of OnPaint. In a standard MFC dialog based app, DoModal uses CreateDialogIndirect to create the dialog - if you override DoModal and get it to use a DLGTEMPLATEEX structure I think you could supply your own window class.
I use this CS_OWNDC trick in my Gribble2 article, but haven't tried it for a dialog.
|
|
|
|
|
I'm unclear on the necessity of having to register the class
with CS_OWNDC.
Can't I initalize a couple CDC's, keep them in memory,
and blt them to the screenDC (aka my Dialog Client area),
but then do whatever calculations I need when they need to be
updated.
I apologize ahead of time if I missed your explaination in your
articles.
Much Thx,
t²
|
|
|
|
|
I guess you can, but you mentioned the CMemDC sample which I saw doing a lot of this stuff in OnPaint, and, in the heady rush of feeling I actually had something to say...
My feeling was that you we're looking to optimize as well as reduce code in OnPaint, and a window with its own DC can do both, although the real bottlneck with blitting seems to be the overall size of the bounding rectangle of the clipping region.
But I think your right, the CS_OWNDC is not a prerequisite for eliminating the CreateCompatibleDC code in OnPaint - does 'feel' a bit safer, though.
later
Oh - and I'm assuming that the size of your dialog doesn't change - that would be a good reason to leave the mem dc setup in OnPaint.
Um - what is it exactly you are going to draw on the mem dc?
|
|
|
|
|
My project will be an extension of a prewritten custom
ATA HardDrive debugger. Object to display errors at different
block locations on the platter. So there could be potentially
20000x20000 locations (roughly) that I need to map.
I've been experimenting on a much smaller scale, but have
run into a memory leak. I'm not MFC trained (nor even Comp. Sci
trained), so my methodologies could be all out of wack.
Dealing with such a large "map", I've been looking for a way
to do a one time calculation for a full summary view of the map,
then calculate smaller chunks when I need a zoomed view.
Very vague explaination, I know...sorry.
And yes my Dialog doesn't change (for now it's 800x600).
-t²
|
|
|
|
|
Ah, well, lets go back to the leak then.
If you're using a typical MFC dialog based app, make a note of the allocation number of the leak from the object dump.
Start the program again with F10. Open the watch window, and enter this variable name:
{,,msvcrtd.dll}*__p__crtBreakAlloc()
If it shows a -1, you're in luck. Enter the value of the allocation that leaked, and the program will break when its allocated - and you can just hop up the call stack to see whats leaking.
Basically, if you use new you need to use delete to free the memory allocated - but sometimes its tricky to determine where the leak occurred.
Note that sometimes {,,msvcrtd.dll}*__p__crtBreakAlloc() doesn't show up - _ctrBreakAlloc may work.
The allocation number of the dump is the one in curly braces in an output like this:
E:\Develop(Tim)\OPCSim1\OPCSim1.cpp(51) : {64} normal block at 0x00300030, 1 bytes long.
Data: < > CD
|
|
|
|
|
Excuse my ignorance, how can I get the allocation number,
and where do I input it?
I did look at "{,,msvcrtd.dll}*__p__crtBreakAlloc()", and
it did come up -1.
On a separate note, if I declare a GDIObject, say...
CBrush testBrush;
Should I explicitly delete it when I'm done with the object?
(Given that I did save the original CBrush and restored it
to the CDC when I was finished. More specifically, I'm using
SaveDC and RestoreDC)
If I don't delete the object, do GDIObjects have their own "safe"
destructors?
Regards,
-t²
|
|
|
|
|
Oh - ok - I make a distiction between resource leaks and memory leaks - perhaps what you have is a resource leak.
If you are working with classes derived from CGdiObject (like CBrush, CPen) the ~CGdiObject destructor should free the resource for you - so when the testBrush goes out of scope, or its containing class is destroyed, you should be ok. MFC will ASSERT in debug mode if you try to call CreateBrush or CreatePen twice without calling DeleteObject.
If you are working with handles returned from say, a call to ::CreateBrushIndirect (not using CBrush) you must be careful to destroy the object (after deselecting it from the DC).
What is telling you that you have the leak? - I thought it was a dump provided by the debug C runtime allocation routines - in which case the allocation number would be the one in curly braces.
Say - since this thread is getting kind of buried now, why don't you post a bit of code (showing your SaveDC and RestoreDC calls and stuff that you are doing in between) in a new thread - rem - use <pre> and </pre> to surround your code - if its a resource leak, it may not be obvious - I seem to recall some subtle gotchas that have appeared in these posts - but I bet you'll get a helpful answer real quick.
|
|
|
|
|
I placed a followup on our discussion in a new thread...
"CDC Resource/Memor Leaks... (continued)..."
-t²
|
|
|
|
|
I have several static controls that are mapped to CString member variables.. I have a clear function that sets all the CString member variables to "".. When I execute "OnClear" all my edit boxes and combo boxes clear but my static controls do not clear unless I minimize then maximize the dialog box. Any ideas on how I can repaint the dialog box to reflect the new values.. I do a UpdateData(FALSE) at the end of my clear function.
Thanks,
Rob
|
|
|
|
|
Call RedrawWindow() on your dialog to make it repaint.
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
Hello, the codegurus around the world.;)
Try to SetWindowText() to update the text for Static control.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I have tried both methods and neither are working. It may be because the background of my dialog is a bitmap. I have opened spy++ and am trying to find the function that they use to redraw the whole dialog when I go from minimized to maximize.. The RedrawWindow() may be the ticket, as of right now I have only tried RedrawWindow() with out any parameters. I’ll play around with it to see if I can get it to work.
Thank you both for your responses.
Rob
|
|
|
|
|
Never mind the last reply.. RedrawWindow() works fine.. I was calling UpdateData(FALSE); after the RedrawWindow()..
Everything is working great!!
Thanks!
Rob
|
|
|
|
|
Please, check your DoDataExchange() function,
It may look like this
void CDlgStatic::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgStatic)
DDX_Text(pDX, IDC_STATIC_1, m_Static);
...........
//}}AFX_DATA_MAP
}
In general, there is no need to repaint the control.
|
|
|
|
|
My DoDataExchange() function does look exactly like you posted.. Should it look different?
The repaint is working fine for me..
Thanks,
Rob
|
|
|
|
|
What ure doing should work, i cant see why it don't! Anyway try doing what folows:
CRect clientRect;
GetClientRect(clientRect);
InvalidateRect(clientRect);
that should do it!
Good luck!
Papa Charchabil.
|
|
|
|
|
Hi,
I am looking for the font responsible
to display the tree symbols in the
upper right corner of a window.
On my computer, these symbols are
replaced by 0, 1 and r.
Any suggestions ?
Claude
|
|
|
|
|
|
Hello,
Can somebody give me the advantages/disadvantages of using VB to develop COM component instead of using ATL to do the same. Any links to such comparisons are also appreciated.
Ganesh.M.Ramaswamy
|
|
|
|