|
|
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...
|
|
|
|
|
Seems some '<' s are missing (your template definitions lack the parameters list). Please try reposting your message with the checkbox "Display this message as-is (no HTML)" set on. Thanx.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi again,
You`re right. I didn`t notice it. Here`s the code :
In the DLL Project :
A) DEMO.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&);
};
B) DEMO.CPP
template <class T>
ostream& operator << (ostream& out, ListeChaineSimple<T>& liste)
{
...
}
template <class T>
ListeChaineSimple<T>& operator << (ListeChaineSimple<T>& liste, const T& x)
{
...
}
template <class T>
ListeChaineSimple<T>& operator >> (ListeChaineSimple<T>& liste, const T& x)
{
...
}
AND
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&);
In the application Project :
TEST.CPP :
#include "..\demo_dll\demo.h"
void main()
{
...
ListeChaineSimple<int> liste(4);
liste << 6;
liste << 8;
liste << 10;
liste << 15;
cout << liste;
liste >> 6;
liste >> 4;
liste >> 2;
cout << liste;
...
}
The errors :
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 know it should be something stupid but I can`t figure it out... Thk in advanced !
|
|
|
|
|
Please check these two things:- The header
demo.h must read __declspec(dllexport) when building the DLL and __declspec(dllimport) when using it in the program test.cpp . I guess you already knew that and didn't bother to specify in your post. The standard technique to have this done is with some macro hackery.
- Provided the first point is not the issue, then maybe you're having problems explicitly instantiating the functions. Try forcing an implicit instantiation:
void __declspec(dllexport) dummy()
{
typedef ListeChaineSimple<int> LCS_int;
LCS_int liste:
int n;
ofstream ofs("quelque chose");
ofs<<liste;
liste<<n;
liste>>n;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
can anybody tell me if there's a way to insert a bmp as a background for a dialog, i can make a pic control and stretch it to fit the dialog and insert the bmp on it, but i was wondering if there's another way, thanks in advance....
|
|
|
|
|
Handle WM_ERASEBKGND
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
You can also handle WM_CTLCOLOR
Ex: You have a bitmap resource as IDB_BITMAP1
1. In OnInitDialog(), use the code:
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);
m_brush.CreatePatternBrush(&bm);
bm.DeleteObject();
with m_brush is member variable of Your dialog class
2. Handle WM_CTLCOLOR (not return hbr)
pDC->SetBkMode(TRANSPARENT);
return m_brush;
//return hbr;
3. Destroy m_brush in DestroyWindow()
Good luck
Hung Son
|
|
|
|
|
I've run out of ideas trying to track this problem down.
I've created a template class and have a private member variable called m_MSGList.
typedef CTypedPtrList<CPtrList, MSG*> tplMSG;
template <class T> class CD : public CWinThread
{
.
.
.
private:
tplMSG m_MSGList;
}
--------------------------------
When this line of code executes:
m_MSGList.AddTail(pmsg);
I get:
ASSERT_VALID fails with illegal vtable pointer.
--------------------------------
help.
|
|
|
|
|