CocreateInstance in used to obtain only single Object of the class. Whilei CoGetClassObject is used to obtain the multiple Object of the same Class.
And CocreateInstance automatically call the ClassFactory(). you don't have to care for it.
Firstly, as already mentioned, CoCreateInstance uses the IClassFactory interface to create the object. Secondly, IClassFactory has other methods besides CreateInstance. Finally, the class factory is allowed to implement other interfaces.
I have a mfc application,based on CDialog,developed with vc6.0. Now I have make its *.chm help file. But when I press F1, it will always shows "Cannot find the ... *.HLP file". How can I change F1's default help file's name?
CWinApp has a member LPCTSTR m_pszHelpFilePath that is initialized before InitInstance() is called using a _tcsdup(), so you could free() the current m_pszHelpFilePath and _tcsdup() your own path in your InitInstance(). NOTE: during termination MFC will call free() on m_pszHelpFilePath assuming that it has been allocated using _tcsdup() so DO NOT set it to a static string.
-- modified at 3:30 Monday 17th September, 2007
If you are using VC6 then you will also need to override WinHelp either in theApp or in the mainFrame.
If you are using VC7 and above then forget the suggestion above and just call EnableHtmlHelp() in your WinApp constructor.
In fact your code was perfectly correct and that's the wey to do it (and you don't need to specify the second template argument because it has a default value). There are some articles here[^] about the STL, you'll probably find some usefull information.
In the CFrame cpp file (Frame.cpp) the error occurs in line 479 in the function "LRESULT CToolbar::OnCustomDraw(NMHDR* pNMHDR)" atg the line 479, ie:
BOOL HasText = (SendMessage(m_hWnd, TB_GETSTRING, (WPARAM) MAKEWPARAM (0,0), NULL) != -1);
Please advise me if you have a fix for this as soon as possible.
If anyone knows of the fix please email me directly at:
A C++ programming language novice, but striving to learn
I write differend data for then times with the same lengt to a file. I'm using one TEdit for this. Now I want to read the 4e data from this file and display it on a TEdit. How can I read data someware in the middle of a file.
i stumbled across an assertion in my program. When I want to show a dialog modally the dialog is shown correctly, but when I close the dialog I get an assert:
"Debug assertion failed! ... program ...wincore.cpp line 882" which is:
void CWnd::AssertValid() const
if (m_hWnd == NULL)
return; // null (unattached) windows are valid
// check for special wnd??? values
ASSERT(HWND_TOP == NULL); // same as desktop
if (m_hWnd == HWND_BOTTOM)
ASSERT(this == &CWnd::wndBottom);
else if (m_hWnd == HWND_TOPMOST)
ASSERT(this == &CWnd::wndTopMost);
else if (m_hWnd == HWND_NOTOPMOST)
ASSERT(this == &CWnd::wndNoTopMost);
// should be a normal window
ASSERT(::IsWindow(m_hWnd)); //<-- HERE
My code is farely simple:
the thing is: I call this from a member-class:
-MyDialogDlg my dialog
-SomeClass m_instanceOfClass; a memberclass of dialog.
a function of Someclass does the above code
I found some stuff from microsoft:
which didn't work for my case!
if I add
before the domodal nothing changes... so somehow my handle gets lost and I donnu what to do. can anybody help? maybe a simple link. i tried many links, although nothing worked for my case. I don't have any crazy stuff in my OnInit of the dialog nor do I have another dialog as model dialog
I would expect your ASSERT placed before the DoModal() to succeed, it just means that you are calling DoModal() from a CWnd derived class that has a valid Window, it has no bearing on the state of the dialog.
Are you calling DestroyWindow() somewhere in your Dialog class?
A easy to read time delay code in c++. What i can't understand is the role of clock() in the while loop where: clock()-start < delay. However i know the role of clock() in the program and i know the result of eliminating clock() in the while loop.But:
WHY CLOCK() - START ? clock() is as the same as the start and there is a type cast a line before , or i'm far far off the way ? Thanks
using namespace std;
cout << "Enter the delay time, in seconds: ";
cin >> secs;
clock_t delay = secs * CLOCKS_PER_SEC; // convert to clock ticks
cout << "starting\n";
clock_t start = clock();
while (clock()- start < delay ) // wait until time elapses
; // note the semicolon
cout << " done\n ";
return 0 ;
in a land with no bird, no spring. My first journey was a