|
hwndEdit=CreateWindow ("EDIT","Anshuman",WS_CHILD|WS_VISIBL|WS_BORDER,10,10,80,20,hWnd,(HMENU)IDC_EDIT1,hInst,NULL);
SetFocus (hwndEdit); // Call at last to set the focus.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
tried this method several times at many different places, such as when created, when updated, or in InitInstance, can't success. don't know what's the problem
|
|
|
|
|
Call it immediatly before exiting your OnInit function. If that doesn't work look through your code for any other instances of SetFocus , maybe you are setting it but it is later being stolen.
|
|
|
|
|
On way is using CEdit::Setfocus in overridden OnActivateView()
|
|
|
|
|
|
I don't know what's the reason, but i called m_edtContent.SetFocus in my overridden OnActivateView(), are you OK in your side, thanks for your help.
|
|
|
|
|
its failing ? Is it giving some ASSERT or just not doing what its intended to do?
Have you suppressed its base class call ? You need to do that.
It would just look like this,
void CSDIView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
m_edtContent.SetFocus();
}
|
|
|
|
|
yes, really thanks for your help, it succeeds when i call like "CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
m_edtContent.SetFocus();"
but not if i call like"
m_edtContent.SetFocus();
CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
".
it's really very good, but after i quit the program, it will say "The exception Breakpoint, A breakpoint has been reached."
|
|
|
|
|
ikohl wrote: CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
tries to set foucs on view itself. In your case its not needed.
|
|
|
|
|
yes, it's ok in sdi program, except for can't focus previous program when this program quits.
but for mdi program, there's an error box will jump out when quit this program.
really thanks for your help, you're a kind man.
|
|
|
|
|
Actually, problem was you can't use SetFocus unless that window ,parent window is visible.
OnActivateView is one place where you can achieve this. You can use its parameters for certain checks.
Other place I feel is overriding WM_SHOWWINDOW, but it will get called once.
You can look for such messages and use SetFocus there.
|
|
|
|
|
ok, i will review it, really thanks for your help
|
|
|
|
|
hi all,
I want a part of program/code ie., the USB reading alone in a separate thread so that it doesnt block the main functions/code which is a continuous process.
How can I do it?
Can anyone help/suggestions ...with code snippets please?
Thanks in advance.
|
|
|
|
|
Look up the _beginthread and the _beginthreadex CRT functions of if you're using MFC check out the CWinThread class and the AfxBeginThread global function. Make sure you link to the multithreaded libraries.
Steve
|
|
|
|
|
do u have any example programs or any relevant code snippet that would help me understand it better.
where to call the Afxbeginthread..etc?
iam using MFC for the first time. so am in the learning curve now.
|
|
|
|
|
// The thread.
class CMyThread : public CWinThread
{
public:
DECLARE_DYNCREATE(CMyThread)
CMyThread()
{
m_Data = 0;
}
virtual BOOL InitInstance() { return TRUE; }
virtual int Run() // Do work in here!!!!
{
// Do some work!
while (++m_Data < 1000) {}
return 0;
}
private:
int m_Data;
};
IMPLEMENT_DYNCREATE(CMyThread, CWinThread)
// To start the thread.
AfxBeginThread(RUNTIME_CLASS(CMyThread));
// ------------------------- //
There are many ways to skin a cat however. Using <code>_beginthread</code> is probably easier.
Steve
|
|
|
|
|
I want let my program delete itself,but I do not know what to do.Thanks for your help!!;)
|
|
|
|
|
You can do it like this.
While on exist copy ur exe to some temp folder . Run it with command line something like "delete ME and File to delete" (that is ur current exe path or GetModulePath()) . So in ur program if you get a commandline "delete ME"
try deleting that file (Make sure to try it in aloop , Becs some time the First one is only going to exit. ).
Hopes this will help u.
regards
krishnan
-- modified at 21:40 Tuesday 22nd August, 2006
If u can Dream... U can do it
|
|
|
|
|
Thank krishnan very much!!;)
|
|
|
|
|
Your program cannot delete itself while running. You can put an entry in runonce in the registry to delete it on reboot, or you can have a seperate app that does the deleting and is run by your app as it closes.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
"runonce" is a good information. Can u please provide it's path in registry ?
and what will happen if i set this flag to explorer.exe or iexplorer.exe )
regards
krishnan
If u can Dream... U can do it
|
|
|
|
|
run regedit and search for 'runonce'. Whatever path you put in there, it is run the next time windows starts.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I'm trying to trap a windows message that would inform me the user has selected to minimize the window. I can't find anything on MSDN that enables me to do such a thing. The WM_SIZE message is sent after the window has been minimized, and the WM_MOVING is only sent if the user user physicaly moving the window. There must be some sort of message sent when the user clicks the minimize button.
|
|
|
|
|
Surely it's a button with a known ID and there's a button click message ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Never mind, I found it. It comes under the WM_SYSCOMMAND with SC_MINIMIZE in the wParam.
|
|
|
|