|
 Perhaps you should move to a message based inter-thread communication. You can even pass the percentage of completion.
Try something like this:
#define WM_START_ANIMATION WM_USER + 0x8
#define WM_INC_PROGRESS WM_USER + 0x10
void TestPb::OnButton1()
{
thpbar=AfxBeginThread(thPrgbar,THREAD_PRIORITY_NORMAL,0,0,NULL);
}
UINT TestPb::thPrgbar( LPVOID pParam )
{
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
::PostMessage(pFrame->GetSafeHwnd(),WM_START_ANIMATION,IDR_AVITEST,1);
int iCount;
int iPosition =0;
while(reading DB)
{
int iPercent = iCount * (iPosition / 100.0);
::PostMessage(pFrame->GetSafeHwnd(),WM_INC_PROGRESS,(WPARAM)iPercent,0);
++iPosition;
}
return (1);
}
void CMainFrame::OnStartAnimation( WPARAM id, WPARAM nPane )
{
StopAnimation();
m_pAnimate = new CStatusbarAnimate;
m_pAnimate->Create(id, nPane);
}
void CMainFrame::StopAnimation()
{
if(IsAnimationActive())
{
delete m_pAnimate;
m_pAnimate = NULL;
}
}
bool CMainFrame::IsAnimationActive()
{
return (m_pAnimate != NULL);
}
void CMainFrame::OnUpdateAnimate(CCmdUI* pCmdUI)
{
pCmdUI->SetText(_T(""));
}
Add the following to your CMainFrame
afx_msg LRESULT OnMyProgress(WPARAM wParam, LPARAM lParam);
ON_MESSAGE(WM_INC_PROGRESS,OnMyProgress)
ON_MESSAGE(WM_START_ANIMATION,OnStartAnimation)
LRESULT void CMainFrame::OnMyProgress(WPARAM wParam, LPARAM lParam)
{
int iPercent = (int)wParam;
if(100 == iPercent && IsAnimationActive())
{
StopAnimation();
}
else
{
}
|
|
|
|
|
while (1); not only stops avi to play, but the complete UI on the GUI thread will stop working.
|
|
|
|
|
well, Yes true just i mentioned to as a length process
Thanks u
I want to paly the avi on the mainfram status bar and start some lenthly process, while still the avi is playing... pls advice
|
|
|
|
|
ptr_Electron wrote: well, Yes true just i mentioned to as a length process
Thanks u
I want to paly the avi on the mainfram status bar and start some lenthly process, while still the avi is playing... pls advice
I would run the lengthy operation in a background thread.
Nathan
|
|
|
|
|
HI everyone,
Can someone help me with this.
I founded out that when the recycle bin has a lot of file using the command SHFileOperation to delete file is VERY SLOW!!!!
How can I either fix this or inform the user that since it recycle bin contains (x file, knowing the x threshold would be great )
Thanks anyone!
|
|
|
|
|
Member 3854600 wrote: inform the user that since it recycle bin contains (x file
SHQueryRecycleBin (gives total size, number of items)
Member 3854600 wrote: How can I either fix
SHEmptyRecycleBin (shows progress bar) check this iam not sure.
|
|
|
|
|
OK thanks this is great, but does anybody knows the number X of file in the recycle bin, that causes the SHFileOperation to be slow??
Thanks
|
|
|
|
|
|
SetWindowContextHelpId always fails form dialog and also from base class, Any possible fix ideas please. Dialogs are not MFC generated code
Thanx
|
|
|
|
|
*sigh*
Return Value Returns nonzero if successful, or zero otherwise. To retrieve extended error information, call GetLastError.
led mike
|
|
|
|
|
hi,
can ne one help me how can i wait for file to rename/delete it ??
thanks in advance
|
|
|
|
|
Have a cup of coffee.
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
|
|
|
|
|
Or a tea. 
|
|
|
|
|
Your question is a little too vague. I'm assuming that since you have to wait, the initial attempt to rename/delete has failed. Whether you will now wait or not will entirely depend upon the reason of failure. For example if the failure is permissions, this could be a long wait. If there is a lock on the file, you could wait the file to be unlocked. But again this could be a very long wait.
The coffee answer might hold the best truth.
|
|
|
|
|
Do you want to have a progress bar?
|
|
|
|
|
Hi Experts,
i am writing a shell conext menu. When I click on .lnk file(Link file), I am getting the target file path. How can I get the link file path from target file path?
|
|
|
|
|
CString CDropEdit::ExpandShortcut(CString &inFile)
{
CString outFile;
ASSERT(inFile != _T(""));
IShellLink* psl;
HRESULT hres;
LPTSTR lpsz = inFile.GetBuffer(MAX_PATH);
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*) &psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*) &ppf);
if (SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
::MultiByteToWideChar(CP_ACP, 0, lpsz, -1, wsz, MAX_PATH);
hres = ppf->Load(wsz, STGM_READ);
if (SUCCEEDED(hres))
{
WIN32_FIND_DATA wfd;
HRESULT hres = psl->GetPath(outFile.GetBuffer(MAX_PATH),
MAX_PATH,
&wfd,
SLGP_UNCPRIORITY);
outFile.ReleaseBuffer();
}
ppf->Release();
}
psl->Release();
}
inFile.ReleaseBuffer();
return outFile;
}
from CDropEdit[^]
|
|
|
|
|
Actually this code Resolve the link file path.
I want that can extract the link file path from target file path.
|
|
|
|
|
so, you have a file "Foo.exe" and you want to find all of the shortcuts that point to it ?
|
|
|
|
|
|
i'm 99% sure you can't do that. targets don't know about links to them.
|
|
|
|
|
But we can do a scan in the registry to find out all valid link files pointing to what, and sort the targets to group the identical target.
But ... err ... it takes long time.
WinASO[^] registry optimizer tool does this way (I guess) to remove invalid links (shortcuts and references in registry).
Maxwell Chen
|
|
|
|
|
right, that's the brute force way. (you could also scan all connected drives for .LNK files, resolve them and find those that point to your target!)
but AFAIK there's no simple way to do it, like there is in the standard direction.
|
|
|
|
|
Hi all,
I have written a code in vc6 in which i have written this code for getting a resource handle....
FindResource(NULL,MAKEINTRESOURCE(IDR_IDR_EXE_EXEEXTRACTOR),"IDR_EXE");
now when i am writing this same code in VC2005
it gives an error:-
error C2664: 'FindResourceW' : cannot convert parameter 3 from 'const char [8]' to 'LPCWSTR'
but error is resolved when i add prefix 'L' to my third parameter
FindResource(NULL,MAKEINTRESOURCE(IDR_IDR_EXE_EXEEXTRACTOR),L"IDR_EXE");
now my problem is...
it compiles correctly but at runtime its giving debug assertion failed error.
Is there any other way to Find my resource in VC2005
|
|
|
|
|
It's because UNICODE is enabled by default in VC2005, which was not the case with VC6.
neha.agarwal27 wrote: it compiles correctly but at runtime its giving debug assertion failed error.
Well, you don't provide a lot of usefull information do you ? What is the exact problem ? Where does your code crashes ? Use your debugger to locate the problem more precisely and inspect the state of the different variables before the crash.
|
|
|
|