Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Doubt about which message handler to use

Doubt about which message handler to use

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpc++question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ravi Sankar S
    wrote on last edited by
    #1

    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

    L I D 3 Replies Last reply
    0
    • R Ravi Sankar S

      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

      L Offline
      L Offline
      Lane Yu
      wrote on last edited by
      #2

      //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

      1 Reply Last reply
      0
      • R Ravi Sankar S

        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

        I Offline
        I Offline
        Intertherain
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • R Ravi Sankar S

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          R 1 Reply Last reply
          0
          • D David Crow

            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

            R Offline
            R Offline
            Ravi Sankar S
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups