|
I've only recently started playing with it, and like most such tools it has it's good points and it's bad. I find it anoying that with a very small ammount of use I've been baffled by two unrelated compiler faults and one, shall we say, infelicity of design in MFC which meant going all round the houses to do something which ought to be trivial (replacing one of the windows under a splitter).
There seems to be a certain ammount of too clever by half about MFC. Fancy techniques used where simple techniques would have been more flexible.
I find much of the documentation nearly useless, being formulaic in nature when it ought to be explanatory. It's also irritating that the class references are on CDROM and take forever to acccess (it also interferes with my listening to music while I hack).
On the other hand I find the IDE surprisingly useful. Compiler errrors tend to be vague but runtime errors are quite well handled. The debugger seems quite good (is there an "evaluate expression" anywhere?).
|
|
|
|
|
In this age of 40 gig drives, you'd be mad not to have the MSDN fully installed on your hard drive.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
So when was the old law: Files expand to fill the space available repealed?;)
Actually it's probably just parsimonius habbits (that, and having three separate opertating systems).
|
|
|
|
|
I want the MFC or sdk methods for obtaining the status of each processor such as load, queue length etc in a network.
arunkc
|
|
|
|
|
read HKEY_PERFORMANCE_DATA
|
|
|
|
|
I am new in Visual C++6.
I want to learn.
How I can do a profile like:
Profile
Last name:_______
First name:______
and an user can complete this form and his data to be stored in a data base.
Can you help me please?
I can change the fonts just for the first line?
Thank you!
|
|
|
|
|
It's great that you want to learn, and also ( for you ) great that you've found this site. Can I just ask a couple of questions ?
1/ If I asked you to do this task on a console line ( like a DOS window ), could you do it ? If I asked you to write a simple calculator, could you do that ? If not, then step one is learning some C++, then worry about the Windows world. Otherwise it's too much to take in at once and you're setting yourself up to be a bad Windows programmer.
2/ Assuming you know some C++ and want to move to Windows, you're probably talking a dialog application here, or a Form based view. Either way, what you're looking to do is not difficult - the first step involves creating the 'form', using the dialog editor to position your controls. Then you can use the drop down window in the Wizard bar to associate messages with functions, so you can recieve notification if a button is pressed, or text is typed into a edit box. You press Ctrl-W to get up the class wizard, where you can associate a control with a variable, either a string or number, or a control ( which means you use GetWindowText to get the contents of a text box ). NEVER use DDX with validation, i.e. never create an edit box and create an int or float and type in a minimum or maximum value. The DDX stuff jst blows, it is very annoying to end users. I alaways roll my own.
Database support is something I have little experience in, but from memory you create a project in the wizard with database support and associate it with a database, and you get a class that opens the file and provides methods for reading and writing values in and out. Or you can use serialisation or CFile to create your own if you don't need a relational database, but just a file with a list of details.
If I've lost you along the way, feel free to ask for more info, but also consider if you need to choose something simpler at this stage. Also, buy a book. Everyone here is very helpful, but there's no substitute for good references. I have a bookshelf full of programming books. Initially I thought along the lines of getting stuff for free online, why spend money, books are $100 each, etc. Now I love buying books, because I learn so much better from a book, and because I see it as an investment in myself. ( That may not be a wise investment, but I have a vested interest )
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Thank you very much for your explanations, I’m really interested in learning this programming language.
I started to learn last week and till now wasn’t very difficult.
|
|
|
|
|
*grin* It gets difficult, but that's the fun of it. If you learned an easy language you'd have something that
a. any monkey could do and
b. wasn't very powerful. A language is easy when it protects you from the details, which in turn limits your options.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
How hard is this to do?
Id like to be able to, for instance, drag a item (node) in the tree and move it to a new location in the tree. Oh, and a non-MFC solution is preferred.
thanks
-Jack Mott
jackm@scalablesoftware.com
|
|
|
|
|
Handle TVN_BEGINDRAG/TVN_BEGINRDRAG. KB article Q214814 has basic info about this.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
In my MDI application, I have a dialog box that the user can select at most 30 files(bitmaps).
then I store those file path names in a CStringArray(m_Array) in my Doc class.
there a button( on the toolbar) to click on, everytime I have to open the next image.
my problem is that I don't know how to open the next image in a new document.
I don't know what code to use.
the following is what i thought to start with.
void CTurboMechView::OnWindowNextimage()
{
// TODO: Add your command handler code here
CWinApp* pApp=AfxGetApp();
CMainFrame *ptr=(CMainFrame*)GetParent();
CTurboMechDoc* pDoc=(CTurboMechDoc*) ptr->GetActiveDocument();
pApp->OpenDocumentFile(m_Array.GetData()[1]);
}
any suggestions?
Ehsan Behboudi
|
|
|
|
|
You could open up another view and associate it with the current document. For this to work, you would also need to add a variable to the view. This variable would contain the index of the image the view is supposed to display.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I have a pretty difficult DLL problem to solve and I a little bit in the air right now.
I am developing a game engine with a "Resource Manager" which is in essence a linked list storing pointers to "Resource" classes. This setup deals with data that needs to be loaded/shared/released. All classes that load data are derived from "Resource" and on loading are registered with the global resource manager.
So that when the game requests e.g a texture a second time it gets the pointer to the already loaded texture object... Hope that is understandable..
This setup works quite well with the built in resource classes (Texture,Movie,Sound etc)
But now i allow extension DLLs which allow to add functionality to the game engine through plugin classes which are derived from "Object" and sent back to the game engine through a DLL exported function like extern "C" __declspec(dllexport) Object * CreateEngineObject( const char * classname )
This works ok too... But now i want to allow different Resource classes too in the extension DLL and here i get a crash when the resource manager tries to delete such a class (the destructor is never reached) There is one global resource manager in the engine dll ...
The engine is setup like this.
Game.exe // Small executable
Engine.DLL // All the engine classes, including ResourceManager,and Resource, those classes are also Exported via __declspec (dllexport)
Plugin1.dll the basic plugin for my tests. here i define a XMESH class derived from Resource which is alos __declspec(dllexport) exported....
The Runtime lib for all configs is of course "Multihreaded DLL"...
I don't have a clue what that could be anymore...
If anyone wants to see the code i can send a 18 MB Setup file which contains the whole project which is compilable via VC6 SP4 without anything additional ... out of the box..
Thanks in advance
Bernhard Glueck
|
|
|
|
|
Try
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
at beginning of every member function exported or every DLL function explicit exported.
Oscar L.
|
|
|
|
|
Hm this AFX_MANAGE_STATE.. isn't that a MFC Specifc Macro/Function ?
I am only using the native WIN32 API and DirectX 8.0 no MFC whatsoever...
Till next time.
|
|
|
|
|
Some new facts after long debugging sessions
After Removing the virtual in "virtual ~Resource"
the first bug is gone. the destructor is called, but only from the base class, however no crash occurs anymore
The problem itselt persists since now all the other virtual methods of the class fail...
Any ideas ?
|
|
|
|
|
Can you post the declaration, constructor & destructor for the Resource and XMESH classes?
|
|
|
|
|
Just a hunch, but apparently your resources involve GDI objects? Bitmaps? Are you sure your cleanup is not doing a DeleteObject call on something still selected into the DC? When you remove the virtual from the destructor, that chain is broken and the gdi object is not deleted, hence, no crash, just a leak. You wouldn't be the first person to be bit by that.
|
|
|
|
|
I have a TreeView that I would like to have popup menus appear in when people rightclick. How does one go about making popup menus like this?
-Jack Mott
jackm@scalablesoftware.com
|
|
|
|
|
Handle WM_CONTEXTMENU in the tree and call TrackPopupMenu or TrackPopupMenuEx.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
thanks, got it working!
-Jack Mott
jackm@scalablesoftware.com
|
|
|
|
|
Greetings,
I was wondering how I can convert a LOGFONT's lfHeight into a CHARFORMAT's yHeight?
I don't have access to the DC or a handle to the HDC.
Is there a conversion formula that I can use?
I know that you take 20*pointsize to get the height of the yHeight, but
I am not sure how to go from a logfont height to a yHeight.
ie: -48 is what in yHeight?
Thanks in advance!!!!
|
|
|
|
|
Howdy folks,
Please help me understand the concept of memory allocation in win32 dll's written in c++. I have found that when I use 'new' and 'delete' I often get access violations. I've done some reading, but am still confused. Blaszczak is silent on this issue. Brain ("Win32 System Services") says to use 'GlobalAlloc' in dlls, but doesn't really say why.
Here is an example that confuses me:
<br />
#include <windows.h><br />
#define _COMPILING_DCC237C0_6FEE_11d5_A91C_0050DAC6D85C_<br />
#include "JunkDll.h"<br />
<br />
HGLOBAL secret;
<br />
BOOL WINAPI main(HINSTANCE dllhandle, DWORD reason, LPVOID situation)<br />
{<br />
switch(reason)<br />
{<br />
case DLL_PROCESS_ATTACH :<br />
OutputDebugString("DLL_PROCESS_ATTACH\n");<br />
secret = GlobalAlloc(GPTR,100*sizeof(char));
strcpy((char*)secret,"The meaning of life is 42.\n");<br />
break;<br />
case DLL_PROCESS_DETACH:<br />
OutputDebugString("DLL_PROCESS_DETACH\n");
if(secret)<br />
GlobalFree(secret);<br />
break;<br />
}<br />
<br />
return TRUE;<br />
}<br />
<br />
char* getMeaningOfLife(char* buffer)<br />
{<br />
if(buffer != 0)<br />
strcpy(buffer,(char*)secret);<br />
return buffer;<br />
}<br />
<code> <br />
<br />
In the above example, if I define 'secret' as char* secret, and then use new and delete to allocate a buffer for it I get an acess violation. When I use GlobalAlloc as shown, it works. The help files say to use the heap function instead of GlobalAlloc, but I've never used them.<br />
<br />
I'm clearly missing the big picture on memory allocation for dlls. Brain talks about four different dll memory models, but I'm not grocking the concept.<br />
<br />
thanks<br />
<br />
Jim <br />
:confused:
|
|
|
|
|
It should be possible to call new in DllMain called with DLL_PROCESS_ATTACH parameter. Each MFC extension DLL has a call to new in its initialization code:
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("CORE.DLL Initializing!\n");
if (!AfxInitExtensionModule(CoreDLL, hInstance))
return 0;
new CDynLinkLibrary(CoreDLL);
}
Is DllMain the 'raw' entrypoint to your DLL, or is it called from _DllMainCRTStartup? Put the breakpoint in the DllMain and check the stack.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|