|
in your DLLMain
myBitmap = LoadBitmap( hInstance , MAKEINTRESOURCE( IDB_MY_BITMAP);
and in your control class, or wherever you need it, do an
extern HBITMAP myBitmap;
There may be other ways.
|
|
|
|
|
Hello,
I've just read an article here saying how to use the IPStorage COM class to enumerate the data in windows' protected storage.
http://www.codeproject.com/w2k/pseenuma.asp
First of all, (please corret me if I'm wrong) must a Coclass be created before used? plus, must it be first declared in a header file? If yes, how about the method suggested in the example - create a class using a DLL function and then access its members directly without being declared?
I've done too much Delphi programming before moving to VC++ so please excuse me if I'm talking nonsense here...
I would be glad if anyone can give me an example for doing the enumeration.
|
|
|
|
|
Hi,
I'm getting scrolling problem in WTL Scrollview window. I've derived a class from CScrollWindowImpl class and did some drawing. If I want to scroll the window, here the problem comes. In MFC OnInitialUpdate function there, is it any equivalent function available in WTL. Please can any one help me out?
If I want to scroll dynamically by calculating the view size and set the scroll ranges, what are all the steps I've to follow?
Advance thanx
Regards,
Ramesh.
|
|
|
|
|
Should an MFC ActiveX control be designed to retun SCODES or HRESULTS to indicate status of a method? I'm not talking about critical problems, just to indicate failure.
From my understanding they should fire an error (in a custom method, throw in a property setting method) if it's a critical problem, but what about those little day to day things like an invalid parameter or to indicate the status of a procedure such as updating a database record?
I tried returning a VARIANT_BOOL, but it always evaluates to TRUE at the container end, in both an mfc dialog app and a vb test app, even when explictly set to VARIANT_FALSE and comparing the return agains VARIANT_FALSE (making no assumptions about its actual value).
I've pored over approximately 200 documents/web pages mostly on the net and in the MSDN documentation and they are completely conflicting on this issue. Generally they have completely different standpoints depending upon what era they come from.
Some say SCODES are a holdout from the times of the proverbial ancients (1995?), but VC7 Add method wizard only lists SCODE as a return type, not HRESULT.
Some docs say they are the same and interchangeable, others say SCODES are 16 bits and HRESULTS 32, other docs say SCODES are 64 bit and HRESULT 32!!!!
Some docments say that all ActiveX objects should return only HRESULTS and some say SCODES only.
If they are the same why are there functions to convert and SCODE into an HRESULT in the platform sdk etc etc. It goes on, but does anyone know the definitive answer?
|
|
|
|
|
SCODE and HRESULT are different on 16(bit) platforms,
and they are the same on 32(bit) platforms
soptest
|
|
|
|
|
Like others said, SCODE is for 16/32 legacy systems.
New code should use HRESULT.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hmmm...so why does the VC7 Add method wizard not supply HRESULT on the list of possible return types but rather SCODE?
|
|
|
|
|
for 16(bit) compatibility
soptest
|
|
|
|
|
When I call IGlobalInterfaceTable::RevokeInterfaceFromGlobal from a FTM object created in the main STA for an sub-object that was created from a MTA thread, a deadlock seems to occurs while I am revoking the interface (from the STA).
Here are the steps:
1) Create an object (that aggregate the FTM) in the main STA
2) Call a function on that object from a MTA thread and from that function create an sub-object (that does uses the FTM) in the STA but register it in the GIT from the MTA.
3) Destroy the object from the STA. When revoking the cookie for the sub-object a deadlock seems to occurs.
Any idea for a solution?
Should an object always be registered from it own apartment?
Does there is some restrictions when using the GIT for FTM objects?
Is my problem caused by the MTA not responding at that time?
In fact, if I force the creation of the sub-object from the STA instead of waiting when I need it (which will occurs from a call made from a MTA in my case), no deadlock will occurs...
I haven't found much "advanced" informations on the GIT and the MSDN documentation is not clear enough about potential problems, limitations and restrictions. Any suggestions?
Philippe Mori
|
|
|
|
|
May be this will help you to resolve this problem:
The apartment that calls RegisterInterfaceInGlobal method must remain alive until the corresponding call to RevokeInterfaceFromGlobal.
soptest
|
|
|
|
|
I have change how objects are destroyed and it seems to works fine...
Now I start by destroying sub-object in FinalRelease and then releasing the FTM for that object. In my initial implementation (which was not working in some cases), the FTM was destroyed first (in FinalRelease) but sub-objects were destroyed only by the destructor (automatic objects are used).
Also I now aggregate the FTM on demand for each of those object.
Philippe Mori
|
|
|
|
|
[earlier posted in the VC++ forum with zero answers ]
Is it S_OK to use W2A to convert from a BSTR to a const char * ?
Means, can I do this?
const char * p = W2A(bstrBlah);
Nish
p.s. I am doing this now and without any problem. But I just wanna know if it is safe!
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Well,
I have been using the same for some time now with
out any probs.
Anyway, Just be careful that the BSTRs can contain
null('\0') characters in between and this macro will
not take that into account.
|
|
|
|
|
Prem Kumar wrote:
I have been using the same for some time now with
out any probs
Whew! Good to hear that!
Prem Kumar wrote:
Anyway, Just be careful that the BSTRs can contain
null('\0') characters in between and this macro will
not take that into account.
Thanks for that.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
W2A uses stack, so size of BSTR is limited.
Use this code:
inline char* ConvertBSTRToString(BSTR pSrc)
{
if(!pSrc) return NULL;
DWORD cb,cwch = ::SysStringLen(pSrc);
char *szOut = NULL;
if(cb = ::WideCharToMultiByte(CP_ACP, 0, pSrc, cwch + 1, NULL, 0, 0, 0))
{
szOut = new char[cb];
if(szOut)
{
szOut[cb - 1] = '\0';
if(!::WideCharToMultiByte(CP_ACP, 0, pSrc, cwch + 1, szOut, cb, 0, 0))
{
delete []szOut;
szOut = NULL;
}
}
}
return szOut;
};
soptest
|
|
|
|
|
Wow! Thanks. That's a lot of code for a conversion.
Nish
p.s. Right now I won't have to use this, as I know the size of the BSTRs and they are rather small
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I created an ATL DLL server project and inserted a new ATL object as a simple one, named Inter. Next, i added a new BSTR-type property named Str.
I wrote:
STDMETHODIMP CInter::get_Str(BSTR *pVal)
{
_bstr_t x(*pVal, FALSE);
m_str=x.copy();
return S_OK;
}
This code links perfectly on debug versions but generates this error:
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
on release versions.
Do you know how to handle it?
rechi
|
|
|
|
|
Taken from "INFO: Active Template Library (ATL) 2.0 Readme File" in MSDN, hope it helps...
<br />
_ATL_MIN_CRT and Link Error "unresolved external symbol _main"<br />
--------------------------------------------------------------<br />
<br />
When you build a Release version of an ATL project, you can get the<br />
following link error:<br />
<br />
LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main<br />
<br />
This error occurs if you are using CRT functions that require CRT startup<br />
code. The Release configurations define _ATL_MIN_CRT, which excludes CRT<br />
startup code from your EXE or DLL. To avoid this error, do one of the<br />
following:<br />
<br />
- Remove _ATL_MIN_CRT from the list of preprocessor defines to allow CRT<br />
startup code to be included. On the Build menu, click Settings. Hold<br />
the ctrl key while selecting all Release configurations. On the C/C++<br />
tab, choose the General category, then remove _ATL_MIN_CRT from the<br />
preprocessor definitions edit box.<br />
<br />
- If possible, remove calls to CRT functions that require CRT startup<br />
code. Instead, use their Win32 equivalents. For example, use lstrcmp()<br />
instead of strcmp(). Known functions that require CRT startup code are<br />
some of the string and floating point functions.<br />
Dylan Kenneally
London, UK
|
|
|
|
|
I've an OLE automated project to convert MS Excel document to PDf file. I use the
void _Workbook::PrintOut(const VARIANT& From,
const VARIANT& To,
const VARIANT& Copies,
const VARIANT& Preview,
const VARIANT& ActivePrinter,
const VARIANT& PrintToFile,
const VARIANT& Collate,
const VARIANT& PrToFileName)
for printing into Acrobat PDFWriter. It runs, but the problem is that Acrobat appears. How can i do to avoid this, please ?
Thanks.
Aziz Rajim.
|
|
|
|
|
I think if you use Adobe PDFWriter, then Acrobat is gonna popup. Alternatively you could consider using LibPDF or other pdf writing libraries to write your pdf file?
sonork: 100:18407
|
|
|
|
|
I want to get HTML code from MSHTML Document.But I can't.
public Samples
//pDoc,IHTMLDocument2
IHTMLElement *elem;
BSTR* bstrVal;
pDoc->get_body(&elem);
elem->get_innerHTML(&bstrVal);
.....
But This Code can't get or ,etc.
For Example,
....
...
....
Please tell me how to get ALL HTML code.
|
|
|
|
|
try this:
IHTMLElementCollection *pEnum;
pDoc->get_all(&pEnum);
if(pEnum)
{
::IHTMLElement *pelem;
try
{
pelem = pEnum->item((long)0);
}catch(...){};
if(pelem)
{
BSTR wsHTML;
pelem->get_outerHTML(&wsHTML);
}
}
soptest
|
|
|
|
|
I want to put HTML code too.
I modified a little and I could get HTML code ,Thank you.
and,
pelem->put_outerHTML(&wsHTML);
But An error occurs,and I couldn't put HTML code.
But I tried use insertAdjacentHTML method and I could insert HTML code.
Please tell me to how to put HTML code.
|
|
|
|
|
i try to embed and automate a word document and an excel
worksheet with mfc and office 2000 using articles
howto (Q184663 for excel and Q238611 for word)
Working well for excel ,not working for word (com error
not registred).
word is well registred in my type librairies with the good UUID
|
|
|
|
|
Did you use the Application independant ProgID ???
--> 'Word.Application'
Dont use any predefined id's use 'CLSIDFromProgID' to get the clsid.
|
|
|
|