|
Thanks a lot for Dave and Aisha.
I checked the returned value of HRESULT, which is -2147023486, and the error lookup program explains it as "Class already exists".
I am not sure what does that mean? I think I have released all the resoures. Is there any way to check what class does the error refer to?
By the way, can you explain a little of "releasing the referrence count using Release() method after the first time creation of your component using CoCreateInstance". How normally it is done? (it is my first time to do this COM related programming so I am not very sure of these things. That's why I use the walkall demo source a lot).
Thanks a lot.
PS: I belive the parameters to CoCreateInstance is correct. It is called like:
if (FAILED(hr = CoCreateInstance( CLSID_HTMLDocument, NULL,
CLSCTX_INPROC_SERVER, IID_IHTMLDocument2,
(LPVOID*)&g_pApp->m_pMSHTML )))
{
// here I can watch the hr's value.
goto Error;
}
|
|
|
|
|
I think you are probably not releasing your pointer reference. The call to CoCreateInstance() is correct.
When you first time call CoCreateInstance(), do with your g_pApp->m_pMSHTML pointer whatever you want and then when you are finished, simply do the following:
g_pApp->m_pMSHTML->Release();
make sure you have been released your pointer before you second time call your CoCreateInstance().
all the best!
@!$h@
|
|
|
|
|
I think you are probably not releasing your pointer reference. The call to CoCreateInstance() is correct.
When you first time call CoCreateInstance(), do with your g_pApp->m_pMSHTML pointer whatever you want and then when you are finished, simply do the following:
g_pApp->m_pMSHTML->Release();<br />
g_pApp->m_pMSHTML = NULL;<br />
make sure you have been released your pointer before you second time call your CoCreateInstance().
all the best!
@!$h@
|
|
|
|
|
Thanks a lot.
I found out that the reference count is not set to 0 before release.
(I doubt that the "release" will not return any error if the count is not 0).
From the debug window, I found the reference count is 1 before release. I tracked it step by step and found out the wrong place.
Thanks a lot for Aisha and Dave and all the people's kind help.
Have a nice day.
|
|
|
|
|
Kevein wrote:
Thanks a lot for Aisha
you are most welcome
Kevein wrote:
Have a nice day.
thanks, you too
@!$h@
|
|
|
|
|
It's been a long day and I'm now officially brain dead!
I've got an MFC Extension dll as a project in a solution. The extension dll calls several WinInet functions. I have included wininet.h in the stdafx.h file and linked to wininet.lib in the ../vc7/platformSDK/lib folder.
I'm getting LNK2019: Unresolved external symbol on my first call to the library... InternetGetConnectedState(...)
What have I forgotten to do?
Paul Lyons, CCPL Certified Code Project Lurker What a long, strange trip it's been - Robert Hunter
|
|
|
|
|
do you get the same error with other wininet functions, like say InternetOpen, or only with that function?
.... If its only with InternetGetConnectedState then try InternetGetConnectedStateEx... it might have been deprecated without warning in VC7 or somethin
|
|
|
|
|
Hi all,
I have a problem. I have written a program that uses a commercial activeX component. I need to distribute this program on other machines and in order to do that I need to also distribute the commercial .ocx file and register it.
This is no problem.
What I want to do is for my program to send a popup error message if the ocx file is not installed/registered with windows.
Currently it just crashes.
thanks
---
|
|
|
|
|
why not do a cocreateinstance and catch any errors/exceptions
Bryce
|
|
|
|
|
It crashes at
TRY {<br />
CModelessMain::Create(...)<br />
}<br />
CATCH_ALL<br />
{<br />
<t>...<br />
}<br />
END_CATCH_ALL<br />
Never tried CoCreateInstance - will give it a go
---
|
|
|
|
|
Create() method returns a BOOL , If you have specified appropriate parameters, the method does not crash. So better check for your parameters. In case the control is not registered, Create returns a FALSE . In this case, give user the message that control is not registered or installed.
@!$h@
|
|
|
|
|
bryce wrote:
why not do a cocreateinstance and catch any errors/exceptions
Ok How do I do that????
---
|
|
|
|
|
You can create an object of your control using COM techniques:
HRESULT hr = CoCreateInstance(<br />
CLSID_YourControlID, <br />
NULL, <br />
CLSCTX_INPROC_SERVER, <br />
IID_IYourControlInterface, <br />
(void**)&pInterfaceName);<br />
<br />
if (FAILED(hr)) {<br />
MessageBox(<br />
NULL, "Failed to create instance of " "Your Control", "Error!", MB_ICONERROR);<br />
}
For that you need to know the basics of COM. MSDN is a good source of learning so read about the basics of COM.
All the best!!
@!$h@
|
|
|
|
|
I had found on MSDN its said that, SetDIBitsToDevice can be pass JPEG image as source image.
Anyone, Could you show me the code to show JPEG image by using SetDIBitsToDevice .
|
|
|
|
|
I am seeing some strange running behavior, when building a library using C++ <iostream> and some other library using C <stdio.h>. The building results in some of the stdio.h symbols being defined twice. And the running behavior is that file reads with fstream.getline end up sucking in the newline character, which it is not suppose to do.
At this point I am thinking that the symbols for the old C libraries are getting used instead of the newer C++ versions, and I am betting that they are incompatible.
Both libraries are outside my control. I am integrating them into an application. Otherwise I would just update the headers to use the C++ versions. I have a vague recollection that there was a header file or some #define to make the two play together nicely, but can't seem to find it. Does anyone know of such a header, #define, or some other flag or trick to make these libraries work together?
Thanks.
Dave Hickerson
david.a.hickerson@boeing.com
|
|
|
|
|
I found that one of the libraries had set Unix file reading format. This is caused carriage returns to end up in the fstream.getline() read. How annoying.
I did find a MS VC++ 6.0 error with getline() in the string header referenced at Microsoft: http://support.microsoft.com/default.aspx?scid=kb;en-us;240015 . This one is a manual entry to the <string> header file. If you are using MS VC++ .NET, its fixed in that version according to the bug report.
Dave
Dave Hickerson
david.a.hickerson@boeing.com
|
|
|
|
|
Hi,
How do you update the main frame if the user presses an accelerator key and a dialog box is active? For example, given F1 is "Help" and a dialog box is active, how do you update main frame so that it can handle "F1" accelerator accordingly?
I have tried overriding PreTranslateMessage() and processing LoadAccelerators() using main frame's handle.
::TranslateAccelerator(AfxGetMainWnd()->GetSafeHandle(), hAccelerator, pMsg);
The solution above does solve this problem, but it creates a new problem. No other key works in the dialog box such as "paste" or "copy."
I want to update main frame upon an accelerator key even when a dialog box is active.
Thanks,
Kuphryn
|
|
|
|
|
I'm using a MFC Edit Control to log information for my app. Unfortunately, I can't get it to automatically scroll to the bottom whenever I add more text! I've tried LineScroll, but that doesn't do anything, no matter what parameters I use.
|
|
|
|
|
CEdit edit_control;
edit_control.SetSel(0,-1,FALSE); This will force the edit control to scroll the last line into view whenever you add more text.
You need to be a little careful in how you use this. Each time you do this, you'll scroll the control down, even if the user was trying to scroll the control himself. A simple solution is to have a check box off to the side, perhaps labelled "update". If the update box is checked, you scroll the last line into place. If it's not checked, assume that the user is looking at the data, and doesn't want the scrolling to happen. You can still update the text in the edit control in this case, although you may need to make sure you save the user's selection (GetSel() and SetSel()) and restore it after you update the text.
Software Zen: delete this;
|
|
|
|
|
It doesn't work
You can see my app here, if seeing the edit control in action might help: http://www.lancersreactor.com/t/download/download.asp?id=123
|
|
|
|
|
Which product is the better of the two?
Jon Sagara
You know the world is off tilt, when the best rapper is a white guy, the best golfer is a black guy, the tallest basketball player is Chinese, and Germany doesn't want to go to war.
-- Charles Barkley
|
|
|
|
|
I am currently using BoundsChecker, though I have used Purify in the past (about 4 years ago on VC++ and SGI). Both are good products, though I think BoundsChecker is easier to use. If you are getting this for a company and getting multiply copies, I would think about getting one of each. Each has their strengths, one may find something the other may miss.
Dave Hickerson
david.a.hickerson@boeing.com
|
|
|
|
|
|
I tried both of them recently and BoundsChecker worked much better for me. I have a project with 120,000 lines of code and Purify generally was not able to operate correctly. It generally stops execution on some API calls, which are valid calls. Even if it works fine, the resource and error leak analysis of Purify was not as good as BoundsCheckers analysis (it was not even close to it).
Currently I am using BoundsChecker and it works like a charm. It has more features than Purify and its integration to Visual C++ is much better.
You can request a trial for both of the products. Just try and see both of them...
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
I created a new class based on CButton -- CMyButton. I add a message notification handler in CMyButton.cpp for =BN_CLICKED to change an protected member variable of CMyButton.
void CMyButton::OnClicked()
{
m_nState += 1;
}
Using resource editor, I put an instance of CMyButton to my dialog template. I want my dialog to handle the BN_CLICKED also, do some other stuff.
void CMyDlg::OnMyBtn()
{
MessageBox("Button pressed.");
}
The problem is: CMyDlg::OnMyBtn is never called, even though I add the style of "Notify" to the button instance in the resource editor. What am I missing here?
TIA!
|
|
|
|