Core Function PTRToDLLStruct

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Remarks)
m (1 revision)
 
(4 intermediate revisions by one user not shown)
Line 21: Line 21:
 
Success - Returns the DLLStruct.
 
Success - Returns the DLLStruct.
  
Failure - Returns 0 and most likely throws exception.
+
Failure - Returns false and most likely throws exception.
  
 
=== Remarks ===
 
=== Remarks ===
Line 31: Line 31:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
DLLStructCreateDef("WindowPos",  
 
DLLStructCreateDef("WindowPos",  
@"
+
@"
ptr hwnd;
+
ptr hwnd;
ptr hwndInsertAfter;
+
ptr hwndInsertAfter;
int x;
+
int x;
int y;
+
int y;
int cx;
+
int cx;
int cy;
+
int cy;
uint flags
+
uint flags
");
+
");
 
+
 
// Create the MDI GUI
 
// Create the MDI GUI
 
$GUI = GUICreate("MDIWindow", "GUI", 800, 600);
 
$GUI = GUICreate("MDIWindow", "GUI", 800, 600);
 
// Show the MDI GUI
 
// Show the MDI GUI
 
GUILoad( $GUI );
 
GUILoad( $GUI );
 
+
 
// Create the Design Window
 
// Create the Design Window
 
$Window = GUICreate("Window", "GUI", 640, 482, 0, 0);
 
$Window = GUICreate("Window", "GUI", 640, 482, 0, 0);
Line 52: Line 52:
 
GUILoad( $Window );
 
GUILoad( $Window );
 
// Add a MsgFilter to Design Window
 
// Add a MsgFilter to Design Window
GUIWndProc($Window, "DesignWndProc();");
+
GUIWndProc($Window, 'DesignWndProc($HWND, $MSG, $WPARAM, $LPARAM);');
 
+
 
// Keep the GUI running as long as long as the window is open
 
// Keep the GUI running as long as long as the window is open
 
While ( GUIStatus( $GUI ) ) DoEvents( );
 
While ( GUIStatus( $GUI ) ) DoEvents( );
 
+
Function DesignWndProc()
+
Function DesignWndProc($HWND, $MSG, $WPARAM, $LPARAM)
 
{
 
{
 
if ($MSG == 0x0046) # WM_WINDOWPOSCHANGING
 
if ($MSG == 0x0046) # WM_WINDOWPOSCHANGING

Latest revision as of 12:37, 14 June 2015

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