|
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.
|
|
|
|
|
Have you tried catching WS_WINDOWPOSCHANGED/WS_WINDOWPOSCHANGED?
--
Featuring GRATUITOUS ALIEN NUDITY
|
|
|
|
|
Hey guys,
Help! I have been using visual C++ for a while, but there is a issue always make me confused.
The description of the issue:
We use this Macro very often: ON_NOTIFY(wNotifyCode, id, memberFxn), but how do you know what is the actual signature of memberFxn.
For instance, when we use
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
At the same time, we will define a function called OnToolTipText, the signature of this function is:
OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult)
For the parameter pNMHDR, we know the actual data type maybe not NMHDR, sometime we convert it by using a specific data type rather than using it directly. The actual struct of NMHDR is:
typedef struct tagNMHDR {
HWND hwndFrom;
UINT idFrom;
UINT code;
} NMHDR;
For the notification TTN_NEEDTEXTW, we convert parameter pNMHDR by using TOOLTIPTEXTA, so my question is: how, when and where do you know you should use TOOLTIPTEXTA to convert it? why don't you use something else? is there any documents talk about what type we should use to convert a specific parameter?
PS: If you don't mind, I have one more question, is there anyone knows how to use CListCtrl::SetInfoTip()? I want to set a tooltip for each cell of the table, I tired to use SetInfoTip(), but it doesn't work well. Can you teach me how to use it?
Thank you so much!
David Zuo
|
|
|
|
|
All ON_NOTIFY handlers have the same signature. For other macros, see the documentation for that macro.
The convention for any message sent with WM_NOTIFY is for the lParam parameter of the window message to point to a structure that either is, or begins with, an NMHDR structure - the notification code is actually part of this structure. To find out if there's an extended structure sent with a given notification code, check the documentation for that code.
In your specific situation you should be matching a TOOLTIPTEXTW structure with the TTN_NEEDTEXTW notification. In general you should consider using the versions with no character-encoding-width indicator, TTN_NEEDTEXT and, as documented in the latest MSDN Library, a NMTTDISPINFO structure.
|
|
|
|