home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / mswindo / programm / misc / 4723 < prev    next >
Encoding:
Text File  |  1993-01-07  |  993 b   |  34 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!mcsun!fuug!pcuf!news
  3. From: turre@pcuf.fi (Jarkko Turunen)
  4. Subject: Enabling the first and only window in MFC
  5. Message-ID: <C0Fyw0.3pq@pcuf.fi>
  6. Sender: news@pcuf.fi (News)
  7. Nntp-Posting-Host: pcuf.fi
  8. Organization: The PC-users of Finland
  9. Date: Wed, 6 Jan 1993 16:52:47 GMT
  10. Lines: 22
  11.  
  12. I want user not to be able to run many instances of my application. So if
  13. he tries to run another instance my program should bring the first
  14. instance to top. I've been trying it with this following code:
  15.  
  16. BOOL CMyApp::InitInstance()
  17. {
  18.     If( m_hPrevInstance != NULL )
  19.     {
  20.         m_pMainWindow->BringWindowToTop();
  21.         return FALSE;
  22.     }
  23.     else
  24.     {
  25.         m_pMainWindow = new CMyWindow;
  26.         m_pMainWindow->ShowWindow( m_nCmdShow );
  27.         m_pMainWindow->UpdateWindow();
  28.         return TRUE;
  29.     }
  30. }
  31.  
  32. The first instance runs fine and no other instances are displayed or created
  33. but the first windows is not brought to the top.
  34.