Click here to Skip to main content
11,431,307 members (68,738 online)

C / C++ / MFC

 
GeneralRe: Regarding storing structures in database Pin
Member 789460125-Apr-13 23:56
memberMember 789460125-Apr-13 23:56 
GeneralRe: Regarding storing structures in database Pin
Marco Bertschi26-Apr-13 0:16
professionalMarco Bertschi26-Apr-13 0:16 
GeneralRe: Regarding storing structures in database Pin
Jochen Arndt26-Apr-13 0:34
professionalJochen Arndt26-Apr-13 0:34 
GeneralRe: Regarding storing structures in database Pin
Member 789460126-Apr-13 0:41
memberMember 789460126-Apr-13 0:41 
GeneralRe: Regarding storing structures in database Pin
Jochen Arndt26-Apr-13 0:57
professionalJochen Arndt26-Apr-13 0:57 
AnswerRe: Regarding storing structures in database Pin
jschell26-Apr-13 10:36
memberjschell26-Apr-13 10:36 
GeneralRe: Regarding storing structures in database Pin
Member 789460129-Apr-13 2:00
memberMember 789460129-Apr-13 2:00 
GeneralRe: Regarding storing structures in database Pin
Member 78946011-May-13 1:09
memberMember 78946011-May-13 1:09 
Questionstrcat_memcpy Pin
khushboo gupta25-Apr-13 19:37
memberkhushboo gupta25-Apr-13 19:37 
AnswerRe: strcat_memcpy Pin
pasztorpisti25-Apr-13 22:07
memberpasztorpisti25-Apr-13 22:07 
GeneralRe: strcat_memcpy Pin
Freak3026-Apr-13 3:15
memberFreak3026-Apr-13 3:15 
GeneralRe: strcat_memcpy Pin
pasztorpisti26-Apr-13 3:20
memberpasztorpisti26-Apr-13 3:20 
AnswerRe: strcat_memcpy Pin
Richard MacCutchan25-Apr-13 23:17
mvpRichard MacCutchan25-Apr-13 23:17 
QuestionDoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Newbie0025-Apr-13 11:26
memberNewbie0025-Apr-13 11:26 
Hello,

I need to verify content of my edit control before I let it to loose focus. To do so I wrote my PreTranslateMessage like this:

BOOL CMyFrameWnd::PreTranslateMessage( MSG *pMsg )
{
   BOOL bMessageHandled = FALSE;
 
   switch( pMsg->message )
   {
      case WM_LBUTTONDOWN:
      {
        if( ::GetFocus == MyEditWnd )
        {
          if( !IsContentOfMyEditWndOK )
          {
            ShowMessageBox( "You cannot change value");
            //ShowMessageBox has got DoModal inside, which pumps messages.
           //Unfortunately it causes my *pMsg parameter to be changed.
          }
        }
        break;
      }
   }
  if( !bMessageHandled )
  {
     bMessageHandled = CFrameWnd::PreTranslateMessage( pMsg ); //I get assertion has failed here, because I am sending pMsg->Hwnd changed with 'ShowMessageBox'
  }
 
  return bMessageHandled; //I want to show messagebox and let WM_LBUTTONDOWN to be processed, because I do not want to trap focus in my Edit. So I am returning FALSE here. But it has no sence since the pMsg has changed. It is no longer WM_LBUTTONDOWN. 
}
In order to be able to show modal dialog in PreTranslateMessage and after it forward WM_LBUTTONDOWN I would like to do something like this:
BOOL CMyFrameWnd::PreTranslateMessage( MSG *pMsg )
{
   BOOL bMessageHandled = FALSE;
   MSG oRememberMsg;
 
   switch( pMsg->message )
   {
      case WM_LBUTTONDOWN:
      {
        if( ::GetFocus == MyEditWnd )
        {
          if( !IsContentOfMyEditWndOK )
          {
            oRememberMsg = *pMsg; 
            ShowMessageBox( "You cannot change value");
            *pMsg = oRememberMsg; //now pMsg is WM_LBUTTONDOWN again 
          }
        }
        break;
      }
   }
  if( !bMessageHandled )
  {
     bMessageHandled = CFrameWnd::PreTranslateMessage( pMsg ); //I am not getting assertion has failed, because pMsg->HWnd is correct now (the same as at the beginning)
  }
 
  return bMessageHandled; //Now I am forwarding my catch WM_LBUTTONDOWN and my Edit loses focus
}
But I am not sure if my code is ok from MFC structural point of view. Can I manipulate with MSG *pMsg parameter as I described above? I tried it and it seems to work, but I don't know... Does it make some side effects? Is something I am missing here? How do you think?
AnswerRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
jeron125-Apr-13 11:48
memberjeron125-Apr-13 11:48 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Newbie0025-Apr-13 19:24
memberNewbie0025-Apr-13 19:24 
AnswerRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Richard MacCutchan25-Apr-13 23:14
mvpRichard MacCutchan25-Apr-13 23:14 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) [modified] Pin
Newbie0026-Apr-13 8:02
memberNewbie0026-Apr-13 8:02 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Richard MacCutchan26-Apr-13 8:23
mvpRichard MacCutchan26-Apr-13 8:23 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Newbie0026-Apr-13 9:01
memberNewbie0026-Apr-13 9:01 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Richard MacCutchan26-Apr-13 23:15
mvpRichard MacCutchan26-Apr-13 23:15 
QuestionC++ MVC framework for Linux/Motif [modified] Pin
LeifUK25-Apr-13 7:35
memberLeifUK25-Apr-13 7:35 
AnswerRe: C++ MVC framework for Linux/Motif Pin
pasztorpisti25-Apr-13 21:56
memberpasztorpisti25-Apr-13 21:56 
QuestionCrystal Reports 2011 with C++/MFC Dev Studio 2010 Pin
Member 983646924-Apr-13 19:42
memberMember 983646924-Apr-13 19:42 
QuestionAudio in DirectShow Pin
Indian Coder198924-Apr-13 18:40
memberIndian Coder198924-Apr-13 18:40 
AnswerRe: Audio in DirectShow Pin
Vaclav_Sal25-Apr-13 4:03
memberVaclav_Sal25-Apr-13 4:03 
QuestionHow to create 4 dimenstional array Pin
jothivel k24-Apr-13 10:07
memberjothivel k24-Apr-13 10:07 
AnswerRe: How to create 4 dimenstional array Pin
Richard MacCutchan24-Apr-13 10:33
mvpRichard MacCutchan24-Apr-13 10:33 
AnswerRe: How to create 4 dimenstional array Pin
pasztorpisti24-Apr-13 10:45
memberpasztorpisti24-Apr-13 10:45 
GeneralRe: How to create 4 dimenstional array Pin
jothivel k25-Apr-13 8:12
memberjothivel k25-Apr-13 8:12 
GeneralRe: How to create 4 dimenstional array Pin
pasztorpisti25-Apr-13 21:48
memberpasztorpisti25-Apr-13 21:48 
AnswerRe: How to create 4 dimenstional array Pin
Stefan_Lang24-Apr-13 23:15
memberStefan_Lang24-Apr-13 23:15 
AnswerRe: How to create 4 dimenstional array Pin
Joe Woodbury25-Apr-13 7:47
memberJoe Woodbury25-Apr-13 7:47 
Questioniso_8583 message Pin
khushboo gupta23-Apr-13 1:16
memberkhushboo gupta23-Apr-13 1:16 
AnswerRe: iso_8583 message Pin
Marco Bertschi23-Apr-13 2:53
professionalMarco Bertschi23-Apr-13 2:53 
GeneralRe: iso_8583 message Pin
khushboo gupta23-Apr-13 21:05
memberkhushboo gupta23-Apr-13 21:05 
GeneralRe: iso_8583 message Pin
Marco Bertschi23-Apr-13 22:39
professionalMarco Bertschi23-Apr-13 22:39 
GeneralMessage Removed Pin
khushboo gupta23-Apr-13 21:13
memberkhushboo gupta23-Apr-13 21:13 
GeneralRe: iso_8583 message Pin
Richard MacCutchan23-Apr-13 22:50
mvpRichard MacCutchan23-Apr-13 22:50 
GeneralMessage Removed Pin
khushboo gupta23-Apr-13 23:54
memberkhushboo gupta23-Apr-13 23:54 
GeneralRe: iso_8583 message Pin
Richard MacCutchan24-Apr-13 0:02
mvpRichard MacCutchan24-Apr-13 0:02 
GeneralRe: iso_8583 message Pin
khushboo gupta24-Apr-13 21:17
memberkhushboo gupta24-Apr-13 21:17 
GeneralRe: iso_8583 message Pin
Jochen Arndt24-Apr-13 22:13
professionalJochen Arndt24-Apr-13 22:13 
GeneralRe: iso_8583 message Pin
khushboo gupta24-Apr-13 23:32
memberkhushboo gupta24-Apr-13 23:32 
GeneralRe: iso_8583 message Pin
Richard MacCutchan24-Apr-13 23:58
mvpRichard MacCutchan24-Apr-13 23:58 
QuestionMCI wave player Pin
VijaySoni2348823-Apr-13 1:15
memberVijaySoni2348823-Apr-13 1:15 
AnswerRe: MCI wave player Pin
Marco Bertschi23-Apr-13 3:32
professionalMarco Bertschi23-Apr-13 3:32 
QuestionCDaoDatabase for Opening MS-Access Pin
D.Manivelan23-Apr-13 0:32
memberD.Manivelan23-Apr-13 0:32 
AnswerRe: CDaoDatabase for Opening MS-Access Pin
Jochen Arndt23-Apr-13 1:03
professionalJochen Arndt23-Apr-13 1:03 
QuestionMulti Threaded ::ShowWindow(...) Pin
Bram van Kampen22-Apr-13 14:58
memberBram van Kampen22-Apr-13 14:58 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.150428.2 | Last Updated 4 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid