Click here to Skip to main content
15,889,462 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CString Stupidity Pin
Daniel Turini20-Aug-02 11:19
Daniel Turini20-Aug-02 11:19 
GeneralRe: CString Stupidity Pin
carrie20-Aug-02 11:23
carrie20-Aug-02 11:23 
Generalget text of first item in Clistctrl without selecting it Pin
ns20-Aug-02 10:13
ns20-Aug-02 10:13 
GeneralRe: get text of first item in Clistctrl without selecting it Pin
dazinith20-Aug-02 10:24
dazinith20-Aug-02 10:24 
GeneralRe: get text of first item in Clistctrl without selecting it Pin
ns20-Aug-02 10:50
ns20-Aug-02 10:50 
GeneralFile Version Pin
act_x20-Aug-02 10:00
act_x20-Aug-02 10:00 
GeneralRe: File Version Pin
Dave Bryant20-Aug-02 10:26
Dave Bryant20-Aug-02 10:26 
GeneralCTreeCtrl and Selection Changed Event Pin
dazinith20-Aug-02 9:47
dazinith20-Aug-02 9:47 
GeneralRe: CTreeCtrl and Selection Changed Event Pin
Ernest Laurentin20-Aug-02 11:08
Ernest Laurentin20-Aug-02 11:08 
GeneralRe: CTreeCtrl and Selection Changed Event Pin
dazinith20-Aug-02 11:19
dazinith20-Aug-02 11:19 
GeneralRe: CTreeCtrl and Selection Changed Event Pin
Joel Lucsy21-Aug-02 12:38
Joel Lucsy21-Aug-02 12:38 
GeneralRe: CTreeCtrl and Selection Changed Event Pin
dazinith22-Aug-02 3:43
dazinith22-Aug-02 3:43 
GeneralHyperlink Question Pin
Onyme20-Aug-02 9:13
sussOnyme20-Aug-02 9:13 
GeneralRe: Hyperlink Question Pin
dazinith20-Aug-02 9:36
dazinith20-Aug-02 9:36 
GeneralRe: Hyperlink Question Pin
jmkhael20-Aug-02 9:45
jmkhael20-Aug-02 9:45 
GeneralRe: Hyperlink Question Pin
Anonymous20-Aug-02 9:49
Anonymous20-Aug-02 9:49 
QuestionWhy was WinCE implementation better than Win32? Pin
djrisc20-Aug-02 8:50
djrisc20-Aug-02 8:50 
GeneralRemove taskbar icon to CWnd derived wnd Pin
BlackSmith20-Aug-02 8:39
BlackSmith20-Aug-02 8:39 
GeneralModal MessgeBox Problem Pin
moobob20-Aug-02 7:45
moobob20-Aug-02 7:45 
GeneralRe: Modal MessgeBox Problem Pin
Mustafa Demirhan20-Aug-02 9:08
Mustafa Demirhan20-Aug-02 9:08 
GeneralRe: Modal MessgeBox Problem Pin
moobob20-Aug-02 9:20
moobob20-Aug-02 9:20 
GeneralRe: Modal MessgeBox Problem Pin
moobob20-Aug-02 9:31
moobob20-Aug-02 9:31 
GeneralRe: Modal MessgeBox Problem Pin
Mustafa Demirhan20-Aug-02 10:07
Mustafa Demirhan20-Aug-02 10:07 
Well, this won't work because the control is the child of your View class; not the CMainFrame class.

I have two suggestions: The first one is the easier way: Don't try to validate the data everytime you loose focus. Instead, validate it when the user clicks on OK button.

If you want to do it whenever the window looses focus do it this way: Create a bool variable as a member of your view. Lets say m_bChildHasFocus

Now, whenever the control gets the focus set the variable to true and whenever it looses set it false. Here is the code:
void DataImportDlg2::OnKillfocusProtocolNameCb() 
{
	if (!m_bChildHasFocus)
		return CView::OnKillFocus(); // or whatever! I am not sure. Just exit the function properly!!

	m_bChildHasFocus = false;

	CString protoName;

	// Get the protocol item just typed in.
	m_protocolNameCB.GetWindowText(protoName);

	// If an item was typed in
	// verify this protocol exists.
	if (protoName.GetLength() > 0)
	{
		int index = m_protocolNameCB.FindStringExact(0, protoName);

		if (index == CB_ERR)
		{
			MessageBox (_T ("Protocol does not exist, to create it, use the Create Protocol button"),
			_T ("Data Import"), 
			MB_ICONERROR | MB_OK | MB_APPLMODAL | MB_TOPMOST);
			m_protocolNameCB.SetFocus();
			m_bChildHasFocus = true;
		}


Also, don't forget to add the OnGetFocus function. In OnGetFocus functions, just set m_bChildHasFocus = true.

Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix

<nobr>They say I'm lazy but it takes all my time
GeneralCEdit::ReplaceSel Help Needed Pin
Cerb20-Aug-02 7:10
Cerb20-Aug-02 7:10 
GeneralRe: CEdit::ReplaceSel Help Needed Pin
Ravi Bhavnani20-Aug-02 7:35
professionalRavi Bhavnani20-Aug-02 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.