Doubt about which message handler to use
-
Hello All I am developing an SDI application in VC++ 6.0 on WIndows 2000. I want to read some settings from Database when application comes up. I wrote DB access code in "CMyView::OnInitialUpdate()". It is working fine when DB is accessable. If DB is not accessable due to some problem, my application waits in the starting itself until the DB connection is timed out... after that application displays the Error MessageBox and then the main window is launched. User is unable to know what is going on until he gets the Error Message. I want my application to comeup first and then I want to try to access the DB and I want to put periodic status message to the user to know about what is going on in backend. Please let me know where I can write the code for DB accesss in order to get executed after the main window is displayed. Please note that it is SDI application. Thanks for your time Ravi
-
Hello All I am developing an SDI application in VC++ 6.0 on WIndows 2000. I want to read some settings from Database when application comes up. I wrote DB access code in "CMyView::OnInitialUpdate()". It is working fine when DB is accessable. If DB is not accessable due to some problem, my application waits in the starting itself until the DB connection is timed out... after that application displays the Error MessageBox and then the main window is launched. User is unable to know what is going on until he gets the Error Message. I want my application to comeup first and then I want to try to access the DB and I want to put periodic status message to the user to know about what is going on in backend. Please let me know where I can write the code for DB accesss in order to get executed after the main window is displayed. Please note that it is SDI application. Thanks for your time Ravi
//Define a user message (2008 is Beijing Olympic;P)) #define WM_DELAY_CONNECTDB WM_USER + 2008 BEGIN_MESSAGE_MAP(CXXXView, CView) //... ON_MESSAGE(WM_DELAY_CONNECTDB, OnDelayConnectDB) //... END_MESSAGE_MAP() void CXXXView::OnInitialUpdate() { CView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class //Post the message here PostMessage(WM_DELAY_CONNECTDB); } void CXXXView::OnDelayConnectDB(WPARAM wParam, LPARAM lParam) { //Begin your operation MessageBox("Perform your connecting operation"); } Lane China
-
Hello All I am developing an SDI application in VC++ 6.0 on WIndows 2000. I want to read some settings from Database when application comes up. I wrote DB access code in "CMyView::OnInitialUpdate()". It is working fine when DB is accessable. If DB is not accessable due to some problem, my application waits in the starting itself until the DB connection is timed out... after that application displays the Error MessageBox and then the main window is launched. User is unable to know what is going on until he gets the Error Message. I want my application to comeup first and then I want to try to access the DB and I want to put periodic status message to the user to know about what is going on in backend. Please let me know where I can write the code for DB accesss in order to get executed after the main window is displayed. Please note that it is SDI application. Thanks for your time Ravi
In my opinion ,I don't put code in CMyView::OnInitialUpdate()". It may be better to use a menu named "Link DataBase", the user click the menu ,then the application link to the DB accesss. If access failed ,you can give the user an Error MessageBox . Thus you can put the DB access code in CMyView::On****( ). libo
-
Hello All I am developing an SDI application in VC++ 6.0 on WIndows 2000. I want to read some settings from Database when application comes up. I wrote DB access code in "CMyView::OnInitialUpdate()". It is working fine when DB is accessable. If DB is not accessable due to some problem, my application waits in the starting itself until the DB connection is timed out... after that application displays the Error MessageBox and then the main window is launched. User is unable to know what is going on until he gets the Error Message. I want my application to comeup first and then I want to try to access the DB and I want to put periodic status message to the user to know about what is going on in backend. Please let me know where I can write the code for DB accesss in order to get executed after the main window is displayed. Please note that it is SDI application. Thanks for your time Ravi
Have you considered putting the database-access code in a separate thread? This would allow the primary thread, which owns the GUI, to remain active and responsive.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
Have you considered putting the database-access code in a separate thread? This would allow the primary thread, which owns the GUI, to remain active and responsive.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
Hello All I am accessing DB using user defined message handler. Due to more number of threads i have avoided using one more thread. But thanks for your solution. Have nice time Ravi