Saturday, November 29, 2008

Javascript > Hacking Auto-Sizing IFRAME tag

<html>
<head>
<script type="text/javascript">

/***********************************************
* IFrame SSI script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function dyniframesize() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById){ //begin resizing iframe procedure
dyniframe[dyniframe.length] = document.getElementById(iframeids[i]);
if (dyniframe[i] && !window.opera){
dyniframe[i].style.display="block"
if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) //ns6 syntax
dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight+FFextraHeight;
else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) //ie5+ syntax
dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
}
}
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

if (window.addEventListener)
window.addEventListener("load", dyniframesize, false)
else if (window.attachEvent)
window.attachEvent("onload", dyniframesize)
else
window.onload=dyniframesize

</script>
</head>

<body>

<iframe id="myframe" src="externalpage.htm" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>

</body>
</html>


Source : http://www.dynamicdrive.com/

Read More...

Friday, November 28, 2008

Delphi > Download Source Code KSpoold Disinfector

KSpoold Disinfector is a software that writen to restore Microsoft Office files (Word, Excel, PPT etc.) from damaged file because of KSpoold virus.

KSpoold infect the docs files by mergeing these docs to the virus file, original docs files will be delete & new file with the same name will be added to cheating the users with new file extention: .EXE So anytime you double click this infected file from explorer / open it using shell api your computer will be infected too.

The software is provided "as-is," without any express or implied warranty. In no event shall the Author be held liable for any damages arising from the use of the Software

The software is writen in Borland Delphi 7. Full source-code also provided, any comments are noted of the following:
"The const SAMPLE_SIZE = 524; is taken from the following figure: Microsoft Word & Excel using the same file header at the first 512, so we get unique header at the first 12 byte after 512 offset 512 + 12 = 524"

You can download sample of infected file by KSpoold here:
http://delphi-id.org/dpr/Downloads-index-req-viewdownloaddetails-lid-180.pas

Download Source Code

KSpoold Disinfector 1.0 - Freeware
Copyright © Indra Gunawan, 2ind@mail.com
www.delphiexpert.wordpress.com

Read More...

Sample HTML Help and Visual Basic 6 - Tutorial

When you distribute an application, there should be some guidance for your customers and/or users how to work with it. You can simply add a few HTML pages, but this will not allow you to use the often appreciated "what's this help", in form of the small question mark in your applications form borders. Neither does it look professional.

The purpose of this document/tutorial is showing you how to use HTML Help for a very simple help file, and how to 'attach' it to your application. Note that by no means this document has been written to teach you everything about HTML Help. This document focuses more on the actual help file, combined with your Visual Basic 6 application.

Download sample source code and tutorial

Read More...

VB > Get a drives drive and volume info


Declare Function GetVolumeInformation Lib _
"kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long

Declare Function GetDriveType Lib "kernel32" _
Alias "GetDriveTypeA" (ByVal nDrive As String) As Long


Private Sub cmdGetVol_Click()

Dim VolName As String, FSys As String, erg As Long
Dim VolNumber As Long, MCM As Long, FSF As Long
Dim Drive As String, DriveType As Long

VolName = Space(127)
FSys = Space(127)

Drive = "C:\" 'Enter the driverletter you want
DriveType& = GetDriveType(Drive$)

erg& = GetVolumeInformation(Drive$, VolName$, 127&, _
VolNumber&, MCM&, FSF&, FSys$, 127&)

Print "VolumeName:" & vbTab & VolName$
Print "VolumeNumber:" & vbTab & VolNumber&
Print "MCM:" & vbTab & vbTab & MCM&
Print "FSF:" & vbTab & vbTab & FSF&
Print "FileSystem:" & vbTab & FSys$
Print "DriveType:" & vbTab & DriveType&;

End Sub

Read More...

VB > Add a 3D Effect to Forms, Textboxes, and Labels


'Set form's AutoRedraw property toTrue
Sub PaintControl3D(frm As Form, Ctl As Control)
' This Sub draws lines around controls to make them 3d

' darkgrey, upper - horizontal
frm.Line (Ctl.Left, Ctl.Top - 15)-(Ctl.Left + _
Ctl.Width, Ctl.Top - 15), &H808080, BF
' darkgrey, left - vertical
frm.Line (Ctl.Left - 15, Ctl.Top)-(Ctl.Left - 15, _
Ctl.Top + Ctl.Height), &H808080, BF
' white, right - vertical
frm.Line (Ctl.Left + Ctl.Width, Ctl.Top)- _
(Ctl.Left + Ctl.Width, Ctl.Top + Ctl.Height), &HFFFFFF, BF
' white, lower - horizontal
frm.Line (Ctl.Left, Ctl.Top + Ctl.Height)- _
(Ctl.Left + Ctl.Width, Ctl.Top + Ctl.Height), &HFFFFFF, BF

End Sub

Sub PaintForm3D(frm As Form)
' This Sub draws lines around the Form to make it 3d

' white, upper - horizontal
frm.Line (0, 0)-(frm.ScaleWidth, 0), &HFFFFFF, BF
' white, left - vertical
frm.Line (0, 0)-(0, frm.ScaleHeight), &HFFFFFF, BF
' darkgrey, right - vertical
frm.Line (frm.ScaleWidth - 15, 0)-(frm.ScaleWidth - 15, _
frm.Height), &H808080, BF
' darkgrey, lower - horizontal
frm.Line (0, frm.ScaleHeight - 15)-(frm.ScaleWidth, _
frm.ScaleHeight - 15), &H808080, BF

End Sub

'DEMO USAGE
'Add 1 label and 1 textbox

Private Sub Form_Load()

Me.AutoRedraw = True
PaintForm3D Me
PaintControl3D Me, Label1 'Label1 is name of label
PaintControl3D Me, Text1 'Text1 is name of textbox

End Sub

Read More...

How to show-hide a combo drop down list on VB

Public Declare Function SendMessageLong Lib _
"user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Public Const CB_SHOWDROPDOWN = &H14F
Sub Form_Load()
Combo1.AddItem "Item 1"
Combo1.AddItem "Item 2"
Combo1.AddItem "Item 3"
End Sub

Private Sub Command1_Click()
Dim r as Long
r = SendMessageLong(Combo1.hWnd, CB_SHOWDROPDOWN, True, 0)
End Sub

Private Sub Command2_Click()
Dim r as Long
r = SendMessageLong(Combo1.hWnd, CB_SHOWDROPDOWN, False, 0)
End Sub

Read More...

Tuesday, November 25, 2008

Active scripting component: Windows script host control for Delphi

Windows Scripting Host Control enables Delphi application to support active scripting languages installed in Windows Scripting Host (such as VB Script, Java Script, Perl, Python, Lua, Tcl etc).TekWSHControl allows to use Delphi objects in script, including use of published properties, running public and published methods, setting script procedures as event handlers, call unit procedures and functions from script, use unit variables etc.Version 2.5 basic features and improvements: (See previous history at http://www.ekassw.com/wshctrl/index.html) - Public methods of Delphi objects calls from script supported - Delphi unit routines (procedures and functions) from script supported - Access to Delphi unit variables from script supported - Minor bugs in wrapper expert fixed

License: Freeware
File Size : 565.0 KB
Download Link : http://www.sourcecodeonline.com/download.php?id=37637&n=1

Read More...

Sunday, November 9, 2008

Using PHP scripts to send an email

What is PHP?
PHP, which stands for "Hypertext Preprocessor", is a server-side, HTML embedded scripting language used to create dynamic Web pages. Much of its syntax is borrowed from C, Java and Perl with some unique features thrown in. The goal of the language is to allow Web developers to write dynamically generated pages quickly.

In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the page, the server processes the PHP code and then sends the output (not the PHP code itself) to the visitor's browser. It means that, unlike JavaScript, you don't have to worry that someone can steal your PHP script.

PHP offers excellent connectivity to many databases including MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, and Generic ODBC. The popular PHP-MySQL combination (both are open-source products) is available on almost every UNIX host. Being web-oriented, PHP also contains all the functions to do things on the Internet - connecting to remote servers, checking email via POP3 or IMAP, url encoding, setting cookies, redirecting, etc.

Basic Syntax

* File name:
You should save your file with the extension .php (earlier versions used the extensions .php3 and .phtml).
* Comments:
// This comment extends to the end of the line.
/* This is a
multi-line
comment */
* Escaping from HTML:
A PHP code block starts with <?php" and ends with "?>. A PHP code block can be placed anywhere in the HTML document.
* Instruction separation:
Each separate instruction must end with a semicolon. The PHP closing tag (?>) also implies the end of the instruction.

This tip provides information on use of utility Command line email client in PHP script. Use of standard PHP mail() function which allows you to send mail, is very complicated. By using febooti Command line email you can:

  • Send email message using plain text or HTML message with embedded pictures.
  • Send unlimited number of attachments.
  • Use return codes to check success or failure.
  • Works on Microsoft Windows (98 / Me / NT / 2000 / 2003 / XP / Vista) including all server versions.
  • And many more options...
Sample PHP script:

/**** febootimail PHP email ****/
<?php
// Send e-mail from PHP and output the result.
// (On a MS Window operating system with
// the "febootimail.exe" executable in the path).

$server=' -SMTP smtp.sender.com -PORT 25';

$body='"This is <I>HTML / MIME</I> e-mail message"';
$body.='" sent with <B>febooti Command line email</B>"';

$subj='PHP mail';

$command='febootimail.exe -HTML -MIME -FROM web@sender.com ';
$command.='-TO john@sender.com '.$body.$server;
$command.='-SUBJ '.$subj.' -BODY '.$body.$server;

$result=0;

exec($command,$output,$result);
echo 'Output: ';
print_r($output);
echo '<BR>';
echo 'Result: '.$result;

// For detailed information about result codes, see:
// Utility Command line email client with MS-DOS batch files - returned errorlevels
?>

Reference : http://expertsadvice.in

Read More...

Friday, November 7, 2008

Displaying Macromedia Flash in your Delphi Application

Macromedia Method descriptions for ActiveX Control

If you have considered using your Macromedia Flash files to help add some flavor to your Delphi applications, but never knew how, this article is for you.

Download demo project

First of all you must find the file titled

"SWFLASH.OCX" usually in the C:\Windows\System\Macromed\Flash directory.

You can then in Delphi click on the menu Component --> Import ActiveX Control. Choose the SWFlash.OCX file and import it. Once you install it, you will then have the TShockWaveFlash component to drag onto your form.

PROBLEM: The important thing to remember is that if deploy your application then they must have this OCX file or it will not run.

SOLUTION: To keep your program simple and only have 1 file to distribute, I would suggest to create a resource file of the OCX and include in your .EXE. Extract the file if needed and register it. I have included some sample code on how to do this.

CREATING RESOURCE FILE: (Skip this section if you already understand it). Create a new Text File in Notepad. Type the following line:

Flash RCDATA "SWFLASH.OCX"

Make sure the text file is saved as Filename.rc, I saved mine as FlashOCX.rc. You must also have the .rc file in the same directory as the SWFLASH.OCX file in order for this to work.

Open your command prompt (DOS window) and find the brcc32.exe file in your bin directory wherever you installed Delphi. Type this and execute it in DOS:

Brcc32 DirofFile\FlashOCX.rc
Example: Brcc32 c:\windows\system\flashocx.rc

It should now have created a file titled "FLASHOCX.RES". You can now include this into your application.

{$R *.RES}
{$R FLASHOCX.RES}


The R Directive tells your program to include that Resource File.

HOW TO EXTRACT AND REGISTER:

First off we need to check to see if we can play the Flash File or not. Click on Project --> View Source (in Delphi 5) and pull up the project source code. We want to check for the EOleSysError Message when creating the first form. If we encounter the error, then we know we must register the OCX on that particular machine.

uses comobj

begin
Application.Initialize;
try
Application.CreateForm(TForm1, Form1);
except
On EOleSysError Do
begin
//Register OCX File because not found.
end;
end;
Application.Run;
end.

This next bit of source code that I will display will give you what is needed to extract the resource file and place into the Windows System Directory.

uses
windows, classes, sysutils

var
aSystemDirZ : array[0..2047] of Char;
fSystemDir : String;

...

GetSystemDirectory ( aSystemDirZ, 2047 );
fSystemDir := aSystemDirZ;

ResStream := TResourceStream.Create(0, 'Flash', RT_RCDATA);
try
FileStream := TFileStream.Create(fSystemDir+'SWFLASH.OCX', fmCreate);
try
FileStream.CopyFrom(ResStream, 0);
finally
FileStream.Free;
end;
finally
ResStream.Free;
end;

ENTIRE CODE:

You must still register the OCX file, and I will now display the entire code so you can see how it would all fit together.


program FlashPlayer;

uses
Forms, Dialogs, comobj, windows, classes, sysutils,
uMain in 'uMain.pas' {Form1};

{$R *.RES}
{$R FLASHOCX.RES}

type
TRegFunc = function : HResult; stdcall;

function WinExecAndWait32( FileName: String; Visibility : Integer ) : Cardinal;
var { by Pat Ritchey }
zAppName : array[0..512] of char;
zCurDir : array[0..255] of char;
WorkDir : String;
StartupInfo : TStartupInfo;
ProcessInfo : TProcessInformation;
begin
StrPCopy( zAppName, FileName );
GetDir ( 0, WorkDir );
StrPCopy( zCurDir, WorkDir );

FillChar( StartupInfo, Sizeof( StartupInfo ), #0 );

StartupInfo.cb := Sizeof( StartupInfo );
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;

if ( not CreateProcess( nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
zCurDir, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo ) ) then
begin
Result := $FFFFFFFF; { pointer to PROCESS_INF }
MessageBox( Application.Handle, PChar( SysErrorMessage( GetLastError ) ), 'Yipes!', 0 );
end
else
begin
WaitforSingleObject( ProcessInfo.hProcess, INFINITE );
GetExitCodeProcess ( ProcessInfo.hProcess, Result );
CloseHandle ( ProcessInfo.hProcess );
CloseHandle ( ProcessInfo.hThread );
end;
end;

var
aSystemDirZ : array[0..2047] of Char;
aShortPath : array[0..2047] of Char;
fSystemDir : String;
aCommand : String;
aHandle : Cardinal;
aFunc : TRegFunc;
ResStream : TResourceStream;
FileStream : TFileStream;
begin

GetSystemDirectory ( aSystemDirZ, 2047 );
fSystemDir := aSystemDirZ;
Application.Initialize;
try
Application.CreateForm(TForm1, Form1);
except
On EOleSysError Do
begin
ResStream := TResourceStream.Create(0, 'Flash', RT_RCDATA);
try
FileStream := TFileStream.Create(fSystemDir+'SWFLASH.OCX', fmCreate);
try
FileStream.CopyFrom(ResStream, 0);
finally
FileStream.Free;
end;
finally
ResStream.Free;
end;

try
{Register the OCX File}
aHandle := LoadLibrary( PChar( fSystemDir+'SWFLASH.OCX' ) );
if ( aHandle >= 32 ) then
begin
aFunc := GetProcAddress( aHandle, 'DllRegisterServer' );
if ( Assigned( aFunc ) = TRUE ) then
begin
GetShortPathName( PChar( fSystemDir+'SWFLASH.OCX' ), aShortPath, 2047 );
aCommand := Format( '%s
egsvr32.exe /s %s', [fSystemDir, aShortPath] );
WinExecAndWait32( aCommand, SW_HIDE );
end;
FreeLibrary( aHandle );
end;

//Try Creating the Form Again
try
Application.CreateForm(TForm1, Form1);
except
ShowMessage('Unable to find Macromedia Shockwave Flash.');
end;

except
ShowMessage('Unable to register Macromedia Shockwave Flash.');
end;
{End of Registering the OCX File}
end;
end;
Application.Run;
end.

END OF PROJECT SOURCE


HOW TO USE ACTIVEX CONTROL:

Properties

ReadyState (get only) - 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.

TotalFrames (get only) - Returns the total number of frames in the movie. This is not available until the movie has loaded. Wait for ReadyState = 4.

FrameNum (get or set) - The currently displayed frame of the movie. Setting this will advance or rewind the movie.

Playing (get or set) - True if the movie is currently playing, false if it is paused.

Quality (get or set) - The current rendering quality (0=Low, 1=High, 2=AutoLow, 3=AutoHigh). This is the same as the QUALITY parameter.

ScaleMode (get or set) - Scale mode (0=ShowAll, 1= NoBorder, 2 = ExactFit). This is the same as the SCALE parameter.

AlignMode (get or set) - The align mode consists of bit flags. (Left=+1, Right=+2, Top=+4, Bottom=+8). This is the same as the SALIGN parameter.

BackgroundColor (get or set) - Override the background color of a movie. An integer of the form red*65536+green*256+blue use -1 for the default movie color.

Loop (get or set) - True if the animation loops, false to play once. Same as the MOVIE parameter.

Movie (get or set) - The URL source for the Flash Player movie file. Setting this will load a new movie into the control. Same as the MOVIE parameter.

Methods

Play() - Start playing the animation.

Stop() - Stop playing the animation.

Back() - Go to the previous frame.

Forward() - Go to the next frame.

Rewind() - Go to the first frame.

SetZoomRect(int left, int top, int right, int bottom) - Zoom in on a rectangular area of the movie. Note that the units of the coordinates are in twips (1440 units per inch). To calculate a rectangle in Flash, set the ruler units to Points and multiply the coordinates by 20 to get TWIPS.

Zoom(int percent) - Zoom the view by a relative scale factor. Zoom(50) will double the size of the objects in the view. Zoom(200) will reduce the size of objects in the view by one half.

Pan(int x, int y, int mode) - Pan a zoomed in movie. The mode can be: 0 = pixels, 1 = % of window.

Events

OnProgress(int percent) - Generated as the Flash Player movie is downloading.

OnReadyStateChange(int state) - Generated when the ready state of the control changes. The possible states are 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.

FSCommand(string command, string args) - This event is generated when a GetURL action is performed in the movie with a URL and the URL starts with "FSCommand:". The portion of the URL after the : is provided in command and the target is provided in args. This can be used to create a response to a frame or button action in the Shockwave Flash movie.

For further information see the Macromedia Flash Website

In order to include your Flash files into your Delphi Application, just type in the directory of the .SWF file, then make "Embed Movie" = True, and it will be included in your file and not look at the Movie parameter any longer.

Reference : Douglas Tietjen - http://www.imaginpro.com

Read More...

Delphi Encrypt - Decrypt Functions

To encrypt / decrypt strings without including "bad" characters (spaces, car return, line feed, tabs, etc)

Code :

function TCrypt.Desencripta(const S: String): String;
var
I: byte;
Key: Word;
ls : string;
begin
Key := 1674;
SetLength(ls,Length(S) div 2);
SetLength(Result,Length(ls));
for I := 1 to Length(ls) do begin
ls[I] := char(StrToInt('$'+ Copy(S, (I*2)-1 , 2)));
end;

for I := 1 to Length(ls) do begin
Result[I] := char(byte(ls[I]) xor (Key shr 8));
Key := (byte(ls[I]) + Key) * C1 + C2;
end;
end;


function TCrypt.Encripta(const S: String): String;
var
I: byte;
Key: Word;
ls : string;
begin
Key := 1674;
SetLength(ls,Length(S));
Result := '';
for I := 1 to Length(S) do begin
ls[I] := char(byte(S[I]) xor (Key shr 8));
Result := Result + IntToHex(byte(ls[I]),2);
Key := (byte(ls[I]) + Key) * C1 + C2;
end;



Download Code
Source : Planet-Source-Code.com

Read More...

Latest Comments

About Me

My photo
Makassar, Sulawesi Selatan, Indonesia

Guest Book


ShoutMix chat widget

Script Sense ©Template Blogger Green by Dicas Blogger.

TOPO