Core Function PTRToDLLStruct

From Sputnik Wiki
Jump to: navigation, search
PTRToDLLStruct( <def string>, <ptr> )

Contents

Description

Reads a DLLStruct from a memory pointer

Parameters

def string

A string representing the structure to create (See DLLStructCreate).

ptr

A pointer to allocated memory to use as the Structs data.

Return Value

Success - Returns the DLLStruct.

Failure - Returns false and most likely throws exception.

Remarks

DLLStructToPTR function does not exist by name but it does exist in function instead use DLLStructGetPtr to get the pointer of a DLLStruct (The reverse of this PTRToDLLStruct)

Example

DLLStructCreateDef("WindowPos", 
				@"
				ptr hwnd;
				ptr hwndInsertAfter;
				int x;
				int y;
				int cx;
				int cy;
				uint flags
				");
 
// Create the MDI GUI
$GUI = GUICreate("MDIWindow", "GUI", 800, 600);
// Show the MDI GUI
GUILoad( $GUI );
 
// Create the Design Window
$Window = GUICreate("Window", "GUI", 640, 482, 0, 0);
GUIMDIParent($Window, $GUI);
// Show the Design Window
GUILoad( $Window );
// Add a MsgFilter to Design Window
GUIWndProc($Window, 'DesignWndProc($HWND, $MSG, $WPARAM, $LPARAM);');
 
// Keep the GUI running as long as long as the window is open
While ( GUIStatus( $GUI ) ) DoEvents( );
 
Function DesignWndProc($HWND, $MSG, $WPARAM, $LPARAM)
{
	if ($MSG == 0x0046) # WM_WINDOWPOSCHANGING
	{	
		$Struct = PTRToDLLStruct("WindowPos", $LParam);
		DLLStructSetData($Struct, "x", 0);
		DLLStructSetData($Struct, "y", 0);
	}
	return 0;
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox