|
Hi John,
*itr is a double.
The format string that you are using in "Node Energy: %d \n", which formats an int.
You need to use "Node Entry: %lf \n".
Best regards,
John
|
|
|
|
|
Thanks for the suggestion.
I tried that, but I kept getting 0.00000, so I looked up
c++ format specifiers.
I discovered that
TRACE("Node Energy: %e\n", *itr);
works perfectly.
|
|
|
|
|
Hi,
I have a dialog that have a bitmap as background. When I put control on the dialog, I can see the surrounding white rectangle around the controls. Is there a way to see my background around the controls and not the white rectangle?
for example, suppose that I have a CStatic with text in it, is there a way to to see the bitmap behind the text?
thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Does enabling the Transparent property (when right-clicking on the control in the ressource editor) change something ?
~RaGE();
|
|
|
|
|
No, enabling the transparent property don't change anything. I have been able to make it work throught OnPaint() redefinition in a CStatic control, but I cannot use to make it work for other controls such as CButton (radio button)
for CStatic, in the OnPaint of the control you can use:
dc.setBkMode(TRANSPARENT)
dc.DrawText(...)
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Try adding a handler for OnEraseBkgnd and either doing nothing or erasing the background with a hollow brush. ex:
BOOL MyDialog::OnEraseBkgnd( CDC* pDC )
{
return TRUE;
}
|
|
|
|
|
Well,
I doesn't seem to work, I also tried to use:
HBRUSH RightDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = ShapedDlg::OnCtlColor(pDC, pWnd, nCtlColor);
if ( pWnd->GetDlgCtrlID() == IDC_RADIO1)
{
// m_bkbrush is a CBrush member variable
m_bkbrush.CreateStockObject(HOLLOW_BRUSH);
pDC->SetBkMode ( TRANSPARENT );
return m_bkbrush;
}
return hbr;
}
If I use BLACK_BRUSH, I will see a black background if I use GREY_BRUSH I will see grey background, but HOLLOW_BRUSH give me a strange blue background.
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Hi
Any one have a link to a free electronic book cover Drivers for Win 2000 & Hook Drivers
Please
Thanks Very much
|
|
|
|
|
Dear All,
I am developing a security/recovery software (in MFC, Visual C++ for Windows 2000/XP/NT).
Presently I am storing password for opening my application in Registry key.
=>ie.HKEY_LOCAL_MACHINE\SOFTWARE\MyApplication\Settings.
But I feel that this key can easily be hacked. And anybody can easily delete this key.
My question is:
1) How can I change the security settings of my password registry key so that any user may not be
able to open or delete key ?
2) Are there any other secure methods to store the passwords? Can we store password in .sys file
which are always in memory ???
Please give your useful suggestions.
Thanks in advance!
Rohit Dhamija
|
|
|
|
|
Hi,
storing passwords is never a good idea. And most passwords are so short, that even the best encryption must fail.
One method I use, is not to store the password, but doing three to five different calculations with the password and the user name, and store these results.
When the user logs in, the computation is done again, and the results are compared with the stored values.
If you do the calculation with non commutative operators like -(minus) or matrix multiplications, you can't tell the the password. Never.
Care must be taken, to avoid that similiar passwords create similiar results.
for instance:
Make all inputs the same length by repeating the input/password till all spaces are filled. Then XOR all characters with a given string. Now do adding and substracting of the characters like : result += (3*XORinput[i] -5*XORpassword[i] + 7*somestring[i]), where i is running from 0 to the string length minus 1.
By exchanging the operators(+/-) and constant factors(3,5,7) you get different results, some positve and negative. Store these results. And only when all results match, the identification is verified.
G. Steudtel
|
|
|
|
|
G. Steudtel wrote:
Care must be taken, to avoid that similiar passwords create similiar results.
Better use one-way hash functions. These have been proven to be mathematically hard, or at least you know how much cmpute-power one need to break them.
A lot of free implementations are somewhere out there.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi,
i have plenty of errors in my code. Help Plz
void trl_calculation(int amount, unsigned char*pData, unsigned char sl)
{
unsigned char NrTrlValues;
unsigned char location;
unsigned char perc;
unsigned char time;
unsigned char *realTrlValues = NULL;;
pTrlValues = (unsigned char*) malloc(amount*sizeof(unsigned char)); //error C2440, error C2106:
for (int i=1; i < amount; i++)
{
pTrlValues[i] = (unsigned char) pData[location]; //error C2109:
if
((pData[location] - sl < 0) && (pData[location + 1] - sl ) > 0)||
((pData[location] - sl > 0) && (pData[location +1 ] - sl < 0)) //error C2143
perc = (sl - pData[location])/(pData[location + 1]) - pData[location];
time = location * 0.00000001923 + (((location * 0.00000001923) + 1) - (location * 0.00000001923))* perc;
//warning C4244
if
pData[location] - sl =0;//error C2061
pTrlValues [i] = location * 0.00000001923;//error C2109, warning 4244,error C2106:
realTrlValues[i] = pTrlValues[i+1] - pTrlValues[i];
//error C2106,arning4244
}
}
void histogram (long amount,unsigned char pTrlValues,unsigned char NrTrlValues)
{
int i_index;
const double Duration = amount/4096;
double histogram_ram[4096];
pTrlValues = (unsigned char*) malloc(amount*sizeof(unsigned char));//error C2440
for (int i=1; i <= amount; i++)
{
i_index = static_cast< unsigned int >(ceil(pTrlValues[i]/Duration)) + 1;//error C2109
histogram_ram[i_index]=histogram_ram[i_index]+1;
}
}
error C2440: '=' : cannot convert from 'unsigned char *' to 'unsigned char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
error C2109: subscript requires array or pointer type
error C2106: '=' : left operand must be l-value
error C2143: syntax error : missing ';' before '||'
warning C4244: '=' : conversion from 'double' to 'unsigned char', possible loss of data
error C2061: syntax error : identifier 'pData'
error C2109: subscript requires array or pointer type
warning C4244: '=' : conversion from 'double' to 'unsigned char', possible loss of data
error C2106: '=' : left operand must be l-value
error C2109: subscript requires array or pointer type
(625) : error C2109: subscript requires array or pointer type
warning C4244: '=' : conversion from 'int' to 'unsigned char', possible loss of data
error C2440: '=' : cannot convert from 'unsigned char *' to 'unsigned char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
error C2109: subscript requires array or pointer type
F.K
|
|
|
|
|
flora_k wrote:
unsigned char NrTrlValues;
unsigned char location;
unsigned char perc;
unsigned char time;
These all are very probably meant to be pointers. That is what the compiler keeps telling you. The other errors are most probably coming from this one.
So please declare your variables as pointers to unsigned chars (instead of as unsigned char itself) and report back.
[EDIT]
Maybe using a string class like CString (of MFC) or std::string (plain standard C++) can help you.
And if writing a C++ program for Win32, you should never need to use malloc at all. In C++ use new and delete .
[/EDIT]
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
It gets worse, i get more errors in addition to the previous one
F.K
|
|
|
|
|
My fault, sorry.
Ok, lets start. You do not show much code, but I try anyway:
What is pTrlValues ? A member variable? What type? Is it unsigned char ?
Where do you assign memory to realTrlVaues ? You initialiy set it to NULL , but where do you get the memory to place the differences of TrlValues you compute?
Why do you assign the result of your complicated computation with double s to time , of type unsigned char , which can only hold 0..255?
Your if s look wiered: Make them look like this:
if ( expression )
{
...stuff..
}
else
{
..stuff..
}
That means, have the expression you want to test between ( and ) and the thing you want to run in { and }.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi !
To jhwurmbach:
Just to explain ... flora_k is a begginer trying to convert Matlab code to VC++ with only few knowledge of the language. So do not ask about where things happen (initialisations, memory) but show him/her directly how to do it.
I posted some code in a previous thread. Might check it to get the whole idea of the program.
To flora_k:
Do not take my remark badly , it is only to help you. If you want, you can post me your matlab code zipped with a small description of what you want it to do, and I'll be glad to translate it (if it is not too long).
~RaGE();
|
|
|
|
|
hi,
the address forums@codeproject.com is not working.
The message keeps coming back.
Can i get another one?
F.K
|
|
|
|
|
Two ways :
Instead of clicking reply to reply to the post, click mail.
~RaGE();
Last modified: 50155hrs 6mins after originally posted --
|
|
|
|
|
Pointers have to be declared :
unsigned char *pTrlValues = (unsigned char *)malloc(amount*sizeof(unsigned char));
flora_k wrote:
pTrlValues[i] = (unsigned char) pData[location]; //error C2109:
Be careful, location is used without being assigned a value !
What is pData ?
flora_k wrote:
if
((pData[location] - sl < 0) && (pData[location + 1] - sl ) > 0)||
((pData[location] - sl > 0) && (pData[location +1 ] - sl < 0)) //error C2143
perc = (sl - pData[location])/(pData[location + 1]) - pData[location];
time = location * 0.00000001923 + (((location * 0.00000001923) + 1) - (location * 0.00000001923))* perc;
//warning C4244
if
pData[location] - sl =0;//error C2061
pTrlValues [i] = location * 0.00000001923;//error C2109, warning 4244,error C2106:
In C/C++, the if statements are used that way :
if (condition)
{
do some stuff.
}
In your case :
if (
((pData[location] - sl < 0) && (pData[location + 1] - sl ) > 0)||
((pData[location] - sl > 0) && (pData[location +1 ] - sl < 0)) )
{
perc = (sl - pData[location])/(pData[location + 1]) - pData[location];
time = location * 0.00000001923 + (((location * 0.00000001923) + 1) - (location * 0.00000001923))* perc;
}
~RaGE();
|
|
|
|
|
can someone tell me how can i get a DataSet and put it into a RecordSet?
if u know this please help me.
thanks
Nuno Henrique Mendes
|
|
|
|
|
Are you talking about .NET Datasets?
If so, you may never want to do that. However use something like this:
DataView dv = MyDataSet.Tables ["MyTableName"].DefaultView;
Now you can use dv just like a normal recordset.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Hi,
can one help me to write the below Matlab code in VC++?
Dura=1000/4096;
Trl =0;
i=1;
for location = 1:length(y)-1
if ((y(location)-sl<0)&(y(location+1)-sl>0))|((y(location)-sl>0)&(y(location+1)-sl<0))
perc = (sl(location) - y(location))/(y(location +1) - y(location)) ;
time = t(location) + (t(location+1)- t(location))*perc;
Trl(i)=time;
i=i+1;
elseif y(location)-sl==0;
Trl(i)=t(location);
i=i+1;
end;
end;
for i=1:length(Trl)-1
realTrl(i)=Trl(i+1)-Trl(i);
end
Trl=realTrl;
histogram_ram(1:4096) = 0;
for i=1:length(Trl)
i_index=round(Trl(i)/Dura)+1;
histogram_ram(i_index)=histogram_ram(i_index)+1;
end;
Thx
F.K
|
|
|
|
|
Let me tell you that your matlab code is not really optimized...
For the following code, you need to put the size of the Trl table in length_y (which has to be declatred as an int).
int Dura = 1000/4096;
int *Trl;
int tmp;
int histogram_ram[4096];
int location;
int perc;
int time;
Trl=(int *)malloc(length_y*sizeof(int));
realTrl=(int *)malloc(length_y*sizeof(int));
for (location=1;location<length_y;location++)
{
if ((y[location]-sl<0)&&(y[location+1]-sl>0))||((y[location]-sl>0)&&(y[location+1]-sl<0))
{
perc = (sl[location] - y[location])/(y[location +1] - y[location]) ;
time = t[location] + (t[location+1]- t[location])*perc;
Trl[location]=time;
}
else if ((y[location]-sl)==0)
{
Trl[location]=t[location];
}
}
for(location=1;location<length_y-1;location++)
{
Trl[location]=Trl[location+1]-Trl[location];
}
for (location=0;location<4096;location++)
{
histogram_ram[location]=0;
}
for (location=1;location<length_y;lcoation++)
{
tmp=(int)(Trl[location]/Dura+1);
hitogram_ram[tmp]++;
}
This has not been tested.
~RaGE();
|
|
|
|
|
I had inserted a Activex control into my project, and put
it on one of my dialog(id: IDD_DIALOG1), then I deleted it
(the class declearation file and implement file and the control on the dialog).The problem comes out:
error C2065: 'IDD_DIALOG1' : undeclared identifier
but please note: I checked my resources and verified that
the dialog(IDD_DIALOG1) is right there.
what have I deleted by mistake?
|
|
|
|
|
ilavl wrote:
I checked my resources and verified that
the dialog(IDD_DIALOG1) is right there.
I had a similar problem like this one long before. I deleted all files in the output dir and then did a re-build. Try that you too!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|