Click here to Skip to main content
15,880,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: CEdit::ReplaceSel Help Needed Pin
Stephane Rodriguez.20-Aug-02 7:37
Stephane Rodriguez.20-Aug-02 7:37 
GeneralRe: CEdit::ReplaceSel Help Needed Pin
Cerb20-Aug-02 7:45
Cerb20-Aug-02 7:45 
GeneralSocket recv question Pin
Todd Smith20-Aug-02 6:51
Todd Smith20-Aug-02 6:51 
GeneralRe: Socket recv question Pin
Le centriste20-Aug-02 7:10
Le centriste20-Aug-02 7:10 
GeneralRe: Socket recv question Pin
Len Holgate20-Aug-02 7:09
Len Holgate20-Aug-02 7:09 
GeneralDirectshow Pin
Zizilamoroso20-Aug-02 6:45
Zizilamoroso20-Aug-02 6:45 
GeneralRe: Directshow Pin
Stephane Rodriguez.20-Aug-02 7:33
Stephane Rodriguez.20-Aug-02 7:33 
GeneralRe: Directshow Pin
Zizilamoroso20-Aug-02 22:47
Zizilamoroso20-Aug-02 22:47 
Generalbutton focus on w2k Pin
gdourmap@lemel.fr20-Aug-02 6:40
sussgdourmap@lemel.fr20-Aug-02 6:40 
Generaldifference between overwrite PretanslateMessage And OnDefWindowProc Pin
Rene De La Garza20-Aug-02 6:40
Rene De La Garza20-Aug-02 6:40 
GeneralShowing content of wnd while moving Pin
MaTrIX2k220-Aug-02 6:29
MaTrIX2k220-Aug-02 6:29 
GeneralCalculate bounding rect of text __@_y Pin
BlackSmith20-Aug-02 5:41
BlackSmith20-Aug-02 5:41 
GeneralRe: Calculate bounding rect of text __@_y Pin
Roger Allen20-Aug-02 5:49
Roger Allen20-Aug-02 5:49 
GeneralRe: Calculate bounding rect of text __@_y Pin
Ravi Bhavnani20-Aug-02 7:37
professionalRavi Bhavnani20-Aug-02 7:37 
GeneralHelp: named pipe Pin
tfElep20-Aug-02 5:20
tfElep20-Aug-02 5:20 

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.