82 $this->countCtrls = 1000;
83 $this->callback = array();
97 public function createAppWindow($caption, $width, $height, $style =
null, $params =
null): mixed
99 return $this->
createWindow(
null, AppWindow, $caption, WBC_CENTER, WBC_CENTER, $width, $height, $style, $params);
117 public function createWindow($parent, $wclass, $caption, $xPos, $yPos, $width, $height, $style =
null, $params =
null): mixed
122 $parent = $parent ===
null ? 0 : $parent;
124 $caption = empty($caption) ? $this->defaultTitle : $this->defaultTitle .
' - ' . $caption;
125 $window = $this->
callWinBinder(
'wb_create_window', array($parent, $wclass, $caption, $xPos, $yPos, $width, $height, $style, $params));
142 private function callWinBinder($function, $params = array(), $removeErrorHandler =
false): mixed
145 if (function_exists($function)) {
146 if ($removeErrorHandler) {
148 $oldErrorLevel = error_reporting(0);
149 $result = @call_user_func_array($function, $params);
150 error_reporting($oldErrorLevel);
152 $result = call_user_func_array($function, $params);
169 if ($wbobject ===
null) {
170 error_log(
'Error: $wbobject is null.');
175 if (!file_exists($path)) {
176 error_log(
'Error: Image file does not exist at path: ' . $path);
181 return $this->
callWinBinder(
'wb_set_image', array($wbobject, $path));
195 public function createNakedWindow($caption, $width, $height, $style =
null, $params =
null): mixed
197 $window = $this->
createWindow(
null, NakedWindow, $caption, WBC_CENTER, WBC_CENTER, $width, $height, $style, $params);
198 $this->
setArea($window, $width, $height);
212 public function setArea($wbobject, $width, $height): mixed
214 return $this->
callWinBinder(
'wb_set_area', array($wbobject, WBC_TITLE, 0, 0, $width, $height));
231 $windowTitle = $this->
getText($window);
242 while ($attempt < $maxAttempts && !$destroyed) {
252 $this->
exec(
'taskkill',
'/FI "WINDOWTITLE eq ' . $windowTitle .
'" /F',
true);
256 if (!empty($currentPid)) {
257 $this->
exec(
'taskkill',
'/PID ' . $currentPid .
' /T /F',
true);
258 $this->
writeLog(
'Force-killed PID: ' . $currentPid .
' for window: ' . $window);
263 $this->
callWinBinder(
'wb_destroy_window', array($window),
true);
283 return $this->
callWinBinder(
'wb_get_text', array($wbobject));
299 $text = $this->
callWinBinder(
'wb_get_text', array($window),
true);
300 return ($text !==
false);
322 public function exec($cmd, $params =
null, $silent =
false): mixed
328 $cmd =
'wscript.exe';
329 $params = !empty($params) ? $silent .
' "' . $params .
'"' : $silent;
332 $this->
writeLog(
'exec: ' . $cmd .
' ' . $params);
334 return $this->
callWinBinder(
'wb_exec', array($cmd, $params));
367 return $this->
callWinBinder(
'wb_refresh', array($wbobject,
true));
379 return $this->
callWinBinder(
'wb_get_system_info', array($info));
394 public function drawImage($wbobject, $path, $xPos = 0, $yPos = 0, $width = 0, $height = 0): mixed
396 $image = $this->
callWinBinder(
'wb_load_image', array($path));
398 return $this->
callWinBinder(
'wb_draw_image', array($wbobject, $image, $xPos, $yPos, $width, $height));
414 public function drawText($parent, $caption, $xPos, $yPos, $width =
null, $height =
null, $font =
null)
416 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
417 $width = $width ==
null ? 120 : $width;
418 $height = $height ==
null ? 25 : $height;
420 return $this->
callWinBinder(
'wb_draw_text', array($parent, $caption, $xPos, $yPos, $width, $height, $font));
436 public function drawRect($parent, $xPos, $yPos, $width, $height, $color = 15790320, $filled =
true)
438 return $this->
callWinBinder(
'wb_draw_rect', array($parent, $xPos, $yPos, $width, $height, $color, $filled));
454 public function drawLine($wbobject, $xStartPos, $yStartPos, $xEndPos, $yEndPos, $color, $height = 1)
456 return $this->
callWinBinder(
'wb_draw_line', array($wbobject, $xStartPos, $yStartPos, $xEndPos, $yEndPos, $color, $height));
469 public function createFont($fontName, $size =
null, $color =
null, $style =
null)
471 return $this->
callWinBinder(
'wb_create_font', array($fontName, $size, $color, $style));
481 public function wait($wbobject =
null)
483 return $this->
callWinBinder(
'wb_wait', array($wbobject),
true);
496 return $this->
callWinBinder(
'wb_destroy_timer', array($wbobject, $timerobject));
524 public function setHandler($wbobject, $classCallback, $methodCallback, $launchTimer =
null)
526 if ($launchTimer !=
null) {
527 $launchTimer = $this->
createTimer($wbobject, $launchTimer);
530 $this->callback[$wbobject] = array($classCallback, $methodCallback, $launchTimer);
532 return $this->
callWinBinder(
'wb_set_handler', array($wbobject,
'__winbinderEventHandler'));
548 self::CTRL_ID => $this->countCtrls,
549 self::CTRL_OBJ => $this->
callWinBinder(
'wb_create_timer', array($wbobject, $this->countCtrls, $wait))
563 $content = str_replace(self::NEW_LINE, PHP_EOL, $content);
565 return $this->
callWinBinder(
'wb_set_text', array($wbobject, $content));
587 return $this->
callWinBinder(
'wb_set_focus', array($wbobject));
599 return $this->
callWinBinder(
'wb_get_enabled', array($wbobject));
624 return $this->
callWinBinder(
'wb_set_enabled', array($wbobject, $enabled));
637 return $this->
callWinBinder(
'wb_set_style', array($wbobject, $style));
651 return $this->
callWinBinder(
'wb_sys_dlg_path', array($parent, $title, $path));
664 public function sysDlgOpen($parent, $title, $filter =
null, $path =
null)
666 return $this->
callWinBinder(
'wb_sys_dlg_open', array($parent, $title, $filter, $path));
683 public function createLabel($parent, $caption, $xPos, $yPos, $width =
null, $height =
null, $style =
null, $params =
null)
685 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
686 $width = $width ==
null ? 120 : $width;
687 $height = $height ==
null ? 25 : $height;
689 return $this->
createControl($parent, Label, $caption, $xPos, $yPos, $width, $height, $style, $params);
707 public function createControl($parent, $ctlClass, $caption, $xPos, $yPos, $width, $height, $style =
null, $params =
null)
712 self::CTRL_ID => $this->countCtrls,
713 self::CTRL_OBJ => $this->
callWinBinder(
'wb_create_control', array(
743 public function createInputText($parent, $value, $xPos, $yPos, $width =
null, $height =
null, $maxLength =
null, $style =
null, $params =
null)
745 $value = str_replace(self::NEW_LINE, PHP_EOL, $value);
746 $width = $width ==
null ? 120 : $width;
747 $height = $height ==
null ? 25 : $height;
748 $inputText = $this->
createControl($parent, EditBox, (
string)$value, $xPos, $yPos, $width, $height, $style, $params);
749 if (is_numeric($maxLength) && $maxLength > 0) {
750 $this->
setMaxLength($inputText[self::CTRL_OBJ], $maxLength);
766 return $this->
callWinBinder(
'wb_send_message', array($wbobject, 0x00c5, $length, 0));
783 public function createEditBox($parent, $value, $xPos, $yPos, $width =
null, $height =
null, $style =
null, $params =
null)
785 $value = str_replace(self::NEW_LINE, PHP_EOL, $value);
786 $width = $width ==
null ? 540 : $width;
787 $height = $height ==
null ? 340 : $height;
788 $editBox = $this->
createControl($parent, RTFEditBox, (
string)$value, $xPos, $yPos, $width, $height, $style, $params);
807 public function createHyperLink($parent, $caption, $xPos, $yPos, $width =
null, $height =
null, $style =
null, $params =
null)
809 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
810 $width = $width ==
null ? 120 : $width;
811 $height = $height ==
null ? 15 : $height;
812 $hyperLink = $this->
createControl($parent, HyperLink, (
string)$caption, $xPos, $yPos, $width, $height, $style, $params);
813 $this->
setCursor($hyperLink[self::CTRL_OBJ], self::CURSOR_FINGER);
826 public function setCursor($wbobject, $type = self::CURSOR_ARROW)
828 return $this->
callWinBinder(
'wb_set_cursor', array($wbobject, $type));
845 public function createRadioButton($parent, $caption, $checked, $xPos, $yPos, $width =
null, $height =
null, $startGroup =
false)
847 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
848 $width = $width ==
null ? 120 : $width;
849 $height = $height ==
null ? 25 : $height;
851 return $this->
createControl($parent, RadioButton, (
string)$caption, $xPos, $yPos, $width, $height, $startGroup ? WBC_GROUP :
null, $checked ? 1 : 0);
868 public function createButton($parent, $caption, $xPos, $yPos, $width =
null, $height =
null, $style =
null, $params =
null)
870 $width = $width ==
null ? 80 : $width;
871 $height = $height ==
null ? 25 : $height;
873 return $this->
createControl($parent, PushButton, $caption, $xPos, $yPos, $width, $height, $style, $params);
890 public function createProgressBar($parent, $max, $xPos, $yPos, $width =
null, $height =
null, $style =
null, $params =
null)
894 $width = $width ==
null ? 200 : $width;
895 $height = $height ==
null ? 15 : $height;
898 $this->
setRange($progressBar[self::CTRL_OBJ], 0, $max);
899 $this->gauge[$progressBar[self::CTRL_OBJ]] = 0;
913 return $this->
callWinBinder(
'wb_get_value', array($wbobject));
927 return $this->
callWinBinder(
'wb_set_range', array($wbobject, $min, $max));
948 if ($progressBar !=
null && isset($progressBar[self::CTRL_OBJ]) && isset($this->gauge[$progressBar[self::CTRL_OBJ]])) {
949 if (strval($value) == self::INCR_PROGRESS_BAR) {
950 $value = $this->gauge[$progressBar[self::CTRL_OBJ]] + 1;
952 if (is_numeric($value)) {
953 $this->gauge[$progressBar[self::CTRL_OBJ]] = $value;
957 $this->
callWinBinder(
'wb_set_value', array($progressBar[self::CTRL_OBJ], $value),
true);
972 return $this->
callWinBinder(
'wb_set_value', array($wbobject, $content));
993 $this->
setRange($progressBar[self::CTRL_OBJ], 0, $max);
1006 return $this->
messageBox($message, self::BOX_INFO, $title);
1022 $message = str_replace(self::NEW_LINE, PHP_EOL, $message);
1025 strlen($message) < 64 ? str_pad($message, 64) : $message,
1026 $title ==
null ? $this->defaultTitle : $this->defaultTitle .
' - ' . $title,
1043 return $this->
messageBox($message, self::BOX_OK, $title);
1056 return $this->
messageBox($message, self::BOX_OKCANCEL, $title);
1069 return $this->
messageBox($message, self::BOX_QUESTION, $title);
1082 return $this->
messageBox($message, self::BOX_ERROR, $title);
1095 return $this->
messageBox($message, self::BOX_WARNING, $title);
1108 return $this->
messageBox($message, self::BOX_YESNO, $title);
1121 return $this->
messageBox($message, self::BOX_YESNOCANCEL, $title);
1141 global $bearsamppWinbinder;
1143 if ($bearsamppWinbinder->callback[$window][2] !=
null) {
1144 $bearsamppWinbinder->destroyTimer($window, $bearsamppWinbinder->callback[$window][2][0]);
1147 call_user_func_array(
1148 array($bearsamppWinbinder->callback[$window][0], $bearsamppWinbinder->callback[$window][1]),
1149 array($window, $id, $ctrl, $param1, $param2)
__winbinderEventHandler($window, $id, $ctrl, $param1, $param2)
static logInitClass($classInstance)
static logDebug($data, $file=null)
setCursor($wbobject, $type=self::CURSOR_ARROW)
messageBoxYesNoCancel($message, $title=null)
setHandler($wbobject, $classCallback, $methodCallback, $launchTimer=null)
createFont($fontName, $size=null, $color=null, $style=null)
drawLine($wbobject, $xStartPos, $yStartPos, $xEndPos, $yEndPos, $color, $height=1)
messageBox($message, $type, $title=null)
createProgressBar($parent, $max, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
createButton($parent, $caption, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
messageBoxError($message, $title=null)
destroyTimer($wbobject, $timerobject)
callWinBinder($function, $params=array(), $removeErrorHandler=false)
incrProgressBar($progressBar)
setImage($wbobject, $path)
setValue($wbobject, $content)
createAppWindow($caption, $width, $height, $style=null, $params=null)
createInputText($parent, $value, $xPos, $yPos, $width=null, $height=null, $maxLength=null, $style=null, $params=null)
setArea($wbobject, $width, $height)
setStyle($wbobject, $style)
setProgressBarValue($progressBar, $value)
createControl($parent, $ctlClass, $caption, $xPos, $yPos, $width, $height, $style=null, $params=null)
setRange($wbobject, $min, $max)
drawText($parent, $caption, $xPos, $yPos, $width=null, $height=null, $font=null)
createNakedWindow($caption, $width, $height, $style=null, $params=null)
messageBoxWarning($message, $title=null)
messageBoxOk($message, $title=null)
createHyperLink($parent, $caption, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
drawRect($parent, $xPos, $yPos, $width, $height, $color=15790320, $filled=true)
resetProgressBar($progressBar)
messageBoxInfo($message, $title=null)
setText($wbobject, $content)
createRadioButton($parent, $caption, $checked, $xPos, $yPos, $width=null, $height=null, $startGroup=false)
exec($cmd, $params=null, $silent=false)
createEditBox($parent, $value, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
sysDlgPath($parent, $title, $path=null)
messageBoxOkCancel($message, $title=null)
messageBoxQuestion($message, $title=null)
sysDlgOpen($parent, $title, $filter=null, $path=null)
setProgressBarMax($progressBar, $max)
createLabel($parent, $caption, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
setMaxLength($wbobject, $length)
createTimer($wbobject, $wait=1000)
createWindow($parent, $wclass, $caption, $xPos, $yPos, $width, $height, $style=null, $params=null)
drawImage($wbobject, $path, $xPos=0, $yPos=0, $width=0, $height=0)
setEnabled($wbobject, $enabled=true)
messageBoxYesNo($message, $title=null)