Click here to Skip to main content
15,895,557 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC Force Painting [modified] Pin
Bram van Kampen19-Feb-07 15:16
Bram van Kampen19-Feb-07 15:16 
GeneralRe: MFC Force Painting Pin
PJ Arends19-Feb-07 15:51
professionalPJ Arends19-Feb-07 15:51 
GeneralRe: MFC Force Painting Pin
Bram van Kampen19-Feb-07 16:04
Bram van Kampen19-Feb-07 16:04 
GeneralRe: MFC Force Painting Pin
Mark Salsbery20-Feb-07 5:21
Mark Salsbery20-Feb-07 5:21 
GeneralRe: MFC Force Painting Pin
Bram van Kampen20-Feb-07 13:23
Bram van Kampen20-Feb-07 13:23 
GeneralRe: MFC Force Painting Pin
Mark Salsbery20-Feb-07 13:30
Mark Salsbery20-Feb-07 13:30 
GeneralRe: MFC Force Painting Pin
Mark Salsbery20-Feb-07 5:41
Mark Salsbery20-Feb-07 5:41 
GeneralRe: MFC Force Painting Pin
Bram van Kampen20-Feb-07 12:14
Bram van Kampen20-Feb-07 12:14 
Hi Mark,

I've read your advice, and there are several points of which I want to take on board. However, I also think that a number of issues are not clear, mainly through me not explaining propperly, so here we go:-

The Application is based on a Dialog Based MFC Wizzard Application, with the following modifications:

By default,the MFC Wizzard initializes m_pMainWnd with &MyAppDlg in
CMyApp::InitInstance(). This Code was Changed as follows:

m_pMainWnd = new CBckGndWnd();
((CMainWnd*)m_pMainWnd)->DisplayBitMap("SalesCounter.bmp");
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED );
m_pMainWnd->UpdateWindow();

This Window is intended to stay on the screen until the App Dies. Multiple Apps open on the screen is something this app tries to avoid. All Apps in this suite are designed to run on Full Screen only. People using my stuff are sales operatives, no computer literacy is assumed, They are at All times shown a Clear and Well defined Full Screen Interface. One place where you may see such thing is on a Supermarket Check-out.

It is this CBckGndWnd Bitmap window that I want to remain displayed as background to the app at all times. This window's code appears to work, and displays the Full Screen Bitmap as advertised, most of the time.

By the way this window has NO other task, other than to show on the display.

After starting this BitmapWindow on the heap, InitInstance() does some more initialisation, and hits the function:

RunCounterProcess();

This 'RunCounterProcess' Function is an Endless Loop which Starts with displaying a Dialog Box, 'CStartTransactionDlg'.
This DialogBox has an Edit Control and various buttons, each to pick an Option. The Standard response would be to enter a Customer ID Number into the Edit Control,

Sofar Sogood, No Problems.

Now After Doing this, the Girl clicks the Button 'FindCustomer', and Control passes to the handler: 'CStartTransactionDlg::OnFindCustomer()'


OnFindCustomer() does some validation and initialisation, and calls in turn something like this:-


ShowWindow(SW_HIDE);// Hides CStartTransactionDlg
CCustomerAccountDlg Dlg(pCurrentCustomer,FLAG_SHOWACCOUNT|FLAG_ALLOWPAYMENT);
Dlg.DoModal();
ShowWindow(SW_SHOWNORMAL);// Show CStartTransactionDlg

Note That ON THIS OCCASION 'ShowWindow(SW_HIDE)' is called from 'CStartTransactionDlg', WHICH IS NOT THE MAIN WINDOW!!!, But Rather, This Dialog Box is displayed ON TOP OF the Main Window.(i.e. the Bitmap!)

The Problem is, that ShowWindow(SW_HIDE) does not only seem to affect the CStartTransactionDlg from where it was called,and which we intend to hide, but also hides momentarily an unintended window, the CBckGndWnd() m_pMainWnd. To Reiterate, the instance of CStartTransactionDlg, which we hide, is NOT the Application's main window, the instance of CBckGndWnd is!!

This is fine, and works well albeit with some anoying flashing, if the instance of CCustomerAccountDlg initialises quickly. If that is slow, the app, i.e. the background bitmap disappears off the screen for more or less the duration of CCustomerAccountDlg::InitDialog(). In other words, No messages can be processed by the Procedure for 'CBckGndWnd' whilst CCustomerAccountDlg is processing WM_INITDIALOG. This is not surprising, afterall there is only one thread.

I can Only see two ways of attack:-
-Stop ShowWindow(SW_HIDE) from interfering with the Background Window
-Force the Background Window to complete Re-paint, before we start the Next Dialog

So, to recap:
What I am realy looking for is something like:

MagicFuncToStopInterferenceWithBackground();
ShowWindow(SW_HIDE);// Hides CStartTransactionDlg
MagicCodeToRepaintCBckGndWndIfAboveFails();
// And Now, on a Full Background:-
CCustomerAccountDlg Dlg(pCurrentCustomer,FLAG_SHOWACCOUNT|FLAG_ALLOWPAYMENT);
Dlg.DoModal();
ShowWindow(SW_SHOWNORMAL);// Show CStartTransactionDlg

The sad point is that the above software was written some five years age. A new version is due for 2008, which fundamentally avoids the above pitfalls. It is also a problem which only became noticable some time ago, when the database had grown to such a size that search times have become non trivial. Needless to say, I am reluctant to start multythreading an app at the end of it's life cycle. At the same time, I want to do something to remove these glitches, if at all possible with reasonable efford. Beside that, I want to find out for the future what to do to avoid this sort of thing.

Sorry for the length of this, but I hope it explains what I want to achieve

Thanks,




LateNightsInNewry
GeneralRe: MFC Force Painting Pin
Mark Salsbery20-Feb-07 12:31
Mark Salsbery20-Feb-07 12:31 
GeneralRe: MFC Force Painting [modified] Pin
Mark Salsbery20-Feb-07 14:06
Mark Salsbery20-Feb-07 14:06 
GeneralRe: MFC Force Painting Pin
Bram van Kampen21-Feb-07 14:11
Bram van Kampen21-Feb-07 14:11 
GeneralRe: MFC Force Painting Pin
Mark Salsbery21-Feb-07 14:23
Mark Salsbery21-Feb-07 14:23 
GeneralRe: MFC Force Painting Pin
Bram van Kampen20-Feb-07 13:33
Bram van Kampen20-Feb-07 13:33 
GeneralRe: MFC Force Painting Pin
Mark Salsbery20-Feb-07 13:49
Mark Salsbery20-Feb-07 13:49 
GeneralRe: MFC Force Painting Pin
Bram van Kampen19-Feb-07 13:50
Bram van Kampen19-Feb-07 13:50 
GeneralRe: MFC Force Painting Pin
Mark Salsbery19-Feb-07 13:55
Mark Salsbery19-Feb-07 13:55 
GeneralRe: MFC Force Painting Pin
Bram van Kampen19-Feb-07 15:23
Bram van Kampen19-Feb-07 15:23 
QuestionHow do I create 4 MDI child windows at start? Pin
Cengine19-Feb-07 12:43
Cengine19-Feb-07 12:43 
QuestionRe: How do I create 4 MDI child windows at start? Pin
Mark Salsbery19-Feb-07 13:16
Mark Salsbery19-Feb-07 13:16 
AnswerRe: How do I create 4 MDI child windows at start? Pin
Cengine19-Feb-07 13:24
Cengine19-Feb-07 13:24 
GeneralRe: How do I create 4 MDI child windows at start? Pin
Mark Salsbery19-Feb-07 13:51
Mark Salsbery19-Feb-07 13:51 
QuestionNeed printing help - How to print on 1/4 the part of A4 paper on dot-matrix printer Pin
anand_study19-Feb-07 7:37
anand_study19-Feb-07 7:37 
AnswerRe: Need printing help - How to print on 1/4 the part of A4 paper on dot-matrix printer Pin
Mark Salsbery19-Feb-07 12:11
Mark Salsbery19-Feb-07 12:11 
GeneralRe: Need printing help - How to print on 1/4 the part of A4 paper on dot-matrix printer Pin
anand_study19-Feb-07 16:27
anand_study19-Feb-07 16:27 
GeneralRe: Need printing help - How to print on 1/4 the part of A4 paper on dot-matrix printer Pin
Mark Salsbery20-Feb-07 5:47
Mark Salsbery20-Feb-07 5:47 

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.