Form instances
-
When I run application on PPC,forms draws itself in memory how many times I open it, if I open twice one form it draw itself in memory as two instances. How can I let the application to draw form only single time?
I Love SQL
What development environment are you creating your application in? Typically the template/wizard code for your environment (with Visual Studio atleast) will have inserted code which restricts your application to one instance. You may like to read the following thread on the MSDN Forums website (where the opposite problem is discussed, i.e. how to allow multiple instances) - http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1576750&SiteID=1[^] Basically in the WinMain method of your application you should put some code similiar to the following:
//If it is already running, then focus on the window, and exit hWnd = FindWindow(szWindowClass, szTitle); if (hWnd) { // set focus to foremost child window // The "| 0x00000001" is used to bring any owned windows to the foreground and // activate them. SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001)); return 0; }
The call to find window is used to detect the existing copy of your application based upon it's window class and window title. Just alter the two arguments to match that of your application's main window. Hope it helps, Christopher Fairbairn -
When I run application on PPC,forms draws itself in memory how many times I open it, if I open twice one form it draw itself in memory as two instances. How can I let the application to draw form only single time?
I Love SQL
Try using showDialog() to open up the form. This shows the form as a modal dialog box with the currently active window set as its owner. The form being opened will show only once then, I think..