|
CTest& operator=(const CTest& rhs)
{
m_test = rhs.m_test;
return *this;
} Yes, you can see the private members of another instance of your class. Returning a reference to the current object allows assignments to be chained.
Interestingly, even though you haven't written an operator=(int) , because you have an implicit constructor that takes an int , you can write:
CTest tst( 4 );
tst = 9; which constructs a temporary CTest and calls operator= . If you don't want this, mark your constructor explicit .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for trying to help but the member variable is a const int which generates the compiler error 'l-value specifies const object' if I implement your suggestion. The class shown is just the simplest example I could put together to show my problem.
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
My understanding is that the only time a const member variable can be initialized is in the member initialization list of the constructor. So unless you are just trying to solve a puzzle for a class, I wouldn't try to get around this rule in professionally designed code. If the variable is const, it is const for a reason; meaning it should never change once it is initialized. Once it is initialized by the constructor, whether it be the default constructor or the copy constructor it should never be changed!! That is why it is const. If it needs to be changed then it should not be const. It is as simple as that in my mind.
Now some super programmer might reply with some crazy way of actually making it happen; but again, it is not good programming style. Const has a special meaning and to make a member variable const and then try to undo that is a bad style in my opinion. Either the variable needs to be const or it doesn't! Since const variables must be initialized in the member initialization list of the constructor anyway, there seems to be no reason why you'd ever want to copy it in the assignment operator anyway because the value would be the same for all classes anyway!
Regards,
Shawn
|
|
|
|
|
How can I lock the keybord and mouse?
I need to be able to disable the keybord and mouse how do I do this.
Plese help me.
|
|
|
|
|
Now a days i am working on a software , which will run specific scheduled tasks at certain time.What should be the technique to develop this software.
One obviouse way is using Timers , but is there some built in notifications by windows.which could infrom my application at certain time.
My schedule may be like this
Task1 12:30:30 PM 7July 2004
Task2 2:30:30 PM 7July 2004
Task3 1:30:30 AM 8July 2004
Task4 12:30:30 PM 8July 2004
etc.
Unmanaged in a .NET world
|
|
|
|
|
If you want your process to do the work, use CreateWaitableTimer. This will allow you to put your process into an efficient sleep, to be awoken at the appropriate time (or other circumstances, like a Windows Shutdown...).
Otherwise, submit the tasks to the internal Windows Task Scheduler, which is capable of performing various types of 'jobs'.
|
|
|
|
|
Hi,
I am trying change desktop bkcolor without restart,logoff-logon or using control panel.
I opened the spy to get handle desktop listview,after that i write this code:
(HWND)0x00030074-->this is what desktop listview handle
...
ListView_SetBkColor((HWND)0x00030074,RGB(255,0,0));
...
it is work until desktop get WM_PAINT,(you can see it by spy++)
after desktop got WM_PAINT,desktop bkcolor getting old value which is defined in
'HKEY_CURRENT_USER\Control Panel\Colors\Background' key value.
i changed 'HKEY_CURRENT_USER\Control Panel\Colors\Background' key value what i want
and added this code because i wanted to take effect registry without logoff-restart
::SendMessage((HWND)0x00030074/*HWND_BROADCAST*/,WM_SETTINGCHANGE,0,0);
it is not work.
ı thing control panel settings can not be changed WM_SETTINGCHANGE message...
i want to change desktop bkcolor like control panel display settings.
How can i do that ??
Thanks,
repekcan
|
|
|
|
|
I think you want to call SetSysColors:
const int aElements[] = { COLOR_DESKTOP };
const COLORREF aColors[] = { RGB( 255, 0, 255 ) };
SetSysColors( 1, aElements, aColors ); Not tested, no warranty
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
yes,it is change desktop bkcolor
|
|
|
|
|
Hi,
I am automating Word 2000 and I want to disable the "Ctrl C" keyboard functionality. (Using VBA I am successful in disabling the "Ctrl+C" by doing this - "Application.FindKey(BuildKeyCode(wdKeyControl, wdKeyC)).Disable")
I am using the following C++ automation code which gives me the DISP_E_EXCEPTION error code on IDispatch::Invoke for "Disable" method ("AutoWrap" function below is a wrapper around IDispatch::Invoke). Here is my C++ code:
parm1.vt = VT_I4;
parm1.lVal = wdKeyControl;
parm2.vt = VT_I4;
parm2.lVal = wdKeyC;
VariantClear(&result);
AutoWrap(DISPATCH_METHOD, &result, pWdApp, L"BuildKeyCode",2,parm2,parm1);
parm1.vt = VT_I4;
parm1.lVal = result.lVal;
VariantClear(&result);
AutoWrap(DISPATCH_PROPERTYGET , &result, pWdApp, L"FindKey", 1,parm1);
pWdKey = result.pdispVal;
AutoWrap(DISPATCH_METHOD, NULL,pWdKey , L"Disable", 0);
Error :
"This method or property is not available because this document is in another application"
I will appreciate any help on this.
Thanks.
Vishal
----------------------
Vishal More
|
|
|
|
|
Is there any good article about this? Thank you
|
|
|
|
|
|
Hi
Problem is like this on my Mousemove event i am checking whether some text is under the mouse or not. If text is under then i will mark the flag to true.
Based on this i am shoing my popup menu say if m_textunder == true then Show pop up menu item Edit TEXT , else show ADD TEXT menu item.
Problem what i am facing is if i mouse move over the text my flag get set to true and EDIT TEXT items get show, now if i right click over other portion of the view where test is not under then still it is showing the EDIT TEXT OPTION. Only in case that if i left click over the area then it will refresh i.e. again start to show the ADD TEXT if text is not under.
My code portion is as per follows:
Function onMouseMove:
CTextLabel *pTxt = pDoc->GetCurrentTextLabel (point,m_Scale,1);<br />
if(pTxt != NULL)<br />
{<br />
m_TextUnder = true;<br />
m_TextToEdit = pTxt->GetText ();<br />
}<br />
else<br />
{<br />
if(m_TextUnder)<br />
AfxMessageBox("not under");<br />
m_TextUnder = false;<br />
}<br />
}<br />
<br />
Function -->OnRButtonDown(UINT nFlags, CPoint point) <br />
<br />
CNewMenu menu;<br />
menu.CreatePopupMenu();<br />
menu.InsertMenu(0, MF_BYPOSITION, ID_VIEW_ZOOMIN,"Zoom In");<br />
menu.InsertMenu(1, MF_BYPOSITION, ID_VIEW_ZOOMOUT,"Zoom Out");<br />
menu.InsertMenu(2, MF_BYPOSITION, ID_VIEW_SPECIFYZOOM,"Specify Zoom");<br />
<br />
if(m_TextUnder)<br />
{<br />
menu.InsertMenu(3, MF_BYPOSITION, ID_SEPARATOR, "");<br />
menu.InsertMenu(4, MF_BYPOSITION, ID_EDITTEXTLABEL, "Edit Text Label");<br />
}<br />
else<br />
{<br />
menu.InsertMenu(3, MF_BYPOSITION, ID_SEPARATOR, "");<br />
menu.InsertMenu(4, MF_BYPOSITION, ID_OPT_TEXT_LABEL, "Add Text Label");<br />
}<br />
ClientDC.LPtoDP(&point);<br />
ClientToScreen(&point);<br />
menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, this);
What can be the wrong ?
|
|
|
|
|
What are you trying to do? Change context menu items dependent on where the mouse pointer is?
While TrackPopupMenu is running, it has mouse capture. That is, all mouse messages go to the menu, even if the mouse isn't over it. You can't change the contents of a popup when it's displayed, anyway, because TrackPopupMenu runs a modal loop (i.e. it doesn't return until the user either chooses a menu item or clicks away from it).
The user also won't expect this to change while they have a popup menu item. Normally the contents of a context menu reflect the currently selected item in the document at the time the menu was selected.
I suggest working out which menu items to show in the button click handler. Also, for consistency with Microsoft applications and the Windows shell, the context menu should be shown on button UP, not button down (try it on Explorer).
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
In a non-MFC application I used the fread() function in order to read documents (WORD) EXCEL files and PowerPoint files.
The problem is that I get not only the content of those files but also information about the file (like file owner etc.).
Is there a way to read only the content of those files?
|
|
|
|
|
I didn't quite understand your question. Could you please rephrase it?
Though by look of it you're expecting from fread to understand format of excel and word files. If so, your expectations are wrong. It's low level i/o function and knows nothing about file format, it simply read/write bytes.
|
|
|
|
|
didn't expect fread to do nothing but reading
my question is how can i analyze the file format so i can draw from it the content of the file.
thanx
|
|
|
|
|
Well, you obviously have to know file format for that.
I can give you a small hint. Read 2 bytes on offset 0x200. If you have 0x0009, 0x0209, 0x0409, 0x0809 it's Excel file. I don't have much data on PowerPoint format therefore my assumption can be wrong. Nevertheless, if you have 0xA046 there, it's PowerPoint XP(and 2003?). If you have 0xFDFF there, you have to read extra 2 bytes from 0x204 and if you have 0x5eca there, it's PP95 and if the value is 0x5dca, it's PP97(-2002?).
Hope it'll help.
|
|
|
|
|
Are you against using Excel Automation? Trying to use fread() to weed through a .xls file would be no small undertaking.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I derived a template class from a treelist control class,and placed it in a MFC project.In a dialog, using it as : "CTreeCtrl<cif> m_ctrlTree;".But have a lot of fatal error:fatal error C1001: inner compile error.Refering place is executing the member function of template class.What is wrong with that.Pls help me.
|
|
|
|
|
Internal Compiler Error means you've found a bug in the compiler. Typically this means that it doesn't understand your syntax, or you've exceeded a limit. I suggest starting by commenting out the line on which it fails, repeating until you get it to compile. Then uncomment lines until it stops compiling. By repeating, you should be able to narrow down the location of the fault.
You'll also find the KB article C1001 Compiler Error Message - Suggestions for Troubleshooting[^] helpful.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hai....how can i use C++ to save tiff image to raw data>?
|
|
|
|
|
Look at cxImage library in Codeproject
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Maybe a simple question but when you open a database (SQL2000) in MFC CRecordset in mode dymanic and then sort the database by any column(s), why does the database (recordset) become "READ ONLY". It's open for read/write but as soon as you start sorting the database, you can't write/update anymore.
I am trying a workaround with stored procedures but if that fails, I will have to give the sorts.
Anybody out there can help me?
Thanks,
craig christensen
|
|
|
|
|
HI,
How can i manipulate Registry.
Any sample by Example.
thanx
|
|
|
|
|