|
It means that if you want to allow NULL argument for your function (which means "no object"), use a pointer. The reference-based function argument requires you to pass an existing object and not the NULL value.
Happy Easter!
BB
|
|
|
|
|
Thanks, Bartosz buddy!
George
|
|
|
|
|
I want to implement an object pooling scheme for one of my C++ classes that are created and deleted frequently (so much as to cause a performance degradation). I am thinking about creating a pool and keep it in a static list, and manage the list instead of actually calling new and delete every time.
Is this recommended for improving performance OR is there a better alternative apporach?
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Some of our intense code uses object pooling, and in our case it definately improves performance. We have a log and it will show that the object pooling removed the need for thousands upon thousands of calls to new (these are comm message objects, which would get created and deleted quite frequently when comm is heavy). The key is finding the right number of objects to store in your pool, so that you aren't using too much unnecessary memory, and so that your pool doesn't run out all the time. It will probably take some tuning.
If you are wary of it, then just try implementing it (it shouldn't be too bad). If profiling shows significant performance gains, it would be a good idea for you. As for alternative approaches, I don't really know of any off the top of my head.
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
Thank you very much for the reply.
I made one implementation already. My objects are very small and the number of objects that are in memory at any time is not significantly high. To my surprise, my application improved more than 20% in performance. I am planning to post an article this weekend with the code.
Currently, the pool grows to the maximum number of objects of the class that have ever been in memory. I want to put in some code to release some of these objects, if they are not being used. Anyway. it is not important to me at this moment because memory usage is not very huge.
Thomas
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Sounds good. 20% is a nice gain, and I look forward to your article.
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
To disable ctrl-alt-del I use the following code but it is not working in windows 2000. So how to do it????
BOOL c=TRUE;
BOOL ret=SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,1,&c,0);
|
|
|
|
|
I do not know if it is still possible. What you could do is set a keyboard hook [^]. But it is usually not really user friendly to mess up with ctrl-alt-del
~RaGE();
|
|
|
|
|
In windows NT 4.0 and above you need to replace the MSGina.dll (handles windows login) with a new one. See GINA in MSDN.
GINA
A Graphical Identification and Authentication dynamic-link library (DLL). The GINA is a replaceable DLL component that is loaded by the Winlogon executable. The GINA implements the authentication policy of the interactive logon model and is expected to perform all identification and authentication user interactions.
When logged on, if a user enters a secure attention sequence (SAS), the user is presented with a security options screen. Among the options listed are:
Shut down the system.
Log off.
Change the password.
Go to the task list.
Lock the workstation.
A replacement GINA can provide similar options when an SAS event is received while a user is logged on.
secure attention sequence
(SAS) A key sequence that begins the process of logging on or off. The default sequence is CTRL+ALT+DEL.
John
|
|
|
|
|
How to block Window key and Alt key operation
|
|
|
|
|
|
|
After changing to Visual Studio.Net and C++ V7 (and from WinNT to Win2K), I cannot change the application icon of my Visual C++ 7.0 application.
On my developer machine, I can only see the standard MFC icon, although this was explicitly removed from the app's resources.
When the application is installed on another machine, it correctly displays its custom icon.
Any ideas ? Thank you !
|
|
|
|
|
If you move your .exe out of the release directory, is the icon still wrong ?
~RaGE();
|
|
|
|
|
Yes, in the app. The desktop link (I made one) displays the correct icon !
|
|
|
|
|
The desktop link uses the 32*32 icon, whereas the app (in the explorer) uses the 16*16 one. Did you change both of them (Check that ComboBox in the ressource editor...)
~RaGE();
|
|
|
|
|
1. Have you Rebuilt All?
2. In Doc/View architecture, distinguish between application and document icon (the link may display custom application icon, and the document icon may still be wizard-generated.
Regards,
BB
|
|
|
|
|
(1) Yes, I rebuilt
(2) It is not the problem with app/doc icon, but the app has the MFC default icon.
|
|
|
|
|
I think I had such problem once, but I can't remember clearly what the cause exactly was. You may try deleting all compiler-generated stuff (Debug\ and Release\ dirs, .aps, .ncb ...) and unused resource IDs, then build again.
Happy Easter!
BB
|
|
|
|
|
When editing the icon, did you replace every device type? If you don't know what I'm talking about, when editing the icon there is a combobox labeled device. Icons can have different sizes and color depths. Make sure to change them all.
Joel Lucsy
|
|
|
|
|
Yes, there are different icons under the different device types. That's strange.
Thank you for pointing to the solution.
|
|
|
|
|
Hello,
I have a formview in which a "play" button opens a new window where a video is played image by image. I have also created a "pause" button which should stop the video. But once I'm starting to play my video, nothing happens when I click on the pause button. If I understand well, the message sent by the pause button cannot be catched while my video is playing.
Basically, what I did is the following :
bool user_paused=false // gets true when the user clicks on
// pause
OnButtonPlay(){
while(user_paused==false){
// grab next frame
}
}
OnButtonPause()
user_paused=true;
}
Is there something that I didn't understand in the handling of messages ? Has anyone a solution to help me solve this problem ?
Thank you
Sandrine
|
|
|
|
|
You understand correctly.
You need to change the play loop to check for messages.
Have a look at this example, it's a cancellable progress bar, but it shows how to process messages in a loop.
Progress Window[^]
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Thank you, this helps a bit, but there are still things I don't understand : you are supposed to grab the message that has been picked, but I don't understand how I can know which button sent the message. In the example, it is :
msg.message==WMCHAR&&msg.wParam==VK_ESCAPE,
which I think corresponds to a keyboard key, the escape key, but in my case, it is a button that I have created so the msg.message should be BN_CLICKED, but I have several buttons, so it should grab the message for any button. How can I specify which button is concerned ?
Sorry if I bother with simple questions, but I have hard time finding simple examples for beginners.
Sandrine
|
|
|
|
|
In your message loop, get the WM_NOTIFY message which is sent by your pushing the button.
WM_NOTIFY
idCtrl = (int) wParam;
pnmh = (LPNMHDR) lParam;
Cast the lParam on a LPNMHDR (like done here on pnmh), and you have a pointer on a NMHDR structure :
typedef struct tagNMHDR {
HWND hwndFrom;
UINT idFrom;
UINT code;
} NMHDR;
check if the pnhm->idFrom correspond to your IDC_PAUSEBUTTON (or whatever ID you gave to the button), and if yes, your button has sent the Message (ouf).
BUT ...
I would recommend you to let the video display using its own thread, so the rest of the buttons keep available for the user (this is pseudo code):
Main
if (pause) boolean PAUSE=1
if (play) boolean PAUSE =0, boolean PLAY=1
if (stop) boolean STOP=1
...
VideoThread
while (not STOP)
if (PLAY) display next frame
if (PAUSE) while (not PAUSE)
...
~RaGE();
|
|
|
|