|
Hi Joaquín
Thanks for your quick response. I am unable to use the overlapped mode. I mean I am not getting the correct usage syntax.
I simply used stop event as shown below.
UINT CheckFileUpdates(LPVOID lp)
{
//Get the document pointer
CLogViewerAppView* pView = (CLogViewerAppView*)lp;
CLogViewerAppDoc* pDoc = pView->GetDocument();
CFileException err;
CFileStatus st;
CFile::GetStatus(pView->m_LogFilePath,st);
LONG l1,l2;
CFile file;
if( !file.Open(pView->m_LogFilePath, CFile::modeRead|CFile::shareDenyNone, &err ) )
{
TCHAR szCause[255];
err.GetErrorMessage(szCause, 255);
AfxMessageBox(szCause);
return 0;
}
l1 = (LONG)file.GetLength();
file.Close();
CFile file1;
LONG size_1 = (LONG)st.m_size;
int len = pView->m_LogFilePath.GetLength()-pView->m_LogFileName.GetLength()-1;
CString dir = pView->m_LogFilePath.Left(len);
HANDLE hDir = CreateFile( dir, // pointer to the file name
FILE_LIST_DIRECTORY, // access (read/write) mode
FILE_SHARE_READ|FILE_SHARE_WRITE, // share mode
NULL, // security descriptor
OPEN_EXISTING, // how to create
FILE_FLAG_BACKUP_SEMANTICS, // file attributes
NULL // file with attributes to copy
);
FILE_NOTIFY_INFORMATION Buffer[1024];
DWORD BytesReturned;
while( ReadDirectoryChangesW(
hDir, // handle to directory
&Buffer, // read results buffer
sizeof(Buffer), // length of buffer
TRUE, // monitoring option
FILE_NOTIFY_CHANGE_SIZE, // filter conditions
&BytesReturned, // bytes returned
NULL, // overlapped buffer
NULL// completion routine
))
{
if ( WaitForSingleObject(pView->m_StopEvent, INFINITE) == WAIT_OBJECT_0 )
{
OutputDebugString(_T("\n KIIGSRETG \n"));
return 0; //end the thraed
}
CString fileName(Buffer[0].FileName);
fileName = fileName.Left(Buffer[0].FileNameLength / 2);
if(fileName.CompareNoCase(pView->m_LogFileName) == 0)
{
//Do the work
}
}
return 0;
}
But the m_StopEvent event is not caught beacuse the control is stuck at while( ReadDirectoryChangesW) I mean it not going inside the while loop unless ReadDirectoryChangesW returns true. Hence WaitForSingleObject is not checked at all.. Hope you got my point.
Can you please let me know how to write this using OVERLAPPED structure. I never did this before. I am really stuck at this point..unable to proceed further..this is very important for my assignment.
Thanks
Madhavi
|
|
|
|
|
Good Day.
Please, can you give me an example how can I change state of the button with some id? I do like this:
m_wndReBar.Create(this);
m_wndReBar.AddBar(&m_wndToolBar);
...
m_wndToolBar.SendMessage(TB_SETSTATE, ID, MAKELONG(TBSTATE_ENABLED, 0));
...
But nothing changes. What's wrong? Or what another ways exists to change the state?
Nulla dies sine linea !!!
|
|
|
|
|
And if I have a button in ReBar how can I change state of it?
Nulla dies sine linea !!!
|
|
|
|
|
To change the state of button on DialogBar I have used
for Disable
m_wndToolBar.GetDlgItem(IDC_BUTTON)->EnableWindow(FALSE);
for Enable
m_wndToolBar.GetDlgItem(IDC_BUTTON)->EnableWindow(TRUE);
For unPressed
m_wndToolBar.CheckDlgButton(IDC_BUTTON,BST_UNCHECKED);
For Pressed
m_wndToolBar.CheckDlgButton(IDC_BUTTON,BST_CHECKED);
I thing it will also work for Rebars
|
|
|
|
|
I am building an application; Along with the main SDI window it has a modeless dialog, SDI has system menu but the modeless dialog has no system menu icon; (upper left part of task bar), although I have selected system menu and taskbar options in the dialog properties.
How to add system menu / icon in a modeless dialog?
Please Help.
|
|
|
|
|
Is it a child and is that selected?
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
Thanks for reply;
I have created dialog in the OnCreate of CMainFrame like this;
mydlg.Create(IDD_MYDLG, this);
In the properties tab the style of dialog is POPUP not child;
making it child donot displays it.
|
|
|
|
|
Hi,
I want to execute the function for evry 3 minuts.How can I call the event multiple times in this regard?
Please help me.
dadsadasd
|
|
|
|
|
Hi
Add a event handler of WM_TIMER. Create a ID for the particulare timer, ie for 3 minutes say, IDT_TIMER1.
On the initialization part of your application call
SetTimer(IDT_TIMER1,18000,NULL);
Now call the function inside the event handler for WM_TIMER.
Check for the nIDEvent with IDT_TIMER1 if you have multiple timers in your application.
Hope this would help you
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
zainu wrote:
SetTimer(IDT_TIMER1,18000,NULL);
You might want to change that to 180000.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
It's possible set a file dialog (CFileDialog) to let select to user only directories?
I want to do this to choose the work directory of my software.
Somebody can help me?
Thanks a lot
|
|
|
|
|
|
Or here's a function that i use to return the folder name in a CString:
CString GetFolder()
{
LPMALLOC pMalloc,pMalloc2;
CString strDirectory;
BROWSEINFO bi;
CString strPath1,strPath2;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
bi.hwndOwner = GetDesktopWindow();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = _T("Select First Directory");
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn = NULL;
bi.lParam = 0;
if (::SHGetMalloc(&pMalloc) == NOERROR)
{
if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
{
if (::SHGetPathFromIDList(pidl, pszBuffer))
{
strDirectory = pszBuffer;
}
pMalloc->Free(pidl);
}
pMalloc->Release();
}
return strDirectory;
}
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hi,
How do I add an unicode support to a code.
also when i build I would need the project configuration list to seperately display one with unicode, other without unicode.
How do i add this "w / without unicode" entry in the project configurations.
thanx,
hiva P
|
|
|
|
|
I have an executable file which was compiled in debug mode.
When I run it in debug mode, I get an error message before the code even seems to execute (InitInstance on my CWinApp class doesn't even get called). The error message says: "C:\path\to\filename.dll" File not Found.
This filename.dll is the output from another project I have, but the 2 projects are unrelated.
If I run the same exeutable file in non-debug mode, then there are no issues like this.
Does anybody know why my application might be trying to link up with this filename.dll ? Does VC++ have someplace where it keeps the list of DLLs it tries to link with at runtime?
Any and all help appreciated.
|
|
|
|
|
Hi
Please look into Project->Settings->Link, Object/Library modules is empty or not.
Hope this would help you.
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I'm loading:
advapi32.lib
So, this isn't the issue.
|
|
|
|
|
Howdy - I've got the code I need to add and remove menu items that I need, but I'm not sure where to place this code.
Using an SDI MFC app, what message do I handle to know that the user dropped down a menu in the main menu?
Thanks!
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
Please, try out WM_INITMENUPOPUP. It is useful to modify popup menu at runtime
|
|
|
|
|
I guess I overlooked that one, Thanks!
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
My application is MDI application.
So,I cannot know what parameter use in following code???
m_tabPages[0]->Create(CMyTabDlg,this);
>>>>>>>>>>>>>>>This is my error>>>>>>>>>>>>>>
MyTabCtrl.cpp(54) : error C2275: 'CMyTabDlg' :
illegal use of this type as an expression
MyTabdlg.h(13) :
see declaration of CMyTabDlg'
>>>>>>>>>>>>>>>This is My code>>>>>>>>>>>>>>>>
//MyTabCtrl.cpp
CDialog *m_tabPages[2];
//MyTabCtrl.cpp
void CMyTabCtrl::Init()
{
m_tabCurrent=0;
m_tabPages[0]->Create(CMyTabDlg,this);
//what i use parameter
m_tabPages[1]->Create(CMyTabDlg,this);
//what i use parameter
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
SetRectangle();
}
//MyView.h
CMyTabCtrl m_tab;
//MyView.cpp
void CMyView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
m_tab.InsertItem(0, _T("One"));
m_tab.InsertItem(1, _T("Two"));
m_tab.Init();
}
|
|
|
|
|
As I thought, CMyTabDlg was a class name, not variable name, so that, it is illegal to appear as a function argument.
|
|
|
|
|
//CMyTab
//MyTab.h
CDialog *m_tabPages[2];
//MyTab.cpp
m_tabPages[0]->Create(CMyTabDlg,this);
My demo is MDI application.
i have a class.This is CMyTabCtrl,
i found codeproject web site.
this demo is dialog base application.
i run this demo is ok.
and i making mdi application.
and use this class.
but i don't know.what parameter place in
"CWnd* pParentWnd".
>>>>>m_tabPages[0]->Create(CMyTabDlg,this);
>>>>>function argument(CDialog::Create)
BOOL Create( LPCTSTR lpszTemplateName,
CWnd* pParentWnd = NULL );
|
|
|
|
|
BOOL Create( LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL );
In this case, the first argument typed string?
|
|
|
|
|
Yes!!!
i change.................
m_tabPages[0]->Create(IDD_MY_DLG,this);
thank you so much...........
|
|
|
|