|
The only purpose of the timers is to refresh the views every so often then. In that case, you might as well set the timer in the view itself, probably start it in OnInitialUpdate() and kill it in OnDestroy() . This way, OnTimer() in the view will get called and you can perform the refresh. If the update frequency needs to be adjusted by the document, you can provide a public member function in the view to achieve this.
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
c:\windows\desktop\project3\linkedlist.h(147) : error C2676: binary '==' : 'class Partition' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Windows\Desktop\Project3\Partition.cpp(188) : while compiling class-template member function 'class Partition &__thiscall LinkedList<class partition="">::find(class Partition &)'
Error executing cl.exe.
HERE IS SOME CODE:
void main()
{
Partition* tempPartition;
MemoryManager* tempManager = new MemoryManager();
LinkedList<partition> L;
bool firstInputLine = true;
int processNumber;
int memoryDesired;
cout << "------------------------------------------" << endl;
cout << "PROCESSING " << endl;
cout << "------------------------------------------" << endl;
do
{
cin>> processNumber >> memoryDesired;
if (firstInputLine)
{
if (memoryDesired <= tempManager->memoryLimit)
{
tempPartition = new Partition(0, memoryDesired-1, false, processNumber);
L.insertAt(*tempPartition, 0);
tempManager->addProcess(*tempPartition, 0);
firstInputLine = false;
}
else
cout <<" THIS PROCESS NEEDS MORE MEMORY THAN WHAT I GOT.";
<\pre>
When i click on that error it takes me to the LinkedList template class
I'm very confused. thanks for unconfusing me.
:confused:
|
|
|
|
|
Compiler Error C2676
binary 'operator' : 'type' does not define this operator or a conversion to a type acceptable to the predefined operator
The specified operator could not be used in its predefined form. To use the operator you must overload it for the apropriate type, or define a conversion to a type for which the operator is defined. If you’ve encountered this error on code which compiled with an earlier version of Visual C++, please read Technote: Improved Conformance to ANSI C++ for more information.
The following is an example of this error:
class C
{
public:
C();
} c;
class D
{
public:
D();
D operator <<( C& );
} d;
void main()
{
d >> c; // error
d << c; // OK, operator << defined
}
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
1. This is not the code that is causing the problem. The error is found on the line you are shown when you double click on the error message.
2. The reason you get the error is that == is not a defined operation for one or both of the things you are comparing.
e,g,
CString s1, s2;
if (s1 == s2) ...
this works because the CString class has a method named == that performs the comparison. The compiler doesn't know what to do in your case. Basically you need to tell it how to compare two objects of your class.
Look at the CString class definition for hints on how to do this.
|
|
|
|
|
Help me. !I have an exercise:
Build an Active X that allow communicate with COM Ports:
-Allow user choosing port (COM1, COM2, COM3, COM4)
-Allow setting parameters: speed, parity, data bit, stop bit…
-Have methods: Open, Close, Flush ports
-Have method: Send & Receive data (char or string) through ports
-Allow setting time for end of transfer data (time-out transfer)
-Allow setting time for testing port (loop-back tested time)
-Auto enabled when there's an event from ports.
Can you help me !
Hung Son
|
|
|
|
|
I'm trying to find a good way to change the saturation of an image.
I've tried the HSL/T/V colorspace tricks, but they don't really work very well; because of the way things work out when going back to RGB space, increasing S tends to make images more red. Unfortunately, most image procesing packages seem to use some variation on the HS* trick, because they all show this tendency towards red at high saturation levels (and those that you can get the source to, like The GIMP and ImageMagick definitely use HSL).
Of course, Photoshop does an excellent job of preserving hue while increasing intensity/saturation - it has none of that red effect and is able to saturate colors to much higher levels than anything else i've seen. So, there's definitely a way to do it - but how?
Anyone have any other ideas? i've searched google for days and can't find anything but "RGB -> HSL -> RGB".
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
Sorry, I can't help. I just wanted to say I *hate* those Photoshop guys for doing everything so much better. I have spent hours in front of Photoshop applying filters and trying to replicate them.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
|
The verdict:
It's faster and uses (infinitely) less memory than the RGB->HSV->RGB method. And the results are by-far better.
The thing is, the results aren't exactly the same as Photoshop. What I'm struggling with now is: is that a bad thing? The output is almost more natural than PS - things don't get as blown-out as they can in PS, so that's good. But sometimes you really want things to get crazy; it's half the fun!
Regardless of the fun factor, I'm definitely going to use it for a while, to see if people like it.
Thanks!!!
B.T.W., the algorithm actually came from SGI (http://www.sgi.com/grafica/matrix), the PDF you linked to just repackaged the SGI stuff.
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
i have a mfc application.
i create a modal dialog with a button.
when i press that button, i want the modal to send an user message to the mainframe and the mainframe - in response to the user message - to create a modeless dialog.
strangely, it works on debug configuration but fails on release.
wish for help!
rechi
|
|
|
|
|
(I don't know whether sending a message to a blocked parent should work or not (my guess is it shouldn't), this is only a workaround.)
If your user message is say WM_CREATE_MODELESS_DIALOG and the associated handler OnCreateModelessDialog , just call this method directly with ((CYourMainFrmWnd *)AfxGetMainWnd())->OnCreateModelessDialog() . Maybe this works.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
|
|
|
|
|
If you only want it to happen once, use adara's suggestion with this key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
If you want it to run everytime the machine is restarted, a better practice is to put a short cut in the startup folder. All of the systems services will have started before the applications in the Startup folder are run.
BTW: The registry path shown above and those used in the sample below are guaranteed on all MS platforms.
Usage:
CreateShortcutEx("Startup","MyAppShortcut","What ever this thing does","c:\\program files\\MyAppFolder\\MyApp.exe","");
This routine builds the shortcut itself.
CString CHSD30App::CreateShortcutEx(CString szWhere, CString szLinkName, CString szDesc, CString szFile, CString szArguments){
TCHAR szLink[MAX_PATH];
DWORD cchCurDir = MAX_PATH;
DWORD cchStartDir = MAX_PATH;
char *pDot;
TCHAR szStartInDirectory[MAX_PATH];
HRESULT hres;
IShellLink *psl;
HKEY hCU;
DWORD lpType;
ULONG ulSize = MAX_PATH;
BOOL bRetVal;
DWORD dwRetVal = 0;
bRetVal = FALSE;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
0,KEY_QUERY_VALUE,
&hCU))
{
RegQueryValueEx( hCU,
LPCSTR(szWhere),
NULL,
&lpType,
(unsigned char *)&szLink,
&ulSize);
RegCloseKey(hCU);
}
bRetVal = FALSE;
pDot = strrchr(szFile, '.');
lstrcat (szLink, LPCSTR(szLinkName));
if (pDot = strstr(szLink, "."))
*pDot = (char)NULL;
lstrcat (szLink, ".LNK");
hres = CoInitialize(NULL);
if( !SUCCEEDED(hres))
bRetVal = FALSE;
else
bRetVal = TRUE;
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **)&psl);
if (SUCCEEDED(hres))
{
IPersistFile *ppf;
hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
if (SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
hres = psl->SetPath(szFile);
if (!SUCCEEDED(hres))
bRetVal = FALSE;
else
bRetVal = TRUE;
if (!szArguments.IsEmpty())
{
hres = psl->SetArguments(szArguments);
if (!SUCCEEDED(hres))
bRetVal = FALSE;
else
bRetVal = TRUE;
}
hres = psl->SetDescription(szDesc);
if (!SUCCEEDED(hres))
bRetVal = FALSE;
else
bRetVal = TRUE;
GetCurrentDirectory(MAX_PATH,szStartInDirectory);
hres = psl->SetWorkingDirectory(szStartInDirectory);
if (!SUCCEEDED(hres))
bRetVal = FALSE;
else
bRetVal = TRUE;
MultiByteToWideChar(CP_ACP, 0, szLink, -1, wsz, MAX_PATH);
hres = ppf->Save(wsz, TRUE);
if (E_FAIL == hres)
bRetVal = FALSE;
else
bRetVal = TRUE;
ppf->Release();
}
psl->Release();
}
else
bRetVal = FALSE;
CoUninitialize();
CString retString = szLink;
if( !bRetVal)
retString.Empty();
return retString;
}
Good Luck,
Bill
|
|
|
|
|
Hi all,
I am new to VC++. Here is the question I have:
I need to write a program that can make a call to another machine through modem, like the Hyperterminal.
Should I use TAPI or RAS or other functions?
RASDIAL needs the phone#, userID, password during the dial up process. But I need to send out the user ID when the remote computer prompts "Username". Also, the password will be sent out only if the remote computer prompts for "Password".
Any help would be appreciate.
Sue
Sue
|
|
|
|
|
When I began to study VC++, I had this idea, but I forgot. Now, help me for that problem plz !
Hung Son
|
|
|
|
|
how to get a process name attached to a given udp port?
|
|
|
|
|
I have created a dialog app, which return a debug error meesage that i don't understand. This message is:
Debug error
Program :\CalcRiskPort\Debug\CalcRiskPort.exe
DAMAGE: after Normal block (#81) at 0x00301190
when i pree retry i have this message box:
User breakpoint called from code at 0x1021376f
you could see the following code concerned
void CCalcRiskPortDlg::OnCalcvar()
{
UpdateData(TRUE);
::CoInitialize(NULL);
//LoadTables Table;
//LoadTables Table2(m_dlgSector);
double *pTabVar=new double[(double)pow(2,m_dlgAsset)];
double *pTabMoy=new double[(double)pow(2,m_dlgAsset)];
CString *pTabPortStr=new CString[(long)pow(2,m_dlgAsset)];
CString strValue,strPortOpti,strMaxiSharpe,strMaxiEfficience;
double MiniVar,MaxiSharpe,MaxiEfficience;
int Rang;
double *pMiniVar=new double[2];
//double *pMiniRatio=new double[2];
double *pMaxiRatioSharpe=new double[2];
double *pMaxiRatioEfficience=new double[2];
int *pTabBinPort=new int[m_dlgAsset];
int *pTabNumPort=new int[m_dlgAsset];
int k,i;
try
{
LoadTables Table(1,m_dlgSector,1,m_dlgSector);
_ConnectionPtr pConnection=NULL;
CString strTemp;
strTemp.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\CalcRiskPort\\Vol&CorrelDB.mdb;");
_bstr_t strCnn(strTemp);
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
pConnection->Open(strCnn,"","",adConnectUnspecified);
Table.pCorrel=Table.LoadCorrelation(m_dlgSector,Table.pCorrel,"Correlation");
Table.pVol=Table.LoadVolatility(m_dlgSector,Table.pVol,"Volatilité");
Table.pYield=Table.LoadYield(m_dlgSector,Table.pYield,"Ratio");
i=0;
for(k=0;k<=m_dlgAsset-1;k++)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
}
*pTabVar=Table.CalcVar(pTabNumPort,m_dlgAsset);
*pTabMoy=Table.CalcMoy(pTabNumPort,m_dlgAsset);
Table.pRatioSharpe[0]=(*pTabMoy)/(*pTabVar);
Table.pRatioEfficience[0]=((*pTabMoy+i)-m_dlgRate0)/(*pTabVar);
*pTabPortStr=Table.AgregIntToStr(pTabNumPort,m_dlgAsset);
for(i=1;i<=pow(2,m_dlgAsset)-1;i++)
{
k=m_dlgAsset-1;
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
if(k!=0)
k--;
}
*(pTabBinPort+k)=1;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
*(pTabMoy+i)=Table.CalcMoy(pTabNumPort,m_dlgAsset);
Table.pRatioEfficience[i]=(*(pTabMoy+i))/(*(pTabVar+i));
Table.pRatioSharpe[i]=((*(pTabMoy+i))-m_dlgRate0)/(*(pTabVar+i));
*(pTabPortStr+i)=Table.AgregIntToStr(pTabNumPort,m_dlgAsset);
}
pMiniVar=Table.CalcMin(pTabVar,pMiniVar,(long)pow(2,m_dlgAsset));
pMaxiRatioSharpe=Table.CalcMax(Table.pRatioSharpe,pMaxiRatioSharpe,m_dlgAsset);
pMaxiRatioEfficience=Table.CalcMax(Table.pRatioEfficience,pMaxiRatioEfficience,m_dlgAsset);
MiniVar=pMiniVar[0];
MaxiSharpe=pMaxiRatioSharpe[0];
MaxiEfficience=pMaxiRatioEfficience[0];
Rang=(int)pMiniVar[1];
m_dlgValue=pTabVar[Rang];
m_dlgValue *=100;
m_dlgPortOpti=*(pTabPortStr+Rang);
strPortOpti=m_dlgPortOpti;
m_dlgSharpe=MaxiSharpe;
m_dlgEfficience=MaxiEfficience;
strMaxiSharpe.Format("%.5f",m_dlgSharpe);
strMaxiEfficience.Format("%.5f",m_dlgEfficience);
strValue.Format("%.5f",m_dlgValue);
CEdit* PEdit=(CEdit*)GetDlgItem(IDC_VALUE);
PEdit->SetWindowText(strValue);
CEdit* SEdit=(CEdit*)GetDlgItem(IDC_OPTI_PORT);
SEdit->SetWindowText(strPortOpti);
CEdit* ShEdit=(CEdit*)GetDlgItem(IDC_OPTI_SHARPE);
ShEdit->SetWindowText(strMaxiSharpe);
CEdit* EffEdit=(CEdit*)GetDlgItem(IDC_OPTI_EFFICIENCE);
EffEdit->SetWindowText(strMaxiEfficience);
delete []pMiniVar;
delete []pMaxiRatioSharpe;
delete []pMaxiRatioEfficience;
delete []pTabBinPort;
delete []pTabNumPort;
delete []pTabVar;
delete []pTabMoy;
pConnection->Close();
}
catch(_com_error &e)
{
AfxMessageBox("a pas bon");
}
::CoUninitialize();
// TODO: Add your control notification handler code here
}
so i hope that someone could help me to solve my problem
thanks in advance for your answers
gerald
|
|
|
|
|
The error is most likely due to some out-of-bounds error: your code is trying to write beyond the limits of some of your arrays.
When the assertion pops up, press "Retry" to get the debugger to the point where the error showed and use the "Call stack" window to determine which buffer is being overrun. This and a little research of your write operations will hopefully locate the error.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
you were right, in fact i declare a wrong memory space for only one pointer that have to be deleted by the class destructor, but there was a problem as when i put value to this pointer, i did it in a for loop, in which i would like to put more that ten times memory spacxe than i have allocated.
thanks a lot
gerald
|
|
|
|
|
Hi, need a hand !
(This message is lot but really easy to read )
I have a project with 2 classes. First is a normal class :
class __declspec(dllexport) Demo
{
public:
int valeur;
Demo(int x=0);
int getValue();
void setValue(int x);
};
My second class is a template :
template <class t="">
class __declspec(dllexport) Element
{
public:
T element;
public:
Element(T);
~Element();
void setElement(T);
T getElement();
};
I have an other project using those two classes. Here's the MAIN function :
#include <iostream.h>
#include "..\test_DLL\test.h"
void main()
{
Demo obj;
obj.setValue(15);
cout << obj.getValue() << endl;
Demo obj2(21);
cout << obj2.getValue() << endl;
Element<int> e1(15);
e1.setElement(15);
cout << "Valeur : " << e1.getElement() << endl;
}
Simple, right ? Here's the errors :
test.obj : error LNK2001: unresolved external symbol "public: __thiscall Element<int>::~Element<int>(void)" (??1?$Element@H@@QAE@XZ)
test.obj : error LNK2001: unresolved external symbol "public: int __thiscall Element<int>::getElement(void)" (?getElement@?$Element@H@@QAEHXZ)
test.obj : error LNK2001: unresolved external symbol "public: void __thiscall Element<int>::setElement(int)" (?setElement@?$Element@H@@QAEXH@Z)
test.obj : error LNK2001: unresolved external symbol "public: __thiscall Element<int>::Element<int>(int)" (??0?$Element@H@@QAE@H@Z)
Debug/test.exe : fatal error LNK1120: 4 unresolved externals
It seems that it cannot find the definition of those functions. It is not the path of my *.LIB of anything else since I don`t have any errors about the DEMO class. If I put the use of the class ELEMENT in commentaries, it is working fine. It seems to be related to the TEMPLATE.
Can we use templates in a DLL ? May be not after all... I`ve search the web and didn`t find any answers. Thk for taking the time to read this ! Hope somebody will help me on that one...
|
|
|
|
|
Hello Frederic.
The good news: You can use templates exported thru a DLL.
The bad news: You must know in advance for which particular types the template class is going to be used.
The procedure is as follows (I'll use your template class instantiated for int s): In some .cpp in your DLL, explicitly instantiate the template like this:
template class__declspec(dllexport) Element<int>; This produces the actual code for Element<int> . Now, in the header file add this:
extern template class __declspec(dllimport) Element<int>; which tells the linker that Element<int> is instantiated somewhere else (extern ) and will be linked at run-time from a DLL (__declspec(dllimport) ). I hope I haven't made any syntax error. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Everything is working fine. But, I have 3 friends functions in this class :
friend ostream& operator << (ostream&, ListeChaineSimple&);
friend ListeChaineSimple& operator << (ListeChaineSimple&, const T&);
friend ListeChaineSimple& operator >> (ListeChaineSimple&, const T&);
And, compiling the EXE gives me those error :
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator>>(class ListeChaineSimple<int> &,int const &)" (??5@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class ListeChaineSimple<int> &)" (??6@YAAAVostream@@AAV0@AAV?$ListeChaineSimple@H@@@Z)
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator<<(class ListeChaineSimple<int> &,int const &)" (??6@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
is it the same thing ? I`ve tried this in the DLL project :
template class __declspec(dllexport) ostream& __cdecl operator<< (ostream&, ListeChaineSimple<int>&);
template class __declspec(dllexport) ListeChaineSimple<int>& __cdecl operator<< (ListeChaineSimple<int>&, int const&);
template class __declspec(dllexport) ListeChaineSimple<int>& __cdecl operator>> (ListeChaineSimple<int>&, int const&);
It compiles fine but the EXE will not work. Anyone ?
|
|
|
|
|
Is ListeChaineSimple a template class? If it is not, then add this to your header:
__declspec(dllimport) ostream& __cdecl operator<< (ostream&, ListeChaineSimple&); and this to your .cpp :
__declspec(dllexport) ostream& __cdecl operator<< (ostream&, ListeChaineSimple&)
{
...
} (and similarly for the other operators.) In this case, thos global friend s can be treated as regular functions you export the usual way.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Actually, it is a template class. Here`s the code in the *.H :
template <class t=""> class __declspec(dllexport) ListeChaineSimple
{
public:
ElementSimple<t> * head;
ListeChaineSimple(T =0);
virtual ~ListeChaineSimple();
friend __declspec(dllexport) ostream& operator << (ostream&, ListeChaineSimple&);
friend __declspec(dllexport) ListeChaineSimple& operator << (ListeChaineSimple&, const T&);
friend __declspec(dllexport) ListeChaineSimple& operator >> (ListeChaineSimple&, const T&);
};
I followed your advice :
typedef ListeChaineSimple<int> LCS_int;
template __declspec(dllexport) ostream& operator<< (ostream&, LCS_int&);
template __declspec(dllexport) LCS_int& operator<< (LCS_int&, const int&);
template __declspec(dllexport) LCS_int& operator>> (LCS_int&, const int&);
Compilation is good. But running it from my application with the DLL, I'm having this error :
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator>>(class ListeChaineSimple<int> &,int const &)" (??5@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class ListeChaineSimple<int> &)" (??6@YAAAVostream@@AAV0@AAV?$ListeChaineSimple@H@@@Z)
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator<<(class ListeChaineSimple<int> &,int const &)" (??6@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
Debug/TP3_EXE.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
I've made a LOT of tests... Everything is fine but this case, there`s something I`m missing. Do you know what exactly ? Thanks in avanced...
|
|
|
|
|