:Start of App1
![]() | ![]() |
|---|
If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.
#
# DragonSphere Software's Home Page
#
# All Source Files for this demo
###############################################################################
# #
# This is a demo of how to use GadgetX'es Whiteboard, Window properties, #
# and message hooks to share data between App1, App2, and App3 with the use #
# of a file or the Windows Registry. Also it shows how to add a little #
# security using a random number with the VDS function @encrypt #
# #
###############################################################################
#
#
#This demo requires app2.dsc
#This demo requires app3.dsc
#
Option Decimalsep,.
Title App1
If @Greater(@Name(@Sysinfo(DSVER)),4)
External GadgetX.dll,@SYSINFO(DSVER)
# Commands for use with Gadgetx.dll
#DEFINE COMMAND,GADGETX,FREEDLL,DEFINE,SET,CALL,SETWIN,SETMSG,WHITEBOARD
# Functions for use with Gadgetx.dll
#DEFINE FUNCTION,GADGETX,LOADDLL,GET,CALL,GETMSG,GETWIN,WHITEBOARD
Else
Warn This example is designed for VDS 5.x and later.
Stop
End
Rem Define a custom user API message and save it as a the USERINFO constant.
Define Constant,USERINFO,@GetMsg(New,"USERINFO")
Rem Define the MESSAGE INFO structure
Define Structure,msg,Handle|hwndfrom,DWORD|id,DWORD|WPARAM,DWORD|LPARAM
:MAIN
DIALOG CREATE,My App,-1,0,272,186,,CLASS App1
REM *** Modified by Dialog Designer on 4/3/2004 - 21:57 ***
DIALOG ADD,BUTTON,BUTTON1,135,31,64,24,Submit
DIALOG ADD,BUTTON,BUTTON2,136,149,64,24,Quit
DIALOG ADD,TEXT,TEXT1,19,38,,,Click submit to send data
DIALOG ADD,TEXT,USERNAME,53,14,,,User Name:
DIALOG ADD,TEXT,PASSWORD,80,15,,,Password:
DIALOG ADD,EDIT,USERNAMEedt,48,74,142,20,jkinsey
DIALOG ADD,EDIT,PASSWORDedt,80,74,142,19
DIALOG ADD,STATUS,STATUS1,STATUS1
DIALOG SHOW
%%Main_hwnd = @Strdel(@winexists(#App1),1)
SetWin Property,#App1,StatusText,STATUS1
Rem Ok Gadget has another trick it can also trap messages comming from the
rem Main Window Procedure...
SetMsg
Rem Ok lets tell gadget what messages to watch for....
SetMsg watchwndmsg,@Get(USERINFO)
Rem Now tell gadget to set the hook... Gadget will generate an event
rem called WNDPROC everytime it see's the messages WM_COMMAND and WM_SYSCOMMAND
rem as stated above for the Main Window Proceedure....
%%WNDPROC = @GetMsg(WNDPROC,#App1,"WNDPROC")
:evloop
wait event,0.001
%E = @event()
If %E
Goto %E
End
goto evloop
:TIMER
%%newstatus = @GetWin(Property,#App1,StatusText)
If @Not(@Equal(%%newstatus,%%oldstatus))
Dialog set,STATUS1,%%newstatus
%%oldstatus = %%newstatus
end
goto evloop
:BUTTON1BUTTON
If @winexists(#App2)
Rem Get a random number to encrypt with
%P = @random(2500,99999)
Rem Write some data to Gadget's WhiteBoard
WhiteBoard Set,@dlgtext(USERNAMEedt)|@encrypt(@dlgtext(PASSWORDedt),%P)
Rem Tell App3 that there is some data on the WhiteBoard waiting for it.
rem and pass it the window handle and the decryption value from above
rem so it can decrypt the password on the other end.
%A = @Sendmsg(@winexists(#App2),@Get(USERINFO),%%Main_hwnd,%P)
End
goto evloop
:WNDPROC
Rem This Sub processes Messages recieved by our dialog.
List create,1
List clear,1
Rem save the message to a VDS list
%%msg = @GetMsg(forwndproc)
if %%msg
List Assign,1,%%msg
Rem assign the list items to some the members of the MESSAGE structure
rem so we can reuse them.
Set msg.hwndfrom,"%"@Item(1,0)
Set msg.id,@Item(1,1)
Set msg.WPARAM,@Item(1,2)
Set msg.LPARAM,@Item(1,3)
If @Equal(@Get(msg.id),@Get(USERINFO))
Rem if our window recieved the USERINFO message
If @Equal("%"@Get(msg.WPARAM),@winexists(#App3))
Rem if the message came from App3 parse the string on Gadget's whiteboard
Parse "%%UserName;%%Password",@WhiteBoard(Get)
Rem Set the username
Dialog set,USERNAMEedt,%%UserName
Rem Grab the lparam to decrypt our password
Dialog set,PASSWORDedt,@encrypt(%%Password,@Get(msg.LPARAM))
End
End
End
List close,1
goto Evloop
:BUTTON2BUTTON
:CLOSE
SetWin Property,#App1,StatusText,REMOVE
SetMsg UnHookWndProc,%%WNDPROC
if @winexists(#App2)
%A = @Sendmsg(@winexists(#App2),$010,0,0)
End
If @winexists(#App3)
%A = @Sendmsg(@winexists(#App3),$010,0,0)
End
Exit
copyright © DragonSphere Software 2000-2006
Terms and Conditions