|
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
|
|
|
|
|
Load is easy like this:
#include atlImage.h
CImage m;
m.Load(_T("c:\\1.jpg"));
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,
i m create a Rect on left top of page i want to show picture in this rect its display but not correctly or not full picture display in this rect.
how can i fit the image according to rect size.
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 1:56 AM
|
|
|
|
|
You have this line on your code:
if(!bitmap.Attach(::LoadImage(
::GetModuleHandle(NULL), filename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE))) {
AfxMessageBox(_T("Error loading bitmap!")); return;
}
change to it:
CImage m;
m.Load(_T("c:\\1.jpg"));
....
....
....
if(!bitmap.Attach(m_.Detach()))
{
AfxMessageBox(_T("Error loading bitmap!")); return;
}
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,how can i cenert fitted this image in rect.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You can refer to Print Bitmaps without Doc/View Framework[^] for calculate image on the paper.
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 )
|
|
|
|
|
my application crashes while I push_back a value of type POSITION.
I checked the call stack. The parameter to the insert function(push_back calls insert) was something else other than POSITION type.
How?
What could be the problem?
Please help!!
|
|
|
|
|
Can you post some code? Its hard to dig in to unseen
BTW did you read Survive The Release Version[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
This code is used for holding the text selection made by the user.
CCursorPos is used for holding the cursor position.
class CCursorPos
{
public:
CCursorPos()
{
invalidate();
}
CCursorPos(const CCursorPos& pos)
{
*this = pos;
}
BOOL isValid() const
{
return (m_posItem!=NULL && m_textPos.x > -1 && m_textPos.y > -1);
}
CCursorPos& operator=(const CCursorPos& pos)
{
ASSERT(pos.isValid());
setCursor(pos.getItem(),pos.getTextPoint());
return *this;
}
BOOL operator==(const CCursorPos& pos) const
{
ASSERT(isValid());
ASSERT(pos.isValid());
return (getItem() == pos.getItem() &&
getTextPoint() == pos.getTextPoint());
}
BOOL operator!=(const CCursorPos& pos) const
{
return !(*this == pos);
}
POSITION getItem() const
{
ASSERT(isValid());
return m_posItem;
}
const CPoint& getTextPoint() const
{
ASSERT(isValid());
return m_textPos;
}
void invalidate()
{
m_textPos.x = m_textPos.y = -1;
m_posItem = NULL;
}
void setCursor(const POSITION& pos, const CPoint& ptText)
{
m_textPos = ptText;
m_posItem = pos;
ASSERT(isValid());
}
protected:
CPoint m_textPos;
POSITION m_posItem;
};
........
class COutlineTextView
{
.....
CCursorPos m_selStart, m_selEnd;
std::vector<POSITION> m_selection;
....
};
void COutlineTextView::prepareSelBounds()
{
if (m_selection.size() > 0){
m_selection.clear();
}
.....
POSITION pos = m_selStart.getItem();
while(pos != NULL && pos != m_selEnd.getItem())
{
m_selection.push_back(pos);
pos = getOutline()->getNext(pos);
}
ASSERT(pos);
m_selection.push_back(m_selEnd.getItem());
...
}
The call stack:
> Desktop.exe!_crt_debugger_hook(int _Reserved=3144168) Line 65 C
Desktop.exe!_invalid_parameter(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0) Line 112 + 0x7 bytes C++
Desktop.exe!_invalid_parameter_noinfo() Line 125 + 0xc bytes C++
Desktop.exe!std::_Vector_const_iterator<unsigned long,std::allocator<unsigned long> >::operator+=(int _Off=0) Line 160 + 0x14 bytes C++
Desktop.exe!std::_Vector_iterator<unsigned long,std::allocator<unsigned long> >::operator+=(int _Off=0) Line 376 C++
Desktop.exe!std::_Vector_iterator<int,std::allocator<int> >::operator+(int _Off=0) Line 382 + 0xc bytes C++
Desktop.exe!std::vector<CTreeData *,std::allocator<CTreeData *> >::insert(std::_Vector_const_iterator<CTreeData *,std::allocator<CTreeData *> > _Where=..., CTreeData * const & _Val=0x017d6b20) Line 878 + 0x1b bytes C++
Desktop.exe!std::vector<CTreeData *,std::allocator<CTreeData *> >::push_back(CTreeData * const & _Val=0x017d6b20) Line 824 C++
Desktop.exe!COutlineTextView::prepareSelBounds() Line 4817 C++
Desktop.exe!COutlineTextView::setSelection(const CCursorPos & selStart={...}, const CCursorPos & selEnd={...}) Line 4857 C++
Desktop.exe!COutlineTextView::OnMouseMove(unsigned int nFlags=1, CPoint point={...}) Line 168 C++
Desktop.exe!COutlineEditView::OnMouseMove(unsigned int nFlags=1, CPoint pointMove={...}) Line 2935 C++
Desktop.exe!CWnd::OnWndMsg(unsigned int message=512, unsigned int wParam=1, long lParam=13254392, long * pResult=0x002ffcd0) Line 2062 C++
I replaced vector with CArray. But caused a crash after OnMouseMove() function was fully executed.
|
|
|
|
|
I see exactly the same problem in my code.
This problem occurred when I migrated to visual studio 2008 and attempted to execute the code using a release build.
The same code does not crash in debug build in VS 2008.
Has anyone been able to figure out the cause of the problem?
Thanks
David Schumaker
|
|
|
|
|
Good day,
Were you able to fix your problem ? I'm having the same kind of problem when porting to VS2008.
Thanks.
Max.
This signature was proudly tested on animals.
|
|
|
|
|
I had the same problem when porting from VS2005 to VS2008.
I avoided it using dynamic allocation something like this:
std::vector *v;
v = new ???;
v->push_back(***)
This works in both debug and release mode ^^
|
|
|
|
|
typedef void *HANDLE;
is there a type "HANDLE" in Visual c++?
i could not find any information about this type?
Thanks
|
|
|
|