Search Results

Search found 1295 results on 52 pages for 'hook'.

Page 9/52 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Disable antialiasing for a specific GDI device context

    - by Jacob Stanley
    I'm using a third party library to render an image to a GDI DC and I need to ensure that any text is rendered without any smoothing/antialiasing so that I can convert the image to a predefined palette with indexed colors. The third party library i'm using for rendering doesn't support this and just renders text as per the current windows settings for font rendering. They've also said that it's unlikely they'll add the ability to switch anti-aliasing off any time soon. The best work around I've found so far is to call the third party library in this way (error handling and prior settings checks ommitted for brevity): private static void SetFontSmoothing(bool enabled) { int pv = 0; SystemParametersInfo(Spi.SetFontSmoothing, enabled ? 1 : 0, ref pv, Spif.None); } // snip Graphics graphics = Graphics.FromImage(bitmap) IntPtr deviceContext = graphics.GetHdc(); SetFontSmoothing(false); thirdPartyComponent.Render(deviceContext); SetFontSmoothing(true); This obviously has a horrible effect on the operating system, other applications flicker from cleartype enabled to disabled and back every time I render the image. So the question is, does anyone know how I can alter the font rendering settings for a specific DC? Even if I could just make the changes process or thread specific instead of affecting the whole operating system, that would be a big step forward! (That would give me the option of farming this rendering out to a separate process- the results are written to disk after rendering anyway) EDIT: I'd like to add that I don't mind if the solution is more complex than just a few API calls. I'd even be happy with a solution that involved hooking system dlls if it was only about a days work. EDIT: Background Information The third-party library renders using a palette of about 70 colors. After the image (which is actually a map tile) is rendered to the DC, I convert each pixel from it's 32-bit color back to it's palette index and store the result as an 8bpp greyscale image. This is uploaded to the video card as a texture. During rendering, I re-apply the palette (also stored as a texture) with a pixel shader executing on the video card. This allows me to switch and fade between different palettes instantaneously instead of needing to regenerate all the required tiles. It takes between 10-60 seconds to generate and upload all the tiles for a typical view of the world. EDIT: Renamed GraphicsDevice to Graphics The class GraphicsDevice in the previous version of this question is actually System.Drawing.Graphics. I had renamed it (using GraphicsDevice = ...) because the code in question is in the namespace MyCompany.Graphics and the compiler wasn't able resolve it properly. EDIT: Success! I even managed to port the PatchIat function below to C# with the help of Marshal.GetFunctionPointerForDelegate. The .NET interop team really did a fantastic job! I'm now using the following syntax, where Patch is an extension method on System.Diagnostics.ProcessModule: module.Patch( "Gdi32.dll", "CreateFontIndirectA", (CreateFontIndirectA original) => font => { font->lfQuality = NONANTIALIASED_QUALITY; return original(font); }); private unsafe delegate IntPtr CreateFontIndirectA(LOGFONTA* lplf); private const int NONANTIALIASED_QUALITY = 3; [StructLayout(LayoutKind.Sequential)] private struct LOGFONTA { public int lfHeight; public int lfWidth; public int lfEscapement; public int lfOrientation; public int lfWeight; public byte lfItalic; public byte lfUnderline; public byte lfStrikeOut; public byte lfCharSet; public byte lfOutPrecision; public byte lfClipPrecision; public byte lfQuality; public byte lfPitchAndFamily; public unsafe fixed sbyte lfFaceName [32]; }

    Read the article

  • How can we detect hotkeys registered by other apps?

    - by worlds-apart89
    Is it possible to detect all the hotkeys registered by the OS as well as software applications currently running? Any native or managed approach on the Windows platform? I know that the RegisterHotKey function returns false if the hotkey is already registered, but what I am looking for is an approach, method, etc. that will give me a list of registered hotkeys. Looping all possible combinations with RegisterHotKey does not sound like a good idea. Anything more efficient?

    Read the article

  • svnlook always returns an error and no output

    - by Pierre-Alain Vigeant
    I'm running this small C# test program launched from a pre-commit batch file private static int Test(string[] args) { var processStartInfo = new ProcessStartInfo { FileName = "svnlook.exe", UseShellExecute = false, ErrorDialog = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, Arguments = "help" }; using (var svnlook = Process.Start(processStartInfo)) { string output = svnlook.StandardOutput.ReadToEnd(); svnlook.WaitForExit(); Console.Error.WriteLine("svnlook exited with error 0x{0}.", svnlook.ExitCode.ToString("X")); Console.Error.WriteLine("Current output is: {0}", string.IsNullOrEmpty(output) ? "empty" : output); return 1; } } I am deliberately calling svnlook help and forcing an error so I can see what is going on when committing. When this program run, SVN displays svnlook exited with error 0xC0000135. Current output is: empty I looked up the error 0xC0000135 and it mean App failed to initialize properly although it wasn't specific to svnhook. Why is svnlook help not returning anything? Does it fail when executed through another process?

    Read the article

  • Anyone get mach_inject working on snow leopard?

    - by overboming
    Project is now on github and here is the link to my issue I successfully compiled the whole thing and able to run rejector and rejectee separately. But the injector will crash the injectee when injecting code to the target process. mach_inject_test_injectee.app 's standard output: mach error on bundle load (os/kern) successful mach error on bundle load (os/kern) successful mach error on bundle load (os/kern) successful mach error on bundle load (os/kern) successful mach error on bundle load (os/kern) successful FS rep /Users/Malic/Documents/Code/c/mach_star/mach_inject_test/build/Development/mach_inject_test_injector.app/Contents/Resources/mach_inject_test_injected.bundle/Contents/MacOS/mach_inject_test_injected LOADDDDDDDDDD! Assertion failed: (0), function +[injected_PrincipalClass load], file /Users/Malic/Documents/Code/c/mach_star/mach_inject_test/injected-PrincipalClass.m, line 25. Abort trap mach_inject_test_injector 's standard output injecting into pid 3680 injecting pid mach_inject failing.. (os/kern) successful mach inject done? 0 hi It seems from the output the injector is not notified from the injectee, any ideas? thanks.

    Read the article

  • Why is this the output of this python program?

    - by Andrew Moffat
    Someone from #python suggested that it's searching for module "herpaderp" and finding all the ones listed as its searching. If this is the case, why doesn't it list every module on my system before raising ImportError? Can someone shed some light on what's happening here? import sys class TempLoader(object): def __init__(self, path_entry): if path_entry == 'test': return raise ImportError def find_module(self, fullname, path=None): print fullname, path return None sys.path.insert(0, 'test') sys.path_hooks.append(TempLoader) import herpaderp output: 16:00:55 $> python wtf.py herpaderp None apport None subprocess None traceback None pickle None struct None re None sre_compile None sre_parse None sre_constants None org None tempfile None random None __future__ None urllib None string None socket None _ssl None urlparse None collections None keyword None ssl None textwrap None base64 None fnmatch None glob None atexit None xml None _xmlplus None copy None org None pyexpat None problem_report None gzip None email None quopri None uu None unittest None ConfigParser None shutil None apt None apt_pkg None gettext None locale None functools None httplib None mimetools None rfc822 None urllib2 None hashlib None _hashlib None bisect None Traceback (most recent call last): File "wtf.py", line 14, in <module> import herpaderp ImportError: No module named herpaderp

    Read the article

  • Detecting branch reintegration or merge in pre-commit script

    - by Shawn Chin
    Within a pre-commit script, is it possible (and if so, how) to identify commits stemming from an svn merge? svnlook changed ... shows files that have changed, but does not differentiate between merges and manual edits. Ideally, I would also like to differentiate between a standard merge and a merge --reintegrate. Background: I'm exploring the possibility of using pre-commit hooks to enforce SVN usage policies for our project. One of the policies state that some directories (such as /trunk) should not be modified directly, and changed only through the reintegration of feature branches. The pre-commit script would therefore reject all changes made to these directories apart from branch reintegrations. Any ideas? Update: I've explored the svnlook command, and the closest I've got is to detect and parse changes to the svn:mergeinfo property of the directory. This approach has some drawback: svnlook can flag up a change in properties, but not which property was changed. (a diff with the proplist of the previous revision is required) By inspecting changes in svn:mergeinfo, it is possible to detect that svn merge was run. However, there is no way to determine if the commits are purely a result of the merge. Changes manually made after the merge will go undetected. (related post: Diff transaction tree against another path/revision)

    Read the article

  • Editing Subversion post-commit script to enable automated Hudson builds

    - by Wachgellen
    Hey guys, I'm not so good with Linux, but I need to modify the post-commit file of my Subversion repository to get Hudson to build automatically on commits. This page here tells me to do this: REPOS="$1" REV="$2" UUID=`svnlook uuid $REPOS` /usr/bin/wget \ --header "Content-Type:text/plain;charset=UTF-8" \ --post-data "`svnlook changed --revision $REV $REPOS`" \ --output-document "-" \ http://server/hudson/subversion/${UUID}/notifyCommit?rev=$REV The part that I don't know is the address URL given at the bottom of that code snippet. I know the address of my Hudson server, but the /subversion part has me baffled, because on my system that doesn't refer to anything. My Subversion repository belongs somewhere else on the server, not inside Hudson. Can anyone tell me what I'm supposed to put as the URL (an example would help greatly)?

    Read the article

  • Intercept keystrokes to a window

    - by MTsoul
    Is it possible to intercept a keystroke (and characters) sent to a window? By intercept, I mean play man-in-the-middle, instead of having just hooks onto the Window. I'd like to filter (i.e. eliminate some keystrokes) keystrokes to a window.

    Read the article

  • How do I patch a Windows API at runtime so that it to returns 0 in x64?

    - by Jorge Vasquez
    In x86, I get the function address using GetProcAddress() and write a simple XOR EAX,EAX; RET; in it. Simple and effective. How do I do the same in x64? bool DisableSetUnhandledExceptionFilter() { const BYTE PatchBytes[5] = { 0x33, 0xC0, 0xC2, 0x04, 0x00 }; // XOR EAX,EAX; RET; // Obtain the address of SetUnhandledExceptionFilter HMODULE hLib = GetModuleHandle( _T("kernel32.dll") ); if( hLib == NULL ) return false; BYTE* pTarget = (BYTE*)GetProcAddress( hLib, "SetUnhandledExceptionFilter" ); if( pTarget == 0 ) return false; // Patch SetUnhandledExceptionFilter if( !WriteMemory( pTarget, PatchBytes, sizeof(PatchBytes) ) ) return false; // Ensures out of cache FlushInstructionCache(GetCurrentProcess(), pTarget, sizeof(PatchBytes)); // Success return true; } static bool WriteMemory( BYTE* pTarget, const BYTE* pSource, DWORD Size ) { // Check parameters if( pTarget == 0 ) return false; if( pSource == 0 ) return false; if( Size == 0 ) return false; if( IsBadReadPtr( pSource, Size ) ) return false; // Modify protection attributes of the target memory page DWORD OldProtect = 0; if( !VirtualProtect( pTarget, Size, PAGE_EXECUTE_READWRITE, &OldProtect ) ) return false; // Write memory memcpy( pTarget, pSource, Size ); // Restore memory protection attributes of the target memory page DWORD Temp = 0; if( !VirtualProtect( pTarget, Size, OldProtect, &Temp ) ) return false; // Success return true; } This example is adapted from code found here: http://www.debuginfo.com/articles/debugfilters.html#overwrite .

    Read the article

  • Vim - show diff on commit in mercurial;

    - by JackLeo
    In my .hgrc I can provide an editor or a command to launch an editor with options on commit. I want to write a method or alias that launches $ hg ci, it would not only open up message in Vim, but also would split window and there print out $ hg diff. I know that I can give parameters to vim by using +{command} option. So launching $ vim "+vsplit" does the split but any other options goes to first opened window. So I assume i need a specific function, yet I have no experience in writing my own Vim scripts. The script should: Open new vertical split with empty buffer (with vnew possibly) In empty buffer launch :.!hg diff Set empty buffer file type as diff :set ft=diff I've written such function: function! HgCiDiff() vnew :.!hg diff set ft=diff endfunction And in .hgrc I've added option: editor = vim "+HgCiDiff()" It kind of works, but I would like that splited window would be in right side (now it opens up in left) and mercurial message would be focused window. Also :wq could be setted as temporary shortcut to :wq<CR>:q! (having an assumption that mercurial message is is focused). Any suggestions to make this a bit more useful and less chunky? UPDATE: I found vim split guide so changing vnew with rightbelow vnew opens up diff on the right side.

    Read the article

  • Generating Mouse-Keyboard combination events in python

    - by freakazo
    I want to be able to do a combination of keypresses and mouseclicks simultaneously, as in for example Control+LeftClick At the moment I am able to do Control and then a left click with the following code: import win32com, win32api, win32con def CopyBox( x, y): time.sleep(.2) wsh = win32com.client.Dispatch("WScript.Shell") wsh.SendKeys("^") win32api.SetCursorPos((x,y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0) What this does is press control on the keyboard, then it clicks. I need it to keep the controll pressed longer and return while it's still pressed to continue running the code. Is there a maybe lower level way of saying press the key and then later in the code tell it to lift up the key such as like what the mouse is doing?

    Read the article

  • Get newly created window using Win32 API hooks

    - by Nathan W
    This may be a long short or not even possible but no harm in asking. What I am trying to do is monitor an application for any new windows it creates in its MDI control. I have implemented hooking in C# and can capture the MDICREATE window message but because I need to get information about the window after is has been created the MDICREATE message isn't much help because at that stage the window hasn't been created in the other application yet. Without going into to much detail I just need to be able to see when a new window has been created. Is this possible? Thanks

    Read the article

  • How to change the sorting of a view using hook_views_pre_view()?

    - by RD
    I've got the following: function view_sorter_views_pre_view(&$view) { // don't need $items if ($view->name == 'MOST_RECENT') { $insert = array(); $insert[order] = 'DESC'; //SORT ORDER $insert[id] = 'title'; $insert[table] = 'node'; $insert[field] = 'title'; $insert[override] = array(); $insert[override][button] = 'Override'; $insert[relationship] = 'none'; unset ($view->display['default']->display_options['sorts']['title']); $view->display['default']->display_options['sorts']['title'] = $insert; } } Basically, I'm just changing the sort order... but this does not appear on the view when opening it. Any idea why?

    Read the article

  • Drupal hook_cron execution order

    - by LanguaFlash
    Does anyone know off hand what order Drupal executes it's _cron hooks? It is important for a certain custom module I am developing and can't seem to find any documentation on it on the web. Maybe I'm searching for the wrong thing! Any help? Jeff

    Read the article

  • drupal hook_menu_alter9) for adding tabs

    - by EricP
    I want to add some tabs in the "node/%/edit" page from my module called "cssswitch". When I click "Rebuild Menus", the two new tabs are displayed, but they are displayed for ALL nodes when editing them, not just for the node "cssswitch". I want these new tabs to be displayed only when editing node of type "cssswitch". The other problem is when I clear all cache, the tabs completely dissapear from all edit pages. Below is the code I wrote. function cssswitch_menu_alter(&$items) { $node = menu_get_object(); //print_r($node); //echo $node->type; //exit(); if ($node->type == 'cssswitch') { $items['node/%/edit/schedulenew'] = array( 'title' => 'Schedule1', 'access callback'=>'user_access', 'access arguments'=>array('view cssswitch'), 'page callback' => 'cssswitch_schedule', 'page arguments' => array(1), 'type' => MENU_LOCAL_TASK, 'weight'=>4, ); $items['node/%/edit/schedulenew2'] = array( 'title' => 'Schedule2', 'access callback'=>'user_access', 'access arguments'=>array('view cssswitch'), 'page callback' => 'cssswitch_test2', 'page arguments' => array(1), 'type' => MENU_LOCAL_TASK, 'weight'=>3, ); } } function cssswitch_test(){ return 'test'; } function cssswitch_test2(){ return 'test2'; } Thanks for any help.

    Read the article

  • drupal hook_menu_alter() for adding tabs

    - by EricP
    I want to add some tabs in the "node/%/edit" page from my module called "cssswitch". When I click "Rebuild Menus", the two new tabs are displayed, but they are displayed for ALL nodes when editing them, not just for the node "cssswitch". I want these new tabs to be displayed only when editing node of type "cssswitch". The other problem is when I clear all cache, the tabs completely dissapear from all edit pages. Below is the code I wrote. function cssswitch_menu_alter(&$items) { $node = menu_get_object(); //print_r($node); //echo $node->type; //exit(); if ($node->type == 'cssswitch') { $items['node/%/edit/schedulenew'] = array( 'title' => 'Schedule1', 'access callback'=>'user_access', 'access arguments'=>array('view cssswitch'), 'page callback' => 'cssswitch_schedule', 'page arguments' => array(1), 'type' => MENU_LOCAL_TASK, 'weight'=>4, ); $items['node/%/edit/schedulenew2'] = array( 'title' => 'Schedule2', 'access callback'=>'user_access', 'access arguments'=>array('view cssswitch'), 'page callback' => 'cssswitch_test2', 'page arguments' => array(1), 'type' => MENU_LOCAL_TASK, 'weight'=>3, ); } } function cssswitch_test(){ return 'test'; } function cssswitch_test2(){ return 'test2'; } Thanks for any help.

    Read the article

  • Which is the event listener after doSave() in Symfony?

    - by fesja
    Hi, I've been looking at this event-listeners page http://www.doctrine-project.org/documentation/manual/1_1/pl/event-listeners and I'm not sure which is the listener I have to use to make a change after the doSave() method in the BaseModelForm.class.php. // PlaceForm.class.php protected function doSave ( $con = null ) { ... parent::doSave($con); .... // Only for new forms, insert place into the tree if($this->object->level == null){ $parent = Place::getPlace($this->getValue('parent'), Language::getLang()); ... $node = $this->object->getNode(); $method = ($node->isValidNode() ? 'move' : 'insert') . 'AsFirstChildOf'; $node->$method($parent); //calls $this->object->save internally } return; } What I want to do is to make a custom slug with the ancestors' name of that new place. So if I inserting "San Francisco", the slug would be "usa-california-san-francisco" public function postXXXXXX($event) { ... $event->getInvoker()->slug = $slug; } The problem is that I'm inserting a new object with no reference to its parent. After it's saved, I insert it to the tree. So I can't change the slug until then. I think a Transaction listener could work, but I'm use there is a better way I'm not seeing right now. thanks!

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >