forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Disable Close (x) of an Apps Title Bar

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
chucks0
Newbie


Joined: 08 Jun 2002
Posts: 23

PostPosted: Thu Jun 20, 2002 2:03 am    Post subject: Disable Close (x) of an Apps Title Bar Reply with quote

We have an application that leaves files open when a users uses the Window Close button (the X in the title bar) to exit rather than choosing File / Exit. Does anyone know if there is a way to use @sendmsg to disable the close button of a running application so that users must choose File / Exit?
Back to top
View user's profile Send private message
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Thu Jun 20, 2002 5:48 am    Post subject: Reply with quote

It may be possible using the WND CLOSEMENU command of my VDSWND DLL, part of the VDSDLL 3.

Tommy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Jun 20, 2002 6:03 am    Post subject: Reply with quote

Why not do the simple thing? - let the :CLOSE section return to the appropriate place in the app.

For instance like this:

Code:
:CLOSE
   info You must close this application by choosing File > Exit
   goto loop
:closeMENU
  exit


Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
chucks0
Newbie


Joined: 08 Jun 2002
Posts: 23

PostPosted: Thu Jun 20, 2002 10:12 pm    Post subject: Reply with quote

I would use the close section of the VDS app except that I am talking about disabling the close button of a Non-VDS app. I did find the appropriate @sendmsg api call that will let me change the title a window, but I can't find the appropriate message that will disable the close button.


Charles
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Jun 20, 2002 10:36 pm    Post subject: Reply with quote

Could you give us a few more details? Is the program
leaving files open in a word processor, etc? If so you
might start your program from a VDS frontend that
could monitor it's existence, then close the appropriate
apps when it closed. Without more details, I'm just
kinda guessing here....

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
chucks0
Newbie


Joined: 08 Jun 2002
Posts: 23

PostPosted: Thu Jun 20, 2002 11:19 pm    Post subject: Reply with quote

Actually, the application is a student management system that leaves a lot of DB4 database files open. As long as the users use File / Quit to exit, the database files are closed. I can always resort to using API calls from Delphi or Visual Basic, but I prefer the simplicity of VDS.
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jun 21, 2002 12:42 am    Post subject: Reply with quote

Well, you're gonna need a front-end that starts the
program, waits for it to open, then disables the close
button anyway...

A VDS app could keep a list of all windows opened
AFTER the program was started, then close them all
when the program closed (might be a problem if other
programs were supposed to be left open though). You
could also check for INI files or REG entries that contain
the name of any apps the program has opened.

You might be able to get the windows message codes
(the numbers used by @sendmsg) from VB or Delphi
header files, but I'm not sure about that. I'd love to
have a complete list of them myself.

BTW, I couldn't find anything but an API "function" to
change a window's style (SetWindowLong), although
there are a couple of messages to notify the window
before and after the change (WM_STYLECHANGING
and WM_STYLECHANGED). But I may have missed
something.

Also, not all API messages will work from VDS.
Good luck on this one.

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
chucks0
Newbie


Joined: 08 Jun 2002
Posts: 23

PostPosted: Fri Jun 21, 2002 1:39 am    Post subject: Reply with quote

I can disable the X in Delphi with the following code:

var
hwndHandle : THANDLE;
hMenuHandle : HMENU;

begin
hwndHandle := FindWindow(nil, PChar(ParamStr(1)));
if (hwndHandle <> 0) then begin
hMenuHandle := GetSystemMenu(hwndHandle, FALSE);
if (hMenuHandle <> 0) then
DeleteMenu(hMenuHandle, SC_CLOSE, MF_BYCOMMAND);
end;

end.


I wrote it to read the Title Bar from the command line and then find the specified window and disable its close button.

Ex: remclose.exe "Untitled - Notepad"

This works great. Now I just need to create some kind of Launcher program that will load the student management system, wait for it to load completely, then disable the x.
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jun 21, 2002 1:48 am    Post subject: Reply with quote

You could run the management program from VDS,
then use a REPEAT loop (with a WAIT) to check for the
existence of the management program window. You
might also want the loop to "time out" after a couple
of minutes in case the program doesn't load.

Once the window is detected, run your Delphi program
and exit the VDS front-end.

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jun 21, 2002 2:43 am    Post subject: Reply with quote

Here's a simple example of what I meant. Depending on
your Delphi program, you might have to use the actual
window title enclosed in quotes instead of the %%title
var.
__________________________________________________________________________________________________________________________
Code:

%%program = "Student management program path\filename goes here"
%%title = "title bar name of %%program goes here"
%%utility = "Delphi program path\filename goes here"

rem -- Check for 2 minutes (120 seconds) --
%x = 0
REPEAT
  WAIT
  %x = @succ(%x)
UNTIL @greater(%x, 120)@winexists(%%title)

rem -- Use any one that works for you (can also use RUNH, RUNM, RUNZ) --
if @winexists(%%title)
   rem -- If no spaces in path\filename --
   rem RUN %%utility %%title

   rem -- If spaces ARE in path\filename, use @shortname() with RUN --
   rem RUN @shortname(%%utility) %%title

   rem -- Or use the SHELL command --
   rem SHELL OPEN, %%utility, %%title
end

rem -- Always use a CLOSE label. Windows looks for
rem -- this if the program is running at shutdown.
:CLOSE
  EXIT


Cheers, Mac

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group