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 button on non vds apps

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


Joined: 30 Jul 2002
Posts: 172

PostPosted: Tue May 11, 2004 8:43 pm    Post subject: Disable close button on non vds apps Reply with quote

Ok first of all I think this is a rather easy api I think. Anyway I'm pleading for someone to convert this to vds code so I may follow it as an example for future api calls not to mention it will help me with a project. Very Happy pleaseeeeee.


[url]
http://www.freevbcode.com/ShowCode.asp?ID=2448
[/url]
Back to top
View user's profile Send private message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Wed May 12, 2004 2:31 am    Post subject: Reply with quote

Hi bbelcher
You can take a look at this code I posted a while ago.
http://forum.vdsworld.com/viewtopic.php?t=1710

or get the file here:
http://www.vdsworld.com/search.php?keywords=disable%20close%20button&match_type=1

If you want more API examples you may take a look at
http://codescript.vdsworld.com

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed May 12, 2004 8:36 am    Post subject: Reply with quote

It may be handy to create a little topic about converting API calls from other languages into VDS syntax. How does this look with the example code which bbelcher gave?


Declarations wrote:
Option Explicit

Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long

Private Const MF_BYPOSITION = &H400&


Code wrote:
Public Function DisableCloseButton(frm As Form) As Boolean

'PURPOSE: Removes X button from a form
'EXAMPLE: DisableCloseButton Me
'RETURNS: True if successful, false otherwise
'NOTES: Also removes Exit Item from
' Control Box Menu


Dim lHndSysMenu As Long
Dim lAns1 As Long, lAns2 As Long


lHndSysMenu = GetSystemMenu(frm.hwnd, 0)

'remove close button
lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION)

'Remove seperator bar
lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION)

'Return True if both calls were successful
DisableCloseButton = (lAns1 <> 0 And lAns2 <> 0)

End Function


First of all, you need to look which DLLs are used and open them which the loadlib function. In this case, it is the user32.dll, so we need that one. At the declarations code, you see a long line with the name of the function, the dll name, the parameters between brackets and last off all the type of the stuff returned by the API. Now, let us convert the code into VDS language:

Code:
#define function,DisableCloseButton

if @DisableCloseButton(<your window name here>)
  info The close button is disabled.
else
  warn The close button IS NOT disabled.
end

exit

# Public Function DisableCloseButton(frm As Form) As Boolean
:DisableCloseButton
# Because VDS can't give functions parameters like "frm", we should change %1 info %%frm
%%frm = %1

# Load the proper library
loadlib user32.dll

# 'PURPOSE: Removes X button from a form
# 'EXAMPLE: DisableCloseButton Me
# 'RETURNS: True if successful, false otherwise
# 'NOTES:   Also removes Exit Item from
# '         Control Box Menu

# We don't have to declare variables, so just rem-them-out... Smile We do have to 'declare' the
# pre-made variables from within the declarations code, so we can use their values. Note that &H
# should be converted into a $ sign, and that the last & can be left away.

# Dim lHndSysMenu As Long
# Dim lAns1 As Long, lAns2 As Long
# Private Const MF_BYPOSITION = &H400&
%%MF_BYPOSITION = $400

# Because in VB API code is declared, the dll name and parameter type don't have to be declared in the
# script itself. Because that isn't the case with VDS, we should use the following lines of VB code:
#
# Private Declare Function GetSystemMenu Lib "user32" _
#     (ByVal hwnd As Long, _
#      ByVal bRevert As Long) As Long
#
# This is about the same syntax as the @lib() function. The @lib() function should be called like this:
# @lib(<dll name>,<function name>,<return type>,<parameters>,<...>)
#
# When filling it in, you get this:
# @lib(user32.dll,GetSystemMenu,INT: (the VDS equivement of LONG),%%hwnd,%%bRevert)
#
# Now, just use the same variables as the VB code:

# lHndSysMenu = GetSystemMenu(frm.hwnd, 0)
%%frm_hwnd = @strdel(@winexists(%%frm),1,1)
%%lHndSysMenu = @lib(user32,GetSystemMenu,INT:,%%frm_hwnd,0)

# 'remove close button
# lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION)
%%lAns1 = @lib(user32.dll,RemoveMenu,INT:,%%lHndSysMenu,6,%%MF_BYPOSITION)

# 'Remove seperator bar
# lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION)
%%lAns2 = @lib(user32.dll,RemoveMenu,INT:,%%lHndSysMenu,5,%%MF_BYPOSITION)

# Unload the library
freelib user32.dll

# 'Return True if both calls were successful
# DisableCloseButton = (lAns1 <> 0 And lAns2 <> 0)
# End Function
exit @both(%%lAns1,%%lAns2)


I hope it is understandable, otherwise, could somebody maybe write another example for people to learn how to use API functions? Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Wed May 12, 2004 11:19 am    Post subject: Reply with quote

AHHH things are starting to become clear.. Surprised
Back to top
View user's profile Send private message
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