|
In normal scenario of what is the expected behavior this dependent service need not to be restarted after it dies out on a reset. This is erroneous behavior. What could be the possible reasons for this?
|
|
|
|
|
Hi,
I have an MFC application.
I run a thread in middle. After completing the thread i have a message box that popsup. But messagebox doesnt have focus.
Can anyone let me know how to get the focus back to message box? Thanks in advance.
Code snippet:
....
RunCmd("test.bat", SW_SHOW);
MessageBox("dfas","fdifd",MB-OK);
.....
Test.bat has come command to format disk etc.
Regards..
|
|
|
|
|
|
Thanks for the reply. But that doesnt have the answer for my problem.
After launching a thread and completing the foucus is not going to main window.
In a dialog based application, I run:
WinExec("test.bat");
Sleep("5000");
MessageBox("sdosn"....);
MessageBox is not having focus. If i remove Thread executions in between (WinExec). Then i get the focus properly.
Any updates on this.
|
|
|
|
|
Member 3834630 wrote: WinExec("test.bat");
Firstly I want to say that WinExec function is Obsolete. you should use, CreateProcess() or ShellExecute() to create new process.
Member 3834630 wrote: MessageBox is not having focus. If i remove Thread executions in between (WinExec). Then i get the focus properly.
Means if you comment out the WinExec() function, your message box is getting the focus and after closing the messagebox, your main dialog is getting the focus?
|
|
|
|
|
Hi,
Sorry, I am actually using CreatProcess() only. To make it simple i put WinExec()
But after calling CreateProcess() which calls a batch file and after completing the process, i display a MessageBox(sdkjfo..), the MessageBox() gets displayed but doesnt have the focus.
Yes, if i comment the CreateProcess() then MessageBox() gets the focus.
Regards.
|
|
|
|
|
Did you try modifying the code as I mentioned yesterday?
WinExec("test.bat");
Sleep("5000");
AttachThreadInput(
GetWindowThreadProcessId(
::GetForegroundWindow(),NULL),
GetCurrentThreadId(),TRUE);
MessageBox("sdosn"....);
AttachThreadInput(
GetWindowThreadProcessId(
::GetForegroundWindow(),NULL),
GetCurrentThreadId(),FALSE);
|
|
|
|
|
Yes, this worked.. Thank you.
If you dont mind, Can you explain why it was earlier failing with out the code and what this code does.
|
|
|
|
|
Did you read the link I gave you yesterday?
Actually in windows XP or later only a thread that own the current active foreground window has the privilege to set another window in foreground. So i guess when you create another process, your application loose the foreground window property
|
|
|
|
|
Hi Naveen,
This solution is working fine on regular OS (vista, XP) but it is failing on Windows PE environment.
Any other to way get the focus?
Thanks,
Ram
|
|
|
|
|
HI,
i have a file named test.ini under a Drive i need to get the complete path of the file if present where drive is specified ...pls let me know...
|
|
|
|
|
Are you using MFC? You could use the CFileFind class.
CFileFind ff;
BOOL res = ff.FindFile(_T("C:\\*.*"));
while(res)
{
res = ff.FindNextFile();
if (!ff.IsDots() && !ff.IsDirectory())
{
TCHAR szTmpPath[MAX_PATH];
_stprintf(szTmpPath, ff.GetFilePath());
}
}
|
|
|
|
|
Thanks for ur response...
but the thing is i need to get the path of the ini file which is present under D:\ drive but i do not know in which folder it is under D:\ drive..
|
|
|
|
|
Ok this is a bit dirty, and untested code. But I have used something similar
void myFindFile(szPath)
{
CFileFind ff;
HANDLE hFindFile;
CString path = szPath;
if(path.Right(1) != "\\")
path += "\\";
path += "*.*";
BOOL res = ff.FindFile(path);
while(res)
{
res = ff.FindNextFile();
if (!ff.IsDots() && !ff.IsDirectory())
{
if(_tcsstr(ff.GetFileName(), _T("test.ini")))
{
}
}
else if (!ff.IsDots() && ff.IsDirectory())
{
path = ff.GetFilePath();
myFindFile(path);
}
}
}
Basically pass the starting point to this function
myFindFile(_T("D:"))
This function will search for every file on that given path, plus inside each folder the while loop is where you look for the specific file.
Hope it helps.
|
|
|
|
|
Hey all,
I have written a utility to remove printer drivers from a system, but the only problem I have come across is refreshing the printer and faxes folder. The driver is removed properly but the printer icon stays in the folder view until I press F5 (to refresh the folder).
I have tried using SHChangeNotify but can't seem to get it working..
Any help is appreciated.
|
|
|
|
|
Hi all,
I have a text file which is something like this.
[SOF]
Start
data1
data2
data4
Stop1
Start
data5
data6
data7
Stop2
[EOF]
Now i want to find "Stop1" and insert "data3" so the file contents look like this
[SOF]
Start
data1
data2
data3
data4
Stop1
Start
data5
data6
data7
Stop2
[EOF]
How to accomplish this??
|
|
|
|
|
You cannot insert data into a file on disk.
You will need to create a new file, delete the old file and then rename the new file to the old filename.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Padmanabha_M wrote: How to accomplish this??
By reading the data into some sort of data structure. Add to that data structure as necessary. Write the data structure to disk. Use Superman's suggestion for the rest.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi,
In my program i got a few edit control box in my dialog. I want when the user click on each edit control box , it will auto highlight the text inside.
After search the forum and msdn i find that SetSel function can done this task. But after i try, it still cannot do what i want to do..
BEGIN_MESSAGE_MAP(CPropErythemaScore, CPropertyPage)
ON_WM_SETFOCUS()
ON_WM_KEYDOWN()
ON_WM_KILLFOCUS()
ON_CONTROL_RANGE(EN_KILLFOCUS, IDC_dELL0, IDC_dEUL4, OnEditKillFocus)
ON_CONTROL_RANGE(EN_SETFOCUS, IDC_dELL0, IDC_dEUL4, OnEditSetFocus)
END_MESSAGE_MAP()
void CTry::OnEditSetFocus(UINT unID)
{
((CEdit*)GetDlgItem(unID))->SetSel(0,-1);
}
any advices?i waiting for your reply..Thank you
|
|
|
|
|
When you click inside an edit control, the control first receives WM_SETFOCUS message and then receives the WM_LBUTTONDOWN message. Since you're highlighting in the set focus, when the button down message is received, the highlight is lost.
To achieve this, you need to derive your own class from CEdit, handle the WM_LBUTTONDOWN message inside your class and subclass the edit control with your class.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thank for reply. Ok, i try to do it on WM_LBUTTONDOWN.
Btw, is there any reading meterial that show the flow of the process when the user click the button / edit control box etc(like here is "control first receives WM_SETFOCUS message and then receives the WM_LBUTTONDOWN message"... )?
|
|
|
|
|
Use Spy++ for this?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi ,
Can u please clarify me how to load the gif file on the CAnimateCtrl picture control using MFC.
Thanks
|
|
|
|
|
The CAnimateCtrl class only understands AVI files and not GIF files.
GIF Animation Control[^] is a custom control derived from CStatic for showing animated GIFs.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi all,
I have a TreeCtrl with checkboxes.I want if checkbox of corrsponding item is unchecked than its not expand even i click on has button of corresponding item.
i m using this code on TVNItemExpanding but its not works
NMTREEVIEW* pnmtv = (NMTREEVIEW*) pNMHDR;
HTREEITEM item = pnmtv->itemNew.hItem;
if ( pnmtv->action == TVE_EXPAND )
{
if(m_tree.GetCheck(item)==0)
{
pnmtv->action=TVE_COLLAPSE;
m_tree.Expand(item,TVE_COLLAPSE);
}
}
Please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|