Click here to Skip to main content
15,899,026 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to make use of SDI features print etc... in Dialog based application Pin
msr_codeproject25-Dec-07 21:45
msr_codeproject25-Dec-07 21:45 
GeneralRAII (Resource Acquisition Is Initialization) pattern limitations Pin
George_George25-Dec-07 20:55
George_George25-Dec-07 20:55 
GeneralRe: RAII (Resource Acquisition Is Initialization) pattern limitations Pin
peterchen26-Dec-07 0:40
peterchen26-Dec-07 0:40 
GeneralRe: RAII (Resource Acquisition Is Initialization) pattern limitations Pin
George_George26-Dec-07 0:58
George_George26-Dec-07 0:58 
GeneralRe: RAII (Resource Acquisition Is Initialization) pattern limitations Pin
peterchen26-Dec-07 1:22
peterchen26-Dec-07 1:22 
GeneralRe: RAII (Resource Acquisition Is Initialization) pattern limitations Pin
George_George26-Dec-07 1:53
George_George26-Dec-07 1:53 
Generalproblem in _bstr_t Pin
rjkg25-Dec-07 19:46
rjkg25-Dec-07 19:46 
GeneralRe: problem in _bstr_t Pin
peterchen26-Dec-07 0:33
peterchen26-Dec-07 0:33 
The safe way is to:
BSTR temp = 0;
HRESULT hr = get_Path(&temp);
// TODO: handle errors here
m_bstrNewPath.Attach(temp);


The reason is that get_Path allocates the string and needs to return you a pointer, so the parameter uses double indirection of (chartype) **.

_bstr_t, for various reasons, cannot safely wrap this operation.
There are a few circumstances where you can avoid the temporary (but you have to know exactly when - and when not). So rather play it safe and use above construct. There is no performance hit involved.

in get_Path, path is an [out] only parameter (i.e. the original valeu is ignored).
If you have a method with an [in/out] parameter, use:

_bstr_t path = ...; // from whereever

BSTR temp = path.Detach();
HRESULT hr = comObject->ModifyPath(&temp);
path.Attach(temp);
if (FAILED(hr))
{
  // handle error here
}


note the different order of attaching vs. error handling.

We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
My first real C# project | Linkify!| FoldWithUs! | sighist


GeneralVariable life cycle Pin
George_George25-Dec-07 19:24
George_George25-Dec-07 19:24 
GeneralRe: Variable life cycle Pin
_AnsHUMAN_ 25-Dec-07 20:06
_AnsHUMAN_ 25-Dec-07 20:06 
GeneralRe: Variable life cycle Pin
George_George25-Dec-07 20:10
George_George25-Dec-07 20:10 
GeneralDrag Drop,overwritefile Pin
john563225-Dec-07 19:05
john563225-Dec-07 19:05 
GeneralRe: Drag Drop,overwritefile Pin
Shaheed Legion27-Dec-07 1:12
Shaheed Legion27-Dec-07 1:12 
QuestionRegarding Interface.. Pin
tasumisra25-Dec-07 19:03
tasumisra25-Dec-07 19:03 
GeneralRe: Regarding Interface.. Pin
_AnsHUMAN_ 25-Dec-07 20:13
_AnsHUMAN_ 25-Dec-07 20:13 
GeneralDisplay Huge files Pin
Manjunath S25-Dec-07 18:50
Manjunath S25-Dec-07 18:50 
QuestionHow to Calculate points of a line in a triangle Pin
MKUser25-Dec-07 18:32
MKUser25-Dec-07 18:32 
AnswerRe: How to Calculate points of a line in a triangle Pin
followait25-Dec-07 18:41
followait25-Dec-07 18:41 
GeneralRe: How to Calculate points of a line in a triangle Pin
MKUser25-Dec-07 19:25
MKUser25-Dec-07 19:25 
GeneralRe: How to Calculate points of a line in a triangle Pin
followait25-Dec-07 23:26
followait25-Dec-07 23:26 
Generalenable button Pin
guru moorthy.k25-Dec-07 18:13
guru moorthy.k25-Dec-07 18:13 
GeneralRe: enable button Pin
Nishad S25-Dec-07 18:34
Nishad S25-Dec-07 18:34 
GeneralRe: enable button Pin
guru moorthy.k25-Dec-07 18:59
guru moorthy.k25-Dec-07 18:59 
GeneralRe: enable button Pin
Nishad S25-Dec-07 19:15
Nishad S25-Dec-07 19:15 
GeneralRe: enable button Pin
guru moorthy.k25-Dec-07 20:13
guru moorthy.k25-Dec-07 20:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.