|
means:
int m;
if (Addr)
{
m = 1;
}
else
{
m = 5;
}
check Addr (? -> check)
if its true use first expression (1)
else use second one (5)
|
|
|
|
|
X1 ? answer1 : answer2
If X1 is true the expression will return answer1, if it is not it will return answer2 and I think you are new so see C++ Reference[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
This line of code first evaluates the condition 'Addr == true'.
Then, if the condition is true assigns 1 to m, otherwise asssigns 5 to it.
|
|
|
|
|
the ?: is a ternary operator(takes three operands), which is known as Conditional Operator. Its the simplified form of a simple if statement. Check the MSDN Link[^] for more info.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
It actually means you need a good C tutorial.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
How to calculate inverse of a matrix, i am using vc++ 6.0 ,
|
|
|
|
|
I'll guess you may have to write a program to do that, without regards to what version of Visual C++ you are using.
A little more clarity on your query, may be?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well, homeworks are meant to be done by your brain, not by codeproject. Refer this code snippet[^] and try to write by your own. Hope it helps!
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Numerical recipes in C book [^] may help.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hey there,
I am using a CProgressBar to show the progress of several checksum operations. There are 3 of them, md5, sha1, and sha2, and they are done sequentially. I want to reset the progress bar just before each calculation, but I can't get the progress bar to redraw. Here is a snippet of what I am trying to do:
if(m_checksumPPage.isMD5Checked()) {
progbar.Invalidate();
progbar.UpdateWindow();
progbar.SetPos(0);
hash.domd5(progbar);// do the hash, which also updates the progbar to 100
}
if(m_checksumPPage.isSHA1Checked()) {
mprogbar.Invalidate();
progbar.UpdateWindow();
progbar.SetPos(0);
hash.dosha1(progbar);// do the hash, which also updates the progbar to 100
}
if(m_checksumPPage.isSHA256hecked()) {
progbar.SetPos(0);
progbar.Invalidate();
progbar.UpdateWindow();
hashsha2.do(progbar);
}
The hash.doxxx(progbar) methods will increment the progbar from 0 to 100 and leave it there when it finishes. The first time through it works fine, but the attempt to reset the progbar to zero for the second and third pass does not move the bar back to zero. I guess I am leaving out some sort of update message someplace, but I can't figure it out.
The progress bar is a CProgressCtrl and it is on a dialog box.
Any ideas?
Paul
|
|
|
|
|
Two out of three of your operations call SetPos after UpdateWindow().
I would start by calling SetPos() THEN invalidating/updating the window.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the reply.
I have tried rearranging that code several different ways, along with trying to StepIt backwards to zero, resetting the range, and calling Invalidate/UpdateWindow on the entire dialog, as well as experimenting with overriding the main apps OnIdle to do continuous updates. Nothing has worked so far.
|
|
|
|
|
Either the operation is going faster than you can see it or you've
messed something up somewhere else.
This works for me on XP and Vista, from the UI thread with no
Invalidate/UpdateWindow necessary:
m_ProgressCtrl.SetRange(0,10);
for (int i = 0; i <= 10; i++)
{
m_ProgressCtrl.SetPos(i);
::Sleep(750);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The first operation works fine for me. Its the second and third that don't. Modify your snippet by copying/pasting it three times, and see if the pbar will reset to zero each time. That is the situation I am trying to fix.
I am glad you mentioned the speed thing. I checked that and verified it is not the speed. That would have been very dumb to miss.
|
|
|
|
|
This works here:
m_ProgressCtrl.SetRange(0,10);
for (int i = 0; i <= 10; i++)
{
m_ProgressCtrl.SetPos(i);
::Sleep(500);
}
for (int i = 0; i <= 10; i++)
{
m_ProgressCtrl.SetPos(i);
::Sleep(500);
}
for (int i = 0; i <= 10; i++)
{
m_ProgressCtrl.SetPos(i);
::Sleep(500);
}
I also tried range 0-1000 with no Sleep() call...
went so fast I couldn't see the second and third loops
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This is interesting. I tried pasting your code in there, and it did work the way I want, resetting to zero each time. Playing around with the Sleep values, loop size and range, I get some funky update behaviors. If you experiment with this you might see what I mean. It seems as though there is some threshold at which the redrawing of the control can't keep up with the actual state of the control.
const int limit = 1000;
const int sleep = 3;
m_checksumProgressCtrl.SetRange(0,limit);
for (int i = 0; i <= limit; i++)
{
m_checksumProgressCtrl.SetPos(i);
::Sleep(sleep);
}
for (int i = 0; i <= limit; i++)
{
m_checksumProgressCtrl.SetPos(i);
::Sleep(sleep * 2);
}
for (int i = 0; i <= limit; i++)
{
m_checksumProgressCtrl.SetPos(i);
::Sleep(sleep * 4);
}
After this experiment I realize that I should probably do my checksum stuff in a separate thread. My test case was much too small to really reflect what I need to do, and the UI goes completely unresponsive during the loops (or the checksumming), which really won't work in the real world. I am going to have to rethink my approach. Thanks for the help, Mark.
|
|
|
|
|
Also note that my example is for demonstration only...any truly lengthy operation
should be done on a thread separate from the UI thread, otherwise there's no guarantee
of good results...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I want to change control panel settings in Windows Vista(control panel>ease of access center>optimize visual display>make the focus rectangle thicker).
For this particular settings following values 'FocusBorderHeight' and 'FocusBorderWidth' at "HKCU\Control Panel\Desktop" changes in Windows registry.
But when i changed these values settings were not getting changed.
Does anyone has idea how to change this particular control panel settings in Windows Vista.
Thanks in Advance!!
|
|
|
|
|
Is Control Panel applet[^] helpful?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Thanks for your kind concern but it isn't very helpful.
Actually i am looking where would OS store the changed settings for "control panel>ease of access center>optimize visual display>make the focus rectangle thicker". I have gone through registry but could not find it
Thanks again
|
|
|
|
|
Hi everyone,
Right now, I'm working at a project that change it to support B/S mode. That is, user can do something by WebBrowser to invoke some functionality of C++ app, and I don' wanna make too complicated. The original C++ app don't support B/S, Is there any thirtd-party library to do that?Anyone tell me how to do that in more earier way?
If using SOCKET, I think that need to make a parser to analysizing middle-protocol, but this progress will spend much more time and quite complicated.
Any suggestion?
Thanks.
|
|
|
|
|
|
HI all,
i m using LoadImage function to load image for printing.
i u using this.
CDC* pDC;
CPrintInfo* pInfo;
Cstring file_name;
CBitmap bitmap;
int maxw = pDC->GetDeviceCaps(HORZRES);
int maxh = pDC->GetDeviceCaps(VERTRES);
pInfo->m_rectDraw.SetRect(0, 0, maxw, maxh);
if(!bitmap.Attach(::LoadImage(
::GetModuleHandle(NULL), file_name, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE)))
{
AfxMessageBox(_T("Error loading bitmap!"));
return;
}
BITMAP bm;
bitmap.GetBitmap(&bm);
int w = bm.bmWidth;
int h = bm.bmHeight;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
memDC.SetMapMode(pDC->GetMapMode());
pDC->SetStretchBltMode(HALFTONE);
pDC->StretchBlt(0, 0, maxw, maxh, &memDC, 0, 0, w, h, SRCCOPY);
memDC.SelectObject(pBmp);
its not able to load image.Please tell me how can i do this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
modified on Monday, December 29, 2008 12:40 AM
|
|
|
|
|
If you like easy work you can use of CImage class instead this code CImage works with Bmp,Jpg,png,gif,tiff and it has (StretchBlt,GetHeight,GetWidth,...) and other functions that you need to them.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
With the help of these function can i able to load image of form at .jpg,.png,.gif
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|