function test_lowlevel($window) { global $maintab; $result = "TEST LOW-LEVEL FUNCTIONS\n\n"; $result .= "Peek/poke a string\n"; $str = "Test string."; $addr = wb_get_address($str); $result .= wb_peek($addr) . "\n"; wb_poke($addr, "Roo"); $result .= wb_peek($addr) . "\n"; $result .= "{$str}\n\n"; $result .= "Peek/poke a long integer\n\n"; $num = 1234; $array = unpack("Vnum", wb_peek(wb_get_address($num), 4)); $result .= "{$array['num']}\n"; wb_poke(wb_get_address($num), pack("V", 800), 4); $array = unpack("Vnum", wb_peek(wb_get_address($num), 4)); $result .= "{$array['num']}\n"; $result .= "{$num}\n\n"; $result .= "Peek/poke a double float\n\n"; $num = 100.01; $array = unpack("dnum", wb_peek(wb_get_address($num), 8)); $result .= "{$array['num']}\n"; wb_poke(wb_get_address($num), pack("d", 800.02), 8); $array = unpack("dnum", wb_peek(wb_get_address($num), 8)); $result .= "{$array['num']}\n"; $result .= "{$num}\n\n"; $result .= "Peek/poke control data\n\n"; $id = ID_RESETHANDLER; $result .= "Getting control handle...\n"; $ctrl = wb_get_control($window, $id); $wbobj = unpack(WBOBJ, wb_peek($ctrl, WBOBJ_SIZE)); $result .= sprintf("Original item # is %d\n", $wbobj["item"]); $result .= "Changing the value of member 'item'...\n"; // The offset of member 'item' in struct WBOBJ is 12 wb_poke($ctrl + 12, pack("V", 1200), 4); $wbobj = unpack(WBOBJ, wb_peek($ctrl, WBOBJ_SIZE)); $result .= sprintf("Current item # is now %d\n", $wbobj["item"] . "\n"); $result .= "Peek/poke window callback\n\n"; $result .= "Current window data:\n"; $wbobj = unpack(WBOBJ, wb_peek($window, WBOBJ_SIZE)); $result .= print_r($wbobj, true); $orig_address = wb_get_address($wbobj["handler"]); $orig_handler = wb_peek($wbobj["handler"]); $result .= "Name of original window handler: \"{$orig_handler}\"\n"; $result .= "Changing handler using wb_poke()...\n"; $newname = "dummy_callback"; // The offset of member 'pszCallBackFn' in struct WBOBJ is 28 wb_poke($window + 28, pack("V", wb_get_address($newname)), 4); $wbobj = unpack(WBOBJ, wb_peek($window, WBOBJ_SIZE)); $handler = wb_peek($wbobj["handler"]); $result .= "Window handler is now \"{$handler}\"\n\n"; $result .= "END TESTS\n\n"; wb_set_text(wb_get_control($maintab, IDC_EDIT6002), $result); }
function wb_set_text($ctrl, $text, $item = null, $subitem = null) { if (!$ctrl) { return null; } switch (wb_get_class($ctrl)) { case ListView: if ($item !== null) { if (!is_array($text) && $subitem !== null) { // Set text of a ListView cell according to $item and $subitem wbtemp_set_listview_item_text($ctrl, $item, $subitem, $text); } else { // Set text of several ListView cells, ignoring $subitem for ($sub = 0; $sub < count($text); $sub++) { if ($text) { if ($text[$sub] !== null) { wbtemp_set_listview_item_text($ctrl, $item, $sub, (string) $text[$sub]); } } else { wbtemp_set_listview_item_text($ctrl, $item, $sub, ""); } } } } else { if (!is_array($text)) { $text = explode(",", $text); } wb_delete_items($ctrl, null); if (!$item) { wbtemp_clear_listview_columns($ctrl); // Create column headers // In the loop below, passing -1 as the 'width' argument of wbtemp_create_listview_column() // makes it calculate the column width automatically for ($i = 0; $i < count($text); $i++) { if (is_array($text[$i])) { wbtemp_create_listview_column($ctrl, $i, (string) $text[$i][0], isset($text[$i][1]) ? (int) $text[$i][1] : -1, isset($text[$i][2]) ? (int) $text[$i][2] : WBC_LEFT); } else { wbtemp_create_listview_column($ctrl, $i, (string) $text[$i], -1, 0); } } } } break; case ListBox: if (!$text) { wb_delete_items($ctrl); } elseif (is_string($text)) { if (strchr($text, "\r") || strchr($text, "\n")) { $text = preg_split("/[\r\n,]/", $text); wb_delete_items($ctrl); foreach ($text as $str) { wbtemp_create_item($ctrl, (string) $str); } } else { $index = wb_send_message($ctrl, LB_FINDSTRINGEXACT, -1, wb_get_address($text)); wb_send_message($ctrl, LB_SETCURSEL, $index, 0); } } elseif (is_array($text)) { wb_delete_items($ctrl); foreach ($text as $str) { wbtemp_create_item($ctrl, (string) $str); } } return; case ComboBox: if (!$text) { wb_delete_items($ctrl); } elseif (is_string($text)) { if (strchr($text, "\r") || strchr($text, "\n")) { $text = preg_split("/[\r\n,]/", $text); wb_delete_items($ctrl); foreach ($text as $str) { wbtemp_create_item($ctrl, (string) $str); } } else { $index = wb_send_message($ctrl, CB_FINDSTRINGEXACT, -1, wb_get_address($text)); wb_send_message($ctrl, CB_SETCURSEL, $index, 0); if ($index == -1) { wb_send_message($ctrl, WM_SETTEXT, 0, wb_get_address($text)); } } } elseif (is_array($text)) { wb_delete_items($ctrl); foreach ($text as $str) { wbtemp_create_item($ctrl, (string) $str); } } return; case TreeView: if ($item) { return wbtemp_set_treeview_item_text($ctrl, $item, $text); } else { return wb_create_items($ctrl, $text, true); } default: // The (string) cast below works well but is a temporary fix, must be // removed when wbtemp_set_text() accepts numeric types correctly if (is_array($text)) { return wbtemp_set_text($ctrl, $text, $item); } else { return wbtemp_set_text($ctrl, (string) $text, $item); } } }
/** * fmod_StreamNetState * * Gathers informations about the current netstream like buffer-progress in * percent, playback bitrate, datatype and status. * * @return bool * @access public */ function fmod_StreamNetState() { $statusstr = pack('i', 0); $status = wb_get_address($statusstr); $bufferstr = pack('i', 0); $buffer = wb_get_address($bufferstr); $bitratestr = pack('i', 0); $bitrate = wb_get_address($bitratestr); $flagsstr = pack('i', 0); $flags = wb_get_address($flagsstr); $result = $this->fmodlib_GetNetStatus($this->fmodStream, $status, $buffer, $bitrate, $flags); if ($result) { $bitrate_array = unpack('iBitrate', wb_peek($bitrate, 4)); $buffer_array = unpack('iBuffer', wb_peek($buffer, 4)); $status_array = unpack('iStatus', wb_peek($status, 4)); $flags_array = unpack('iFlags', wb_peek($flags, 4)); $netReturn['buffer'] = $buffer_array['Buffer'] . "%"; $netReturn['bitrate'] = $bitrate_array['Bitrate']; $netReturn['status'] = $status_array['Status']; switch ($status_array['Status']) { case 1: $netReturn['statustext'] = 'Not Connected'; break; case 2: $netReturn['statustext'] = 'Connecting'; break; case 3: $netReturn['statustext'] = 'Playing'; break; case 4: $netReturn['statustext'] = 'Ready'; break; case 5: $netReturn['statustext'] = 'Error'; break; } switch ($flags_array['Flags']) { // Possible Network Resources case 1: $netReturn['format'] = 'Shoutcast'; break; case 2: $netReturn['format'] = 'Icecast'; break; case 4: $netReturn['format'] = 'HTTP'; break; // Stream is type of MPEG // Stream is type of MPEG case 65536: $netReturn['format'] = 'MPEG'; break; case 65537: $netReturn['format'] = 'Shoutcast MPEG'; break; case 65538: $netReturn['format'] = 'Icecast MPEG'; break; case 65540: $netReturn['format'] = 'HTTP MPEG'; break; // Stream is type of OGG // Stream is type of OGG case 131072: $netReturn['format'] = 'OGG'; break; case 131073: $netReturn['format'] = 'Shoutcast OGG'; break; case 131074: $netReturn['format'] = 'Icecast OGG'; break; case 131076: $netReturn['format'] = 'HTTP OGG'; break; } $this->fmodNetStatus = $netReturn; $result = true; } else { $this->fmodLastErrorMsg = $this->fmodlib_GetErrorMessage(); } return $result; }