Closing Application from PB Application

Hi everybody,
I'm trying to find solition for the following. I'm trying to close running
application (for example PB application or any other) from another running
application (PB application).
I tried using GetModuleName Win API function to get handle of the
application and then tried to close it using CloseWindoe function - it
didn't work. Also tried to send and post messages using value for
WM_SYSCOMMAND and SC_CLOSE message - still the same negative result.
Does anybody have solution for that looks like simple thing. Unfortunately
Powerbuilder allows you to start application using run function, but didn't
provide mechanizm to close it.
Your advice would be very helpful.

Thanks,

Dmitri


0
Dmitri
3/11/1998 5:17:17 PM
sybase.powerbuilder.general 62418 articles. 18 followers. Follow

4 Replies
1117 Views

Similar Articles

[PageSpeed] 14

On Wed, 11 Mar 1998 12:17:17 -0500, in
powersoft.public.powerbuilder.general "Dmitri Ilyin"
<dilyin@muller.com> wrote:

>Hi everybody,
>I'm trying to find solition for the following. I'm trying to close running
>application (for example PB application or any other) from another running
>application (PB application).
>I tried using GetModuleName Win API function to get handle of the
>application and then tried to close it using CloseWindoe function - it
>didn't work. Also tried to send and post messages using value for
>WM_SYSCOMMAND and SC_CLOSE message - still the same negative result.
>Does anybody have solution for that looks like simple thing. Unfortunately
>Powerbuilder allows you to start application using run function, but didn't
>provide mechanizm to close it.
>Your advice would be very helpful.

Dmitri,

Try sending a WM_CLOSE message to the frame / main application window.

Use FindWindow API to get the handle of the frame window.

int WM_CLOSE = 16
Send(ul_handle, WM_CLOSE, 0, 0)

HTH,
--
Boris Gasin [TeamPS]	
mailto:bgasin@advent2000.com

Have a heart,
http://home.sprynet.com/sprynet/JCredit/eds_stry.htm
0
NOSPAM_bgasin
3/11/1998 7:01:53 PM
Thanks for advice Boris,
This is unfortunately true for static Task (i.e. when title of the app
window is unchangable) when you can get handle of the app based on the
title. But when title is changebla (for example when title reflects
scrolling through the datawindow and shows current scrolled row out of some
number of rows) then usage of the title becomes impossible but without it to
get handle becomes questionable. I wonder how Task Window gets handles of
the running applications and then based on them displays their titles. I
think there has to be funvtion in Windows API to do that -- to get handles
of all running apps and based on them get titles of the applications. Then
you can use title of the application to decide which one is supposed to be
closed.

Dmitri

Boris Gasin [TeamPS] wrote in message
<350bde39.2348916523@forums.powersoft.com>...
>On Wed, 11 Mar 1998 12:17:17 -0500, in
>powersoft.public.powerbuilder.general "Dmitri Ilyin"
><dilyin@muller.com> wrote:
>
>>Hi everybody,
>>I'm trying to find solition for the following. I'm trying to close running
>>application (for example PB application or any other) from another running
>>application (PB application).
>>I tried using GetModuleName Win API function to get handle of the
>>application and then tried to close it using CloseWindoe function - it
>>didn't work. Also tried to send and post messages using value for
>>WM_SYSCOMMAND and SC_CLOSE message - still the same negative result.
>>Does anybody have solution for that looks like simple thing. Unfortunately
>>Powerbuilder allows you to start application using run function, but
didn't
>>provide mechanizm to close it.
>>Your advice would be very helpful.
>
>Dmitri,
>
>Try sending a WM_CLOSE message to the frame / main application window.
>
>Use FindWindow API to get the handle of the frame window.
>
>int WM_CLOSE = 16
>Send(ul_handle, WM_CLOSE, 0, 0)
>
>HTH,
>--
>Boris Gasin [TeamPS]
>mailto:bgasin@advent2000.com
>
>Have a heart,
>http://home.sprynet.com/sprynet/JCredit/eds_stry.htm


0
Dmitri
3/13/1998 7:45:58 PM
Dmitry,

Sorry for the late reply, just noticed your message... 

There may be a better way to get the "Dynamic Title" application
window handle, but here is one way I picked up from Bill Green.

How to get the main window handle if the window title is changing. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ( For example in Word when the window is maximized the sheet title is
appended to the frame title )

The idea is to loop through all the main windows comparing the window
classname  and title to the one you are looking for.  The difference
from FindWindow approach is that you can truncate the window title,
thus eliminating the variable component.

This can be accomplished through the use of a couple of API calls.

1. GetDesktopWindow will give you a handle of the desktop area.  The
desktop is the parent of all the main windows.  

2. Get a handle of the first desktop child by using GetWindow(xx,
GW_CHILD)

3. Loop through the rest of the children (1st child siblings) by using
GetWindow(xx, GW_HWNDNEXT).  Compare the tiles and classnames to the
ones you are looking for.

Here is some sample code:

API Declarations
=============
FUNCTION ulong GetDesktopWindow() Library "user32.dll"
FUNCTION ulong GetWindow(ulong hwnd, uint fuDirection)  Library
"user32.dll"
FUNCTION int GetClassNameA(ulong hwnd, ref string  lpClassName, int
length)  Library "user32.dll"
FUNCTION int GetWindowTextA(ulong hwnd,  ref string wintext, int
length)  Library "user32.dll"
=============



Main Window handle code.
=============
ulong lul_hndl, lul_desktophndl
int li_rc, li_titlelen

uint GW_HWNDNEXT  = 2
uint GW_CHILD     = 5

string ls_pbclassname
string ls_winclassname, ls_title

// The frame class name for < 5.0.03 is FNWND050
// The frame class name for 5.0.03 is FNWND350
ls_pbclassname =  "FNWND050"

ls_winclassname = Space(9) // Len("FNWND050") + null terminator
li_titlelen = len(is_frametitle) + 1
ls_title = Space(li_titlelen)

// Get a handle to the desktop
lul_hndl = GetDesktopWindow()

// Get a handle to the first child
lul_hndl = GetWindow(lul_hndl, GW_CHILD)

DO WHILE lul_hndl <> 0
	li_rc = GetClassNameA(lul_hndl, ls_winclassname, 9)
		IF  ls_pbclassname = ls_winclassname THEN
			li_rc = GetWindowTextA(lul_hndl, ls_title,
li_titlelen)
			IF Lower(ls_title) =
Left(Lower(as_frametitle), Len(ls_title)) THEN
				// found target window
				// ... do some processing
			END IF
		END IF
	// Get a handle to the next child
	lul_hndl = GetWindow (lul_hndl, GW_HWNDNEXT)
LOOP
....


The above code is available from
http://www.advent2000.com/techcrnr/isapprunning.htm

The app above uses the approach as one of 5 possible ways to detect a
previous PB app instance.

HTH,

--
Boris Gasin [TeamPS]	
mailto:bgasin@advent2000.com

Have a heart,
http://home.sprynet.com/sprynet/JCredit/eds_stry.htm




On Fri, 13 Mar 1998 14:45:58 -0500, in
powersoft.public.powerbuilder.general "Dmitri Ilyin"
<dilyin@muller.com> wrote:

>Thanks for advice Boris,
>This is unfortunately true for static Task (i.e. when title of the app
>window is unchangable) when you can get handle of the app based on the
>title. But when title is changebla (for example when title reflects
>scrolling through the datawindow and shows current scrolled row out of some
>number of rows) then usage of the title becomes impossible but without it to
>get handle becomes questionable. I wonder how Task Window gets handles of
>the running applications and then based on them displays their titles. I
>think there has to be funvtion in Windows API to do that -- to get handles
>of all running apps and based on them get titles of the applications. Then
>you can use title of the application to decide which one is supposed to be
>closed.
>
>Dmitri
>
>Boris Gasin [TeamPS] wrote in message
><350bde39.2348916523@forums.powersoft.com>...
>>On Wed, 11 Mar 1998 12:17:17 -0500, in
>>powersoft.public.powerbuilder.general "Dmitri Ilyin"
>><dilyin@muller.com> wrote:
>>
>>>Hi everybody,
>>>I'm trying to find solition for the following. I'm trying to close running
>>>application (for example PB application or any other) from another running
>>>application (PB application).
>>>I tried using GetModuleName Win API function to get handle of the
>>>application and then tried to close it using CloseWindoe function - it
>>>didn't work. Also tried to send and post messages using value for
>>>WM_SYSCOMMAND and SC_CLOSE message - still the same negative result.
>>>Does anybody have solution for that looks like simple thing. Unfortunately
>>>Powerbuilder allows you to start application using run function, but
>didn't
>>>provide mechanizm to close it.
>>>Your advice would be very helpful.
>>
>>Dmitri,
>>
>>Try sending a WM_CLOSE message to the frame / main application window.
>>
>>Use FindWindow API to get the handle of the frame window.
>>
>>int WM_CLOSE = 16
>>Send(ul_handle, WM_CLOSE, 0, 0)
>>
>>HTH,
>>--
>>Boris Gasin [TeamPS]
>>mailto:bgasin@advent2000.com
>>
>>Have a heart,
>>http://home.sprynet.com/sprynet/JCredit/eds_stry.htm
>

0
NOSPAM_bgasin
3/17/1998 8:29:12 PM
Thanks Boris,

It works fine. The only thing I had to do is to change a little bit code to
handle 16 bit environment.

Dmitri

Boris Gasin [TeamPS] wrote in message
<350ed38d.20283385@forums.powersoft.com>...
>Dmitry,
>
>Sorry for the late reply, just noticed your message...
>
>There may be a better way to get the "Dynamic Title" application
>window handle, but here is one way I picked up from Bill Green.
>
>How to get the main window handle if the window title is changing.
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ( For example in Word when the window is maximized the sheet title is
>appended to the frame title )
>
>The idea is to loop through all the main windows comparing the window
>classname  and title to the one you are looking for.  The difference
>from FindWindow approach is that you can truncate the window title,
>thus eliminating the variable component.
>
>This can be accomplished through the use of a couple of API calls.
>
>1. GetDesktopWindow will give you a handle of the desktop area.  The
>desktop is the parent of all the main windows.
>
>2. Get a handle of the first desktop child by using GetWindow(xx,
>GW_CHILD)
>
>3. Loop through the rest of the children (1st child siblings) by using
>GetWindow(xx, GW_HWNDNEXT).  Compare the tiles and classnames to the
>ones you are looking for.
>
>Here is some sample code:
>
>API Declarations
>=============
>FUNCTION ulong GetDesktopWindow() Library "user32.dll"
>FUNCTION ulong GetWindow(ulong hwnd, uint fuDirection)  Library
>"user32.dll"
>FUNCTION int GetClassNameA(ulong hwnd, ref string  lpClassName, int
>length)  Library "user32.dll"
>FUNCTION int GetWindowTextA(ulong hwnd,  ref string wintext, int
>length)  Library "user32.dll"
>=============
>
>
>
>Main Window handle code.
>=============
>ulong lul_hndl, lul_desktophndl
>int li_rc, li_titlelen
>
>uint GW_HWNDNEXT  = 2
>uint GW_CHILD     = 5
>
>string ls_pbclassname
>string ls_winclassname, ls_title
>
>// The frame class name for < 5.0.03 is FNWND050
>// The frame class name for 5.0.03 is FNWND350
>ls_pbclassname =  "FNWND050"
>
>ls_winclassname = Space(9) // Len("FNWND050") + null terminator
>li_titlelen = len(is_frametitle) + 1
>ls_title = Space(li_titlelen)
>
>// Get a handle to the desktop
>lul_hndl = GetDesktopWindow()
>
>// Get a handle to the first child
>lul_hndl = GetWindow(lul_hndl, GW_CHILD)
>
>DO WHILE lul_hndl <> 0
> li_rc = GetClassNameA(lul_hndl, ls_winclassname, 9)
> IF  ls_pbclassname = ls_winclassname THEN
> li_rc = GetWindowTextA(lul_hndl, ls_title,
>li_titlelen)
> IF Lower(ls_title) =
>Left(Lower(as_frametitle), Len(ls_title)) THEN
> // found target window
> // ... do some processing
> END IF
> END IF
> // Get a handle to the next child
> lul_hndl = GetWindow (lul_hndl, GW_HWNDNEXT)
>LOOP
>...
>
>
>The above code is available from
>http://www.advent2000.com/techcrnr/isapprunning.htm
>
>The app above uses the approach as one of 5 possible ways to detect a
>previous PB app instance.
>
>HTH,
>
>--
>Boris Gasin [TeamPS]
>mailto:bgasin@advent2000.com
>
>Have a heart,
>http://home.sprynet.com/sprynet/JCredit/eds_stry.htm
>
>
>
>
>On Fri, 13 Mar 1998 14:45:58 -0500, in
>powersoft.public.powerbuilder.general "Dmitri Ilyin"
><dilyin@muller.com> wrote:
>
>>Thanks for advice Boris,
>>This is unfortunately true for static Task (i.e. when title of the app
>>window is unchangable) when you can get handle of the app based on the
>>title. But when title is changebla (for example when title reflects
>>scrolling through the datawindow and shows current scrolled row out of
some
>>number of rows) then usage of the title becomes impossible but without it
to
>>get handle becomes questionable. I wonder how Task Window gets handles of
>>the running applications and then based on them displays their titles. I
>>think there has to be funvtion in Windows API to do that -- to get handles
>>of all running apps and based on them get titles of the applications. Then
>>you can use title of the application to decide which one is supposed to be
>>closed.
>>
>>Dmitri
>>
>>Boris Gasin [TeamPS] wrote in message
>><350bde39.2348916523@forums.powersoft.com>...
>>>On Wed, 11 Mar 1998 12:17:17 -0500, in
>>>powersoft.public.powerbuilder.general "Dmitri Ilyin"
>>><dilyin@muller.com> wrote:
>>>
>>>>Hi everybody,
>>>>I'm trying to find solition for the following. I'm trying to close
running
>>>>application (for example PB application or any other) from another
running
>>>>application (PB application).
>>>>I tried using GetModuleName Win API function to get handle of the
>>>>application and then tried to close it using CloseWindoe function - it
>>>>didn't work. Also tried to send and post messages using value for
>>>>WM_SYSCOMMAND and SC_CLOSE message - still the same negative result.
>>>>Does anybody have solution for that looks like simple thing.
Unfortunately
>>>>Powerbuilder allows you to start application using run function, but
>>didn't
>>>>provide mechanizm to close it.
>>>>Your advice would be very helpful.
>>>
>>>Dmitri,
>>>
>>>Try sending a WM_CLOSE message to the frame / main application window.
>>>
>>>Use FindWindow API to get the handle of the frame window.
>>>
>>>int WM_CLOSE = 16
>>>Send(ul_handle, WM_CLOSE, 0, 0)
>>>
>>>HTH,
>>>--
>>>Boris Gasin [TeamPS]
>>>mailto:bgasin@advent2000.com
>>>
>>>Have a heart,
>>>http://home.sprynet.com/sprynet/JCredit/eds_stry.htm
>>
>


0
Dmitri
3/18/1998 9:48:11 PM
Reply:

Similar Artilces:

PB Application to PB Application communication
I need to have 2 powerbuilder application be able to communicate with one another. A string is all I need to pass between the two applications. I tried creating a com object that I could connect to from both applications. This com object would basically store the information I want to pass between the two applications in an instance variable. One application would populate that instance variable, then notify the other application(through the send command) to go read the information in the com object. I created the com object fine and can call a function on the com object ...

Application to Application
Hi,  Curious on what different solutions there are for one application that is closing down to contact another application. I have the closing down applicaton sending something to the database and for the other application to monitor the database records, but I think that is a horrible solution. Another idea would be when the closing down application sends a message to the database for the database to then respond by sending a message to the other application, but that means the database would have to know where the other application is.  If possible, the security issue mak...

SQLCA works when application runs in PB not when application is run with Powerbuilder WDK.
Hi, My applications with out SQLCA run great through Powerbuilder WDK, my applications that contain SQLCA information doesn't. When I run the application in PB I get a splash screen and then the application starts. When I run it through PB WDK the splash screen starts and the I get a login box. No matter what I do it always show's up and when I hit OK I get the following SQLSTATE = 08001 error. How can I stop this from occurring? The SQLCA code and ini file are below. code: startupfile = "pds.ini" /* Populate sqlca from current PB.INI settings */ sqlca.DBMS...

Frontend PB application for a mainframe General Ledger application using Platinum Infosession
Hi, I am trying to get a project to write a frontend PB GUI application for a mainframe General Ledger. I have succeeded to make an example for a login and CEMT list + update of CICS programs. The customer requires me to do an example based on a very small part of the General Ledger so that he can demonstrate to his colleagues this is viable and this will remove the necessity of training for the users to pass through natural and cumbersome mainframe screens to reach general ledger. They intend to have the whole of general ledger to get a GUI interface... My question is: Th...

pb application deployment of application
ver 10.5 is there an easy way of finding which pb runtime files i need to deploy with my application to create an installation for a customer First of all, check out the PB runtime packager, and documentation in HTML books under application techniques, chapter 40. You can also use tools like process explorer (www.sysinternals.com - now Microsoft) that lists the active DLL's used by an application. Including tools like Dependency Walker (www.dependencywalker.com). (That even integrates with Process Explorer.) Regards Andr� P� Wed, 21 Feb 2007 12:04:10 +0100, sk...

PB 11.5 application is lower than the same application on PB 9
Hi, We have recently migrated our full source from PB 9 to PB 11.5. We found that the program is running extremely slow. We noticed that it happens mostly when using GUI. There are delays even when tabbing though controls on the screen. We run tracing on both environments, and most of the functions show that the response time is better in PB 11.5, but the experience of using PB11.5 application is very slow anyway. Has anyone experienced the same? On Aug 21, 9:13=A0am, chaau <andrew.chered...@gmail.com> wrote: Sorry, typo in the title. Should be PB 11.5 application is slo...

Powerbuilder application "crashing" another powerbuilder application
This is a repost of the above subject since there has been some problem for messages posted on the 19th - 22nd July 2002. *************** Hi All, I have an application (App A)built using PB7.0.3 build 10077 and it seems to work fine. However, recently, another application (App B) built using PB 7.0.3 build 10047 as well was installed and it seems to trigger Dr Watson on App A. There is an embedded OCX on a "main" window on App A, which receives triggers from external applications. The OCX will then call another function sitting on another main window. That function w...

PB is closed when I open the PB objects in a Application
Hi all I am using PB 7.0.3 Build 10312, and Windows 2000 Professional OS When I login as administrator in windows, and when I try to open the PB objects the PB is showing error ("pb70.exe - Application Error, The instruction at "0x104a98ac" referenced memory at "0x00000000". The memory could not be "read". Click on OK to terminate the program. Click on CANCEL to debug the program")and once I click on the OK button the PB is getting closed. Rebuilding the application is not showing any errors. The regeneration of the object is also successful....

Calling internet enabled PB application from Client Server PB Application
Is it possible to call a internet enabled PB application from a Client-Server PB app? (Just like the way using RUN function to run another app from PB app) Thx, Mahesh This newsgroup is for discussing enhancement requests for future versions of PowerBuilder. You will get a much more relevant reponse if you post in one of the other newsgroups, for example: powersoft.public.powerbuilder.distributed or powersoft.public.powerbuilder.general <Mahesh> wrote in message news:E66A29615A1F68F4006837D685256BC8.006837E685256BC8@webforums... > Is it possible to call a internet...

Calling internet enabled PB application from Client Server PB Application
Is it possible to call a internet enabled PB application from a Client-Server PB app? (Just like the way using RUN function to run another app from PB app) Thx, Mahesh If I understand you correctly, you can add teh Microsoft Internet Explorer ole object to a window and have it browse to the site housing the PB appliation just like it would to any other site. See this technote for details on browsing automatically etc. http://my.sybase.com/detail?id=47945 - Joe Slawsky (NOSPAMFORME_jslawsky@planetdx.com) www.planetdx.com ...

Closing an server application from client application
Hi, Any Help ? The way we start an application by a run function from powerbuilder ,like run ( clock.exe) How do I close the server application from the client application in distributed environment in powerbuilder ? Thanks Jeetu You would need to call a method on the server application, and the server application would need to close itself. On Tue, 30 Mar 1999 22:09:16 -0800, in powersoft.public.powerbuilder.powerscript Jeetu <spani@hcltech.com> wrote: >Hi, > >Any Help ? > > The way we start an application by a run function from power...

Calling PB application from other web application
Friends, I have a situation here. I have a powerbuilder 7.0 application with windows, datawindows and database access. NOw, the management needs this powerbuilder application to be called by another web application. I would appreciate if you could give me the possible solutions. Thanks in advance, Saravanan I responded to this in another section. Please don't cross-post. On Thu, 14 Sep 2000 12:31:28 -0700, in powersoft.public.powerbuilder.pfc Saravanan Gurusamy <sarav_g@hotmail.com> wrote: >Friends, > I have a situation here. I have a power...

PB Applications converted to Web Applications
We have a number(3) of large PB7.0 applications that we are looking to migrate to the web. I know that we can take advantage of the DW in the applications (using HTML DW), but what about the other objects, both visual and non-visual. Are there currently any tools for generating web-applicable objects from existing PB objects other than DWs and are there any plans to do this in the future? My understanding is that the WDK only works for LAN, WAN and intranet not internet access, so this will not work for us. Any information would be appreciated, I am looking to leverage as m...

Testing a PFC application (or any PB application)
Hi! I just want to have a few tips on how testing a PFC application should be done. With all the events that occurs in an application, it is sometimes hard to trap every single thing that could happen at anytime! What do you think are the basics steps that for testing an application? What simple things should be considered when coding the application? When you code the application, do you consider all the possible cases at the moment or you put them off until a "testing phase"? What is the best way to activate or deactive menu items while the application is running ...

Web resources about - Closing Application from PB Application - sybase.powerbuilder.general

Application - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Welfare experiment may have applications in Australia
A trial in Finland providing an obligation-free basic income could change how we think about welfare.

AVO application against Labor's Jamie Clements withdrawn
An application for an apprehended violence order against Labor powerbroker Jamie Clements - based on allegations he tried to kiss a female staffer ...

Patent application shows Apple Watch band that transforms into a case, stand and Mac accessory
An Apple patent application published today reveals an idea for an interesting variation on the magnetically-closed Milanese Loop band that allows ...

Seagate Introduces First 8 TB Hard Disk Drive for Consumer NAS Applications
Seagate Technology on Tuesday introduced its new breed of hard disk drives (HDDs) for network area storage (NAS) and RAID applications. The new ...

MBA: Mortgage Applications Increased in Latest Weekly Survey, Purchase Applications up 19% YoY
From the MBA: Mortgage Applications Increase in Latest MBA Weekly Survey Mortgage applications increased 21.3 percent from one week earlier, ...

Mortgage applications sink after rush
A Fed rate hike pulled mortgage demand forward, and made for a steep drop-off in the past two weeks.

SURPRISE! Mizzou Sees Application Drop After Days Of Protests, Illusory Klan Hoods, Poop Swastika
SURPRISE! Mizzou Sees Application Drop After Days Of Protests, Illusory Klan Hoods, Poop Swastika

In Application To Move To Los Angeles, Rams Shit All Over City Of St. Louis
... to relocate to the greater Los Angeles metropolitan area. The relocation would be effective for the 2016 NFL League Year.” The Rams’ full application ...

Seagate pushing non-PC storage for 2016 with focus on surveillance applications
... products for cloud computing, consumer electronics, surveillance and enterprise storage for 2016. Seagate expects surveillance-related applications ...

Resources last updated: 1/17/2016 3:48:01 AM