|
I am a bit curious about why to use new in MFC. What is the danger which is avoided by using 'new' and why such a precaution in MFC. I am almost unaware about MFC and its fundamentals.. That's why I am curious about the above issue
|
|
|
|
|
For integral types, there's not much difference other than the ability to track down memory leaks. For classes/objects, the new operator will also call the constructor.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for the valuable information
|
|
|
|
|
I created a context menu and displayed it using TrackPopupMenu . I do not use TPM_RETURNCMD . My application window receives the result of user selection.
It works fine if I select/click some menu item - the window receives message for the given menu item. However if I cancel the context menu (hit Esc or click somewhere else) I do not receive any message. Is there any mechanism to catch context menu cancel event?
Another question, how to determine if a context menu (CMenu) is active and displayed?
Thanks,
Abyss
|
|
|
|
|
TrackPopupMenu will return 0 if user cancels the menu.
Abyss wrote: Another question, how to determine if a context menu (CMenu) is active and displayed?
If you call the TrackPopupMenu, the thread is blocked at that statement as long as the menu is displayed. So from where you want to know the state of menu?
|
|
|
|
|
If I call TrackPopupMenu with TPM_RETURNCMD flag then the thread is blocked and I can check the return value. However I do not use the TPM_RETURNCMD flag which cause that the TrackPopupMenu creates the context menu and immediately exits. The menu is still active and sending messages to the window. That is why I can't check the return flag because it just say that the menu has been created.
Abyss
|
|
|
|
|
Abyss wrote: If I call TrackPopupMenu with TPM_RETURNCMD flag then the thread is blocked and I can check the return value
I dont think so. please try putting a messagebox in the next line after the TrackPopupMenu() and see whether it is coming or not.
|
|
|
|
|
Uff, you are right. I put a breakpoint right after the TrackPopupMenu call and it returned only after the menu was closed. Meanwhile the WinAPI send notification to the window.
I do not understand why I did not try this?!
Many thanks,
Abyss
|
|
|
|
|
Naveen wrote: TrackPopupMenu will return 0 if user cancels the menu.
Only if the TPM_RETURNCMD is specified. If not it will return the success or failure status.
See the MSDN documentaion.
If you specify TPM_RETURNCMD in the fuFlags parameter, the return value is the menu-item identifier of the item that the user selected. If the user cancels the menu without making a selection, or if an error occurs, then the return value is 0.
If you do not specify TPM_RETURNCMD in the fuFlags parameter, the return value is nonzero if the function succeeds and 0 if it fails. To get extended error information, call GetLastError.
|
|
|
|
|
The list control width is changed in OnNcCalcSize for placing a vertical scroll bar having larger width than normal scroll bar.Then the last column is clipped.
see the code portion below:
void CustomListCtrl::OnNcCalcSize( BOOL bCalcValidRects_i, NCCALCSIZE_PARAMS FAR* lpncsp_i )
{
CListCtrl::OnNcCalcSize( bCalcValidRects_i, lpncsp_i );
DWORD dwStyle = GetWindowLong( m_hWnd, GWL_STYLE );
bool bVScroll = ( WS_VSCROLL == ( dwStyle & WS_VSCROLL ));
if( bVScroll )
{
lpncsp_i->rgrc[0].right -= ( nScrollbarSize - GetSystemMetrics( SM_CXVSCROLL ));
}
}
Actually scroll bars are appearing at correct position but the contents of the last column is clipped.
please help me...
thanks in advance....
JKV
|
|
|
|
|
Hi ...thx for reply...here iam explaining clearly...
iam doing Chat application with out language pack installation .In this when i paste telugu,tamil characters in rtf ,and put one afxmessagebox in sending .In this afxmessagebox it will comes automatically decimal values like 3411(example).. when iam sending chinese characters from rtf the decimal values are not coming it will comes like \'d4\'a4 .
i need help how to convert \'d4\'a4 to decimal value ...plz tell...
#sanroop#
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Is it possible to develop a GraphicsPath object from a Region object?
If possible plz give detail process.
|
|
|
|
|
hi ,
i want to edit a file with non ".cpp" extenstion on vs2003. the editor displays the contents as a plain text file( no Intellisence and color scheme). is any way i can configure the editor to treat thi file as cpp source code without changing its file extension ?
Thanks & Regards
|
|
|
|
|
Set the Language as "C/C++" in the "Source File Properties". You will get it by right clicking the editor and select the "Properties".
|
|
|
|
|
NS17 wrote: right clicking the editor and select the "Properties".
the editor does not contains a "Properties" option on context menu.
i tried "view->properties" but property panel contains nothing.
iam using VisualStudio2003, doing a console application project.
thanks
|
|
|
|
|
nitin3 wrote: iam using VisualStudio2003
I am sorry, I said about VC6. I am not so sure about how to do it in VC7.
|
|
|
|
|
Tools | Options --> Projects and Solutions --> Visual C++ Project Settings --> C/C++ File Extensions.
Maxwell Chen
|
|
|
|
|
Isn't it in VC 2005? He is using VC 2003.
|
|
|
|
|
NS17 wrote: Isn't it in VC 2005? He is using VC 2003.
I only have VC2005 right now. I think that VC2003 and VC2005's IDEs are very much similar.
Maxwell Chen
|
|
|
|
|
Hmm, ".cpp" should be handled by default by Visual Studio. Are you sure you have installed the C++ component of Visual Studio?
You can always try running the VS installer and doing a repair...
Just my two cents.
Florin Crisan
|
|
|
|
|
Actually his source file has NOT cpp extension...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
You're right
Florin Crisan
|
|
|
|
|
Hello,
Is there away to implement a preprocessor macro that would generate a build date in the style of UNIX timestamp (like 20080103 etc.). It would be helpful to print this kind of timestamp into program's About box or include it into program's version number. I know there is __DATE__, but this outputs a different format.
Cheers
|
|
|
|
|
HenriH wrote: I know there is __DATE__, but this outputs a different format.
__DATE__ is what you need. Re-arranging string format won't be such a difficult task.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|