From: SourceForge.net <no...@so...> - 2008-09-29 11:35:50
|
Patches item #2135855, was opened at 2008-09-29 11:35 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=373087&aid=2135855&group_id=22049 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Plugin Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Pasi Ruokola (theodds) Assigned to: Nobody/Anonymous (nobody) Summary: Timer support for nsDialogs Initial Comment: Inspired by this thread: http://forums.winamp.com/showthread.php?s=&threadid=296985 I added timer support for nsDialogs. Patch adds two new functions to nsDialogs (CreateTimer and DestroyTimer). nsDialogs::CreateTimer time_in_milliseconds function_address On sucess it will push timer id and on failure "error" to the the stack. Timer id be also waiting on the stack when the callback function is called. nsDialogs::DestroyTimer timer_id Simply kills the timer specified by the timer id. Doesn't push anytin in the stack. --- WM_TIMER notification fo DialogProc --- case WM_TIMER: { struct nsControl* ctl = &g_dialog.controls[wParam - 100]; if (ctl == NULL) break; if (!ctl->callbacks.onClick) break; pushint((int) wParam); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0); break; } --- CreateTimer and DestroyTimer functions --- void __declspec(dllexport) CreateTimer(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { nsFunction callback; UINT time; size_t id; // get info from stack time = popint(); if (!time) { popint(); // remove callback from stack pushstring("error"); return; } callback = (nsFunction) popint(); if (!callback) { pushstring("error"); return; } // create item descriptor id = g_dialog.controlCount; g_dialog.controlCount++; g_dialog.controls = (struct nsControl*) HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, g_dialog.controls, g_dialog.controlCount * sizeof(struct nsControl)); g_dialog.controls[id].type = NSCTL_UNKNOWN; // create timer SetTimer( g_dialog.hwDialog, (100 + id), time, NULL); g_dialog.controls[id].window = NULL; g_dialog.controls[id].callbacks.onClick = callback; // push back result pushint(100 + id); } void __declspec(dllexport) DestroyTimer(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { UINT id; // get timer id from stack id = popint(); // kill timer KillTimer(g_dialog.hwDialog, id); } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=373087&aid=2135855&group_id=22049 |