|
Thanks for the advice, but unfortunately we are not using MFC.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
You don't need to be using MFC - Windows provides a series of functions which are wrapped by the CEvent class in MFC. Look up the following in MSDN for more info;
1. CreateEvent(...)
2. SetEvent(...)
3. ResetEvent(...)
4. WaitForSingleObject(...)
5. CloseHandle(...)
6. DuplicateHandle(...)
Hope this is useful - I think the idea should work anyway.
--
Andrew.
|
|
|
|
|
Cool - this looks VERY promising. I'll have a play at work this morning.
Thank you
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thanks so much - I got this working like a treat and learned a bit of stuff in the process. Can't ask for more than that...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Glad to be of help - cheers !
--
Andrew
|
|
|
|
|
I don't want to pass the CFtpConnection* pointer to a thread proc because that may be dangerous. Although I can get the handle of the FTP connection from the (HINTERNET) operation, I cannot construct a CFtpConnection object from the handle I've got because there's no such function. What should I do? Please help me out.
Thanks in advance.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
I don't know anything about these classes, but I've decided to look into your problem as it appears to be more of a C++ issue than anything else.
The MFC header file for CFtpConnection shows that the class has a couple of constructors. The one you would probably use looks like this:
CFtpConnection(CInternetSession* pSession, HINTERNET hConnected, LPCTSTR pstrServer, DWORD dwContext);
Again, I don't know anything about these parameters but the second one looks like the one you'd be passing from the other thread. If this doesn't work I'd suggest you to derive a class from CFtpConnection. Since m_hConnection is protected in CInternetConnection, you'd have access to it in your derived class.
Good luck!
Alvaro
|
|
|
|
|
Thank you very much!
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Hi,
I'm trying to get my MDI app to use splitter windows:
My ChildFrame class is called CDesignFrame:
I removed the CView derived member and added a CSplitterWnd member instead.
I overrode the CDesignFrame::OnCreateClient and added this:
m_splitWnd.CreateStatic(this,
2,
1,
WS_CHILD | WS_VISIBLE,
AFX_IDW_PANE_FIRST);
SIZE sInitSize;
sInitSize.cx = lpcs->cx;
sInitSize.cy = lpcs->cy / 2;
m_splitWnd.CreateView(0,
0,
RUNTIME_CLASS(CDesignView),
sInitSize,
pContext);
m_splitWnd.CreateView(1,
0,
RUNTIME_CLASS(CDesignView),
sInitSize,
pContext);
CDesignView is simply the default AppWizard created view class. it doesn't do anything yet. All i did to it was declare and implement dyncreate on it.
Anyway. All compiles nicely, but when i run it, clicking file|new causes app to crash with an unhandled exception: Traceing through the app step by step shows the error comes from the CMDIFrameWnd::CreateNewChild function, when it calls pFrame->InitialUpdateFrame(NULL, TRUE);
The docs for InititalUpdateFrame say it'll update all views in the frame window. but there are none. but if i remove this function call, my frame isn't displayed.
I'm a bit lost. How should I do this?
Jon
|
|
|
|
|
|
I finally figured it out... Because I disabled the Doc/View architecture support in appwizard, My CView derived class was in fact CWnd derived.
Part of the InitialUpdateFrame function casts this CWnd Pointer to a CView, and then calls a member function which plainly doesnt exist. This causes the exception.
Nice to have it sorted.
Thanks again
|
|
|
|
|
There are normally three buttons on the right most upper corner of a window
1) Minimize
2) Small / Large
3) Close (cross)
I want to add another button adjacent to these three buttons (supposedly .) that will minimize the application to task bar (adjacent to clock)
How can I possibly add this button?
Maliha
|
|
|
|
|
You'll have to handle WM_NCPAINT. Have a look at Jan'97 issue of MSJ, C++ Q&A column - it has a code that draws custom caption bar. The article should be in the 'Periodicals' section of VC++ help.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
how to list efficiently TIDs (or handles) of all threads
running within a specified process ?
Thanx in advance
Michal Januszczyk
|
|
|
|
|
There's no method that will work on all 32-bit Windows versions. On 9x and 2000 you can use ToolHelp32's Thread32First/Thread32Next. On NT4 you'll have to get perf data with PdhEnumObjects.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I had written a dialog based application.
It contained a button named "Try"
When I clicked the "Try" button,opened an other
dialog named "Test" which contained a button named "Open".
When I first clicked "Open" button and clicked the "OK"
button in Open File Dialog,everything is ok,and then
close the "Test" Dialog.
But When I click "Try" button again,it showed me wrong.
Who can please tell me what's wrong with my code??
******************************************************************
void CFirstDlg::OnButtonTry()
{
// TODO: Add your control notification handler code here
CTestDialog* dlg;
dlg=new CTestDialog;
dlg->DoModal();
}
******************************************************************
BOOL CTestDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString sCon;
_ConnectionPtr m_pCon;
_RecordsetPtr m_pRs;
sCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=main.mdb";
CoInitialize (NULL);
HRESULT hr=S_OK;
try
{
hr=m_pCon.CreateInstance(__uuidof(Connection));
if(FAILED(m_pCon->Open(_bstr_t(sCon),"","",adModeUnknown)))
AfxMessageBox("Can not open the database!");
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("Failed!\r\nError Message:%s",e.ErrorMessage());
AfxMessageBox(errormessage);
}
m_pRs.CreateInstance("ADODB.Recordset");
if(FAILED(m_pRs->Open("SELECT * FROM employeer",_variant_t((IDispatch*)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText)))
AfxMessageBox("Can not open the record set!");
if((m_pRs->State & adStateOpen) == adStateOpen)
m_pRs->Close();
if ( (m_pCon->State & adStateOpen) == adStateOpen)
m_pCon->Close();
CoUninitialize();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
***********************************************************************
void CTestDialog::OnButtonOpen()
{
// TODO: Add your control notification handler code here
static char BASED_CODE szFilter[]="Bitmap Files (*.bmp)|*.bmp||";
CFileDialog *fd;
fd=new CFileDialog(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFilter,this);
if(IDOK!=fd->DoModal())
return;
else
AfxMessageBox(fd->GetFileName());
delete fd;
}
|
|
|
|
|
You didn't delete the dlg object in the CFirstDialog::OnButtonTry(). That should be the problem. Why do you want to use the heap object rather than stack object? If you do it like this:
void CFirstDialog::OnButtonTry()
{
CTestDialog dlg;
dlg.DoModal();
}
you won't be worried about the work of releasing object. I think this form is better.;)
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
The wrong still happened,what should I do?
|
|
|
|
|
So could you send your piece of codes to me? I think looking into the codes will be more clear.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Thank you,under the help of others,I had solved the problem.
Thanks again.
A beginner of Visual C++,and need your help.
|
|
|
|
|
After seeing code,
I think you are not destroying dialog (delete dlg). This should be your problem.
CTestDialog* dlg;
dlg=new CTestDialog;
dlg->DoModal();
////add line...
delete dlg;
--------------------------------------------------
Say Whatever You Know.
Helping other people is good for health.
=========
Manish
=========
---------------------------------------------------
|
|
|
|
|
The wrong still happened.
|
|
|
|
|
Hi All,
I have a line of code
WaitForSingleObject(hSem,INFINITE);
which i want to replace it for some tracing purpouses with
while(1)
{
if(WaitForSingleObject(hSem,300)==WAIT_OBJECT_0)
break;
//A single trace stmt
TRACE(" ");
}
However, if i do this, my CPU utilization runs to 100% in NT.
Am i doing something wrong? Thanks all for ur help.
cheers ... Sriram M R
|
|
|
|
|
I had the same pb in this loop which was implemented in a thread :
while(TRUE)
{
...something to do
}
I found the solution by adding a Sleep() inside the loop like this :
while(TRUE)
{
... your code
Sleep(1); // 0 has no effect
}
Now, is it a bug from Microsoft ?
Hope that can help you.
|
|
|
|
|
i don't really think that this is a bug.. i think it is made per design.. in an endless loop you have to install a wait - object (sleep(1)) so that the other threads have got any chance to handle their messages... (think this is a general window - programming rule.. never use endless loops without a sleep)
i had that problem in some multithreaded programs too.. after insert sleep(1) it worked perfectly..
if anybody else has another workaround you're welcome
bernhard
stolen sig#16:
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
|
|
|
|