Click here to Skip to main content
11,641,081 members (65,336 online)

C / C++ / MFC

 
GeneralRe: Regarding storing structures in database Pin
Member 789460125-Apr-13 22:56
memberMember 789460125-Apr-13 22:56 
GeneralRe: Regarding storing structures in database Pin
Marco Bertschi25-Apr-13 23:16
professionalMarco Bertschi25-Apr-13 23:16 
GeneralRe: Regarding storing structures in database Pin
Jochen Arndt25-Apr-13 23:34
professionalJochen Arndt25-Apr-13 23:34 
GeneralRe: Regarding storing structures in database Pin
Member 789460125-Apr-13 23:41
memberMember 789460125-Apr-13 23:41 
GeneralRe: Regarding storing structures in database Pin
Jochen Arndt25-Apr-13 23:57
professionalJochen Arndt25-Apr-13 23:57 
AnswerRe: Regarding storing structures in database Pin
jschell26-Apr-13 9:36
memberjschell26-Apr-13 9:36 
GeneralRe: Regarding storing structures in database Pin
Member 789460129-Apr-13 1:00
memberMember 789460129-Apr-13 1:00 
GeneralRe: Regarding storing structures in database Pin
Member 78946011-May-13 0:09
memberMember 78946011-May-13 0:09 
Questionstrcat_memcpy Pin
khushboo gupta25-Apr-13 18:37
memberkhushboo gupta25-Apr-13 18:37 
AnswerRe: strcat_memcpy Pin
pasztorpisti25-Apr-13 21:07
memberpasztorpisti25-Apr-13 21:07 
GeneralRe: strcat_memcpy Pin
Freak3026-Apr-13 2:15
memberFreak3026-Apr-13 2:15 
GeneralRe: strcat_memcpy Pin
pasztorpisti26-Apr-13 2:20
memberpasztorpisti26-Apr-13 2:20 
AnswerRe: strcat_memcpy Pin
Richard MacCutchan25-Apr-13 22:17
mvpRichard MacCutchan25-Apr-13 22:17 
QuestionDoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Newbie0025-Apr-13 10:26
memberNewbie0025-Apr-13 10: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 10:48
memberjeron125-Apr-13 10:48 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Newbie0025-Apr-13 18:24
memberNewbie0025-Apr-13 18:24 
AnswerRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Richard MacCutchan25-Apr-13 22:14
mvpRichard MacCutchan25-Apr-13 22:14 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Newbie0026-Apr-13 7:02
memberNewbie0026-Apr-13 7:02 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Richard MacCutchan26-Apr-13 7:23
mvpRichard MacCutchan26-Apr-13 7:23 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Newbie0026-Apr-13 8:01
memberNewbie0026-Apr-13 8:01 
GeneralRe: DoModal in CWnd::PreTranslateMessage( MSG *pMsg ) Pin
Richard MacCutchan26-Apr-13 22:15
mvpRichard MacCutchan26-Apr-13 22:15 
QuestionC++ MVC framework for Linux/Motif Pin
LeifUK25-Apr-13 6:35
memberLeifUK25-Apr-13 6:35 
AnswerRe: C++ MVC framework for Linux/Motif Pin
pasztorpisti25-Apr-13 20:56
memberpasztorpisti25-Apr-13 20:56 
QuestionCrystal Reports 2011 with C++/MFC Dev Studio 2010 Pin
Member 983646924-Apr-13 18:42
memberMember 983646924-Apr-13 18:42 
QuestionAudio in DirectShow Pin
Indian Coder198924-Apr-13 17:40
memberIndian Coder198924-Apr-13 17:40 
AnswerRe: Audio in DirectShow Pin
Vaclav_Sal25-Apr-13 3:03
memberVaclav_Sal25-Apr-13 3:03 
QuestionHow to create 4 dimenstional array Pin
jothivel k24-Apr-13 9:07
memberjothivel k24-Apr-13 9:07 
AnswerRe: How to create 4 dimenstional array Pin
Richard MacCutchan24-Apr-13 9:33
mvpRichard MacCutchan24-Apr-13 9:33 
AnswerRe: How to create 4 dimenstional array Pin
pasztorpisti24-Apr-13 9:45
memberpasztorpisti24-Apr-13 9:45 
GeneralRe: How to create 4 dimenstional array Pin
jothivel k25-Apr-13 7:12
memberjothivel k25-Apr-13 7:12 
GeneralRe: How to create 4 dimenstional array Pin
pasztorpisti25-Apr-13 20:48
memberpasztorpisti25-Apr-13 20:48 
AnswerRe: How to create 4 dimenstional array Pin
Stefan_Lang24-Apr-13 22:15
memberStefan_Lang24-Apr-13 22:15 
AnswerRe: How to create 4 dimenstional array Pin
Joe Woodbury25-Apr-13 6:47
memberJoe Woodbury25-Apr-13 6:47 
Questioniso_8583 message Pin
khushboo gupta23-Apr-13 0:16
memberkhushboo gupta23-Apr-13 0:16 
AnswerRe: iso_8583 message Pin
Marco Bertschi23-Apr-13 1:53
professionalMarco Bertschi23-Apr-13 1:53 
GeneralRe: iso_8583 message Pin
khushboo gupta23-Apr-13 20:05
memberkhushboo gupta23-Apr-13 20:05 
GeneralRe: iso_8583 message Pin
Marco Bertschi23-Apr-13 21:39
professionalMarco Bertschi23-Apr-13 21:39 
GeneralMessage Removed Pin
khushboo gupta23-Apr-13 20:13
memberkhushboo gupta23-Apr-13 20:13 
GeneralRe: iso_8583 message Pin
Richard MacCutchan23-Apr-13 21:50
mvpRichard MacCutchan23-Apr-13 21:50 
GeneralMessage Removed Pin
khushboo gupta23-Apr-13 22:54
memberkhushboo gupta23-Apr-13 22:54 
GeneralRe: iso_8583 message Pin
Richard MacCutchan23-Apr-13 23:02
mvpRichard MacCutchan23-Apr-13 23:02 
GeneralRe: iso_8583 message Pin
khushboo gupta24-Apr-13 20:17
memberkhushboo gupta24-Apr-13 20:17 
GeneralRe: iso_8583 message Pin
Jochen Arndt24-Apr-13 21:13
professionalJochen Arndt24-Apr-13 21:13 
GeneralRe: iso_8583 message Pin
khushboo gupta24-Apr-13 22:32
memberkhushboo gupta24-Apr-13 22:32 
GeneralRe: iso_8583 message Pin
Richard MacCutchan24-Apr-13 22:58
mvpRichard MacCutchan24-Apr-13 22:58 
QuestionMCI wave player Pin
VijaySoni2348823-Apr-13 0:15
memberVijaySoni2348823-Apr-13 0:15 
AnswerRe: MCI wave player Pin
Marco Bertschi23-Apr-13 2:32
professionalMarco Bertschi23-Apr-13 2:32 
QuestionCDaoDatabase for Opening MS-Access Pin
D.Manivelan22-Apr-13 23:32
memberD.Manivelan22-Apr-13 23:32 
AnswerRe: CDaoDatabase for Opening MS-Access Pin
Jochen Arndt23-Apr-13 0:03
professionalJochen Arndt23-Apr-13 0:03 
QuestionMulti Threaded ::ShowWindow(...) Pin
Bram van Kampen22-Apr-13 13:58
memberBram van Kampen22-Apr-13 13: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
Web03 | 2.8.150731.1 | Last Updated 1 Aug 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid