|
HI,
Wt are smart pointers and y we use them ?
thanx
Regards.
|
|
|
|
|
Hello Zahid,
Smart Pointers are actually objects which wrap around actual memory pointers. These memory pointers usually point to objects which are reference counted.
Smart Pointers are usually bound to these object pointers on construction. During construction, a smart pointer would usually increment the reference count of the pointed-to object. For example
SmartPtr(Interface *& pInterface) :
m_pInterface(pInterface)
{
if (m_pInterface)
{
m_pInterface -> AddRef();
}
}
During destruction, the smart pointer will usually decrement the reference count of pointed-to object. For example :
~SmartPtr()
{
if (m_pInterface)
{
m_pInterface -> Release();
m_pInterface = 0;
}
}
Smart Pointers can also increase the ref count of their internal object pointers when they are assigned to another object. For example :
// Copies and AddRef()'s the interface.
//
SmartPtr& operator=(const SmartPtr& copypointer) throw()
{
if (operator!=(copypointer))
{
Interface* pOldInterface = m_pInterface;
m_pInterface = copypointer.m_pInterface;
if (m_pInterface)
{
m_pInterface -> AddRef();
}
if (pOldInterface)
{
pOldInterface -> Release();
pOldInterface = NULL;
}
}
return *this;
}
It is this automated reference increment and decrement feature of smart pointer objects that make them most useful for keeping the reference count of COM objects (through their interface pointers).
To properly keep track of COM objects (via their interface pointers), AddRef() and Release() calls must tally. Otherwise there will be reference undercount (leading to crashes) and reference overcount (leading to memory leaks). This is precisely what Smart Pointers are designed to overcome.
There are many more useful functionalities behind Smart Pointers. Lookup the definition of _com_ptr_t in MSDN.
Regards,
Bio.
|
|
|
|
|
|
There are methods to change the pointer shape, why not just create a one pixel mouse pointer and use that ?
Elaine
The tigress is here 
|
|
|
|
|
Use the ShowCursor function. Despite its name, it can hide and show the cursor.
|
|
|
|
|
Handle WM_SETCURSOR for the window and call SetCursor(NULL).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
You can use the ShowCursor Windows API function to show and hide the mouse pointer.
|
|
|
|
|
Hi All,
I wanted to know how to display the tooltips for the contents of the CListBox.
The length of the strings that are inserted into the CListBox is larger than the width of the CListBox.For such strings I want to display a tooltip text containing the full string when user places the cursor on them.Can someone tell me how to realize this.
I want to implement something like the tooltips displayed for CTreeView when the contents of the node does not fit the window.
Thanks in advance
Regards
Raghu
|
|
|
|
|
|
I'm new to using the WinInet APIs and I'm stuck on something. If I request a bogus URL with HttpOpenRequest() and HttpSendRequest() , some servers will return HTML in response to the 404 error (example). The trouble is that the above two APIs will succeed because data is returned. Calling HttpQueryInfo() with the HTTP_QUERY_STATUS_CODE returns a code of 0, not 404.
So, the question is how can I tell when an HTTP error actually happens?
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Hi, I am doing image processing and need to manipulate the pixels of the bitmap. Thus, I need to read the pixel from the bitmap to a 2D array. Is there any way to do this? Or is there any library that do that for me?
|
|
|
|
|
Check CxImage library. Procedure "Filter" and others reads bitmap.
Vaclav
|
|
|
|
|
Hi,
Iam using dhtml control in my application. Iam having a problem in table selection. For Example: if i put 2 * 3 table and try to select from 2row and 2 column in upwards direction it is selecting 1 row ,3 column also. And merge cells is not activating if the selection is not exact....
Kindly help...
I downloaded the dhtml edit from msdn..
Thanx.
Raj
|
|
|
|
|
hi everyone,
I'm trying to use the activex control MS Flexgrid. However, if I try to add it to a dialog it tells me that it can't be instantiated because I don't have a run-time license. From what I was able to dig up searching the net about this problem was that I needed to manually give the control a license. This makes no sense to me as I don't understand why you'd need to do something like that if its already in visual c++. Now I don't know the first thing about ActiveX or COM so that might be why. Is there any way to use this control without knowing ActiveX? I just want to be able to have a nice database view such as in Access or if you chose a database view using the single doc architecture (i'm using dialog based). Right now I'm stuck using a listview which simply doesn't look as nice. I suppose I could try using a grid from one of the articles on this site, but it'd be easier to just use the ms flexgrid if possible.
Thanks,
Mike
|
|
|
|
|
hello,
I'm porting some old code from C to Windows code, I'm in a little trouble, suppose I've got a text file, I need to copy single line of text into a listview,
before I did something like
<br />
FILE *fMMC=fopen(filename,"r");<br />
.<br />
.<br />
.<br />
while(!feof(fMMC))<br />
{<br />
while (fgets(buffer,BUFFER_SIZE,fMMC))<br />
{ ....insert buffer into listview<br />
}<br />
}<br />
<br />
<br />
now porting to Windows code, I did someting as
HANDLE fMMC=CreateFiles(..all_the_parameters)...<br />
<br />
while(true)<br />
{<br />
DWORD br;<br />
ReadFile(fMMC, buffer, 255, &BR, NULL)) break;<br />
<br />
}<br />
my question is : in buffer, I can have multiple lines, since with fgets it takes a whole line and stop, with ReadFile I can have 2/3/4 lines depending of each lenght, how do I can retrieve from buffer only 1 line at time? is there a simple way? so that if buffer is composed of 3 lines, i get 3 item in listview
Thanks in advance
Paolo
p.s. if it's possible in some way to copy only a line as fgets does, it would be much more better, thanks again
|
|
|
|
|
You have to parse the text yourself.
If you feel the file will always be small, then i suggest you load it completely in 1 pass, then parse that memory chunk.
Otherwise, you need to parse a little differently and take care not only of \n but also of when you reached the end of the buffer and have to reload another segment.
Hope this gives you a hint.
|
|
|
|
|
Hi,
is there a way to monitor events and messages sent from/to for a particular application? If so, how?
Thanks!
|
|
|
|
|
i highly recommend (hope i'm not going to be bashed) that you look at http://www.sysinternals.com[^]
They have many usefull simple apps, and very often with source code.
P.S.: I am in no way affiliated to sysinternals, i just use their apps that i find very usefull.
|
|
|
|
|
darkbyte wrote:
hope i'm not going to be bashed
I certainly hope you wouldn't get bashed for recommending an excellent resource such as sysinternals.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Thanks! 
|
|
|
|
|
I am able to get the Add-In displayed in the Add-In Manager Dialog Box but I can't get the icon to be displayed in a toolbar. Anybody know how to?
I am the handsome one in the crowd.
|
|
|
|
|
Should there be an icon? I recently installed XC# and there's no icon. Perhaps it depends on the Add-in?
Kevin
|
|
|
|
|
Is this your own code or some random add-in you loaded on the net ?
|
|
|
|
|
I have stored in a database a rescaling factor "0.5/pow(2, 14)".
My question is as its stored as a string how do I use it?
I did try in my project:-
#define scaleFactor1 (data_details[index].scaling)<br />
float rescaledData = currentField * scaleFactor1;
But this does not work; get error:-
c:\Export_Lib\Export_LibDlg.cpp(353): error C2297: '*' : illegal, right operand has type 'char [30]'
Also the macro would be redefined as the statements are in a loop.
Also I did try:-
float scaleFactor1 = signal_details[index].scaling;
But the same error, what I expected.
Are they any tricks that can be aplied to this string to make it usable in the code.
grahamfff
|
|
|
|
|
Grahamfff wrote:
My question is as its stored as a string how do I use it?
Convert it to a floating-point number using atof() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|