don´t run App twice

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: don´t run App twice

Post by serge_girard »

Perfect!
There's nothing you can do that can't be done...
User avatar
fouednoomen
Posts: 186
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: don´t run App twice

Post by fouednoomen »

where i should put this code

#xtranslate IsIconic ( <hWnd> ) => IsMinimized ( <hWnd> )
#xtranslate _Restore( <h> ) => Restore( <h> )
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: don´t run App twice

Post by mol »

Restore of minimazed application works fine.
But if I want to bring it to top - it is still under others

Code: Select all

iif(IsMinimized (hWnd), Restore( hWnd ),	SetForegroundWindow( hWnd ))
What is wrong?
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: don´t run App twice

Post by AUGE_OHR »

hi,

as i wrote you need 4 Step

Code: Select all

      @ User32:SetForegroundWindow( hWndDlg )
      @ User32:BringWindowToTop( hWndDlg )
      @ User32:ShowWindow( hWndDlg, 1 )
      @ User32:UpdateWindow( hWndDlg )
where @ User32 -> User32.DLL

but i don´t want to write it "in" Main, i want to start it "before" Main ...
what about

Code: Select all

INIT PROCEDURE // Declare an initialization procedure
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: don´t run App twice

Post by AUGE_OHR »

hi,

here HMG Version

Code: Select all

STATIC cVersion     := "v0.98"

INIT PROCEDURE MainInit()
LOCAL cTitle  := 'HBFM ' + cVersion
LOCAL hWndDlg := FindWindowEx( ,,, cTitle)
   IF !(hWndDlg == 0)
      SetForegroundWindow(hWndDlg)
      BringWindowToTop(hWndDlg)
      ShowWindow(hWndDlg,1)
      UpdateWindow(hWndDlg)
      QUIT                                // It is a second instance. Bye Bye
   ENDIF
RETURN

PROCEDURE MAIN
have fun
Jimmy
User avatar
fouednoomen
Posts: 186
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: don´t run App twice

Post by fouednoomen »

Please the complete code to use this alternative
User avatar
Anand
Posts: 595
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF

Re: don´t run App twice

Post by Anand »

Complete code by adding Jimmy's code in
c:\MiniGUI\SAMPLES\BASIC\HELLO_WORLD\

Code: Select all

/*
 * Harbour MiniGUI Hello World Demo
 * (c) 2002-2009 Roberto Lopez
 */

#include "minigui.ch"

PROCEDURE Main

	DEFINE WINDOW Win_1		;
		CLIENTAREA 400, 400	;
		TITLE 'Hello World!'	;
		WINDOWTYPE MAIN

	END WINDOW

	Win_1.Center

	Win_1.Activate

RETURN

INIT PROCEDURE MainInit()
LOCAL cTitle  := 'Hello World!'
LOCAL hWndDlg := FindWindowEx( ,,, cTitle)
   IF !(hWndDlg == 0)
      SetForegroundWindow(hWndDlg)
      BringWindowToTop(hWndDlg)
      ShowWindow(hWndDlg,1)
      UpdateWindow(hWndDlg)
      QUIT                                // It is a second instance. Bye Bye
   ENDIF
RETURN

Regards,

Anand
Regards,

Anand

Image
User avatar
fouednoomen
Posts: 186
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: don´t run App twice

Post by fouednoomen »

Now it works fine! THX!
Post Reply