Core Function GUIMsgFilter

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> GUIMsgFilter( <gui>, <command> ) </pre> === Description === Use a function to recieve all messages windows sends to the GUI window (HWND, MSG, WPARAM, LPARAM). === Param...")
 
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
  
Use a function to recieve all messages windows sends to the GUI window (HWND, MSG, WPARAM, LPARAM).
+
Use a function to receive all messages windows sends to the GUI window (HWND, MSG, WPARAM, LPARAM).
  
 
=== Parameters ===
 
=== Parameters ===
Line 25: Line 25:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
// Create a new GUI
+
// Create the MDI GUI
Glob $GUI = GUICreate("GUI", 200, 200);
+
$GUI = GUICreate("MDIWindow", "GUI", 800, 600);
GUISetState($GUI, @Show);
+
// 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 );
  
 
// Create the GUI objects
 
// Create the GUI objects
$b1 = GUICreateButton($GUI, "My Button", "Send", 8, 8);
+
$b1 = GUICreate("Button", $Window, "Send", 8, 8);
  
// Add a few links
+
// Add a link
GUILink($b1, @lClick, 'Send();');
+
GUILink($b1, "Click", 'Send();');
  
 
// Create the GUI msgFilter
 
// Create the GUI msgFilter
GUIMsgFilter($GUI, "myMsgFilter();");
+
GUIMsgFilter($Window, "myMsgFilter();");
  
// Loop while GUI is active
+
// Keep the GUI running as long as long as the window is open
Until ( GUIState( $GUI ) == @sClosed )
+
While ( GUIStatus( $GUI ) ) DoEvents( );
{
+
DoEvents(); // DoEvents to keep the GUI working fine
+
}
+
  
 
// When you create a msgfilter 4 variables are automatically created for you
 
// When you create a msgfilter 4 variables are automatically created for you

Revision as of 10:07, 28 March 2012

GUIMsgFilter( <gui>, <command> )

Contents

Description

Use a function to receive all messages windows sends to the GUI window (HWND, MSG, WPARAM, LPARAM).

Parameters

gui

The GUI to link the MsgFilter to.

command

Either a command to execute or a function to call etc.

Return Value

Success: Returns 1. Failure: Returns 0.

Examples

// 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 );
 
// Create the GUI objects
$b1 = GUICreate("Button", $Window, "Send", 8, 8);
 
// Add a link
GUILink($b1, "Click", 'Send();');
 
// Create the GUI msgFilter
GUIMsgFilter($Window, "myMsgFilter();");
 
// Keep the GUI running as long as long as the window is open
While ( GUIStatus( $GUI ) ) DoEvents( );
 
// When you create a msgfilter 4 variables are automatically created for you
// $HWND
// $MSG
// $WPARAM
// $LPARAM
// All them names should be familiar to you
Function myMsgFilter()
{
	println("HWND: " . $HWND . " | MSG: " . $MSG . " | WParam: " . $WParam . " | LParam: " . $LParam);
	return 0; // If you return HIGHER than 0 the msgfilter will be removed
}
 
// The button click goes here this will simply just be something to test out the msgFilter
Function Send()
{
	$Handle = GUIGetProp($GUI, "Handle"); // Get the HWND of our window
	// Send a message to the window containing 2 unique numbers 777 and 1337
	// Just to see if they appear in the filter
	DLLCall("user32.dll", "PostMessage", "Int32", "iIII", $Handle, 160, 777, 1337);
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox