handle

How can I tell how much memory a handle object uses in matlab

孤街浪徒 提交于 2019-12-21 07:07:15
问题 If I declare an object to be a subclass of handle classdef obj < handle my object is now essentially a "pointer" to some memory somewhere. How do I find out how much memory my object is using up? For example, say I have a class foo with a field bar classdef foo < handle properties bar = randn(1000); end bar takes up 8 megabytes (8 bytes * 1 million numbers) but if I type obj = foo(); whos('obj'); I get Name Size Bytes Class Attributes obj 1x1 60 foo How do I find out how much total memory obj

How to determine that two Win32 API handles represent the same object?

荒凉一梦 提交于 2019-12-21 05:24:11
问题 Suppose I have two hanldes: HANDLE h1; HANDLE h2; And both have received values resulted from some Windows API function - in particular, I'm interesed in handles resulted from calls to CreateFile() . How do I determine that h1 and h2 reference the same underlying object - in the case of CreateFile() - same file, directory or device? Is there some API to determine that? 回答1: You could use GetFinalPathNameByHandle and compare the file path of both handles. https://msdn.microsoft.com/en-us

Runtime error handling in Swift

跟風遠走 提交于 2019-12-21 03:38:20
问题 I am fully aware that Swift doesn't have a try/catch mechanism to catch exceptions (OK, Swift 2.0 now supports them). I also understand that many API methods return a NSError that will be filled with an error object if something goes wrong. So please don't point me to this question: Error-Handling in Swift-Language But this still doesn't explain how to react to runtime errors in your own code, like array-out-of-bounds accesses or force-unwrapping an optional value that is nil. For example:

Broadcast Receiver Still Running after app close - Android

谁说我不能喝 提交于 2019-12-21 02:54:16
问题 I'm using some code from this tutorial on how to receive SMS messages: The code works perfectly, and does exactly what I want. I am having 1 issue with it. I want my app to run in the background, but when it's closed I want it to stop intercepting SMS messages. My question is, why is my app still intercepting SMS messages after it's been closed? I guess I have to find a "on close" handler and close the Broadcast Receiver then. (If there is a "on close" event handler..?). If anyone can provide

How to tell legends from axes in Matlab?

[亡魂溺海] 提交于 2019-12-21 01:12:12
问题 The following stackoverflow qestion: Matlab: How to obtain all the axes handles in a figure handle? identifies how to get handles to all of the axes from a figure in Matlab. However, this list will also contain handles to legends, at least in R2008a, which appear to also be axes. How can I tell (programatically) the legends from the real plot axes in a vector of axes handles? 回答1: From linkaxes , the code you want is: ax = findobj(gcf,'type','axes','-not','Tag','legend','-not','Tag','Colorbar

How to tell legends from axes in Matlab?

这一生的挚爱 提交于 2019-12-21 01:12:09
问题 The following stackoverflow qestion: Matlab: How to obtain all the axes handles in a figure handle? identifies how to get handles to all of the axes from a figure in Matlab. However, this list will also contain handles to legends, at least in R2008a, which appear to also be axes. How can I tell (programatically) the legends from the real plot axes in a vector of axes handles? 回答1: From linkaxes , the code you want is: ax = findobj(gcf,'type','axes','-not','Tag','legend','-not','Tag','Colorbar

Catching/hijacking stdout in haskell

◇◆丶佛笑我妖孽 提交于 2019-12-20 10:37:55
问题 How can I define 'catchOutput' so that running main outputs only 'bar'? That is, how can I access both the output stream (stdout) and the actual output of an io action separately? catchOutput :: IO a -> IO (a,String) catchOutput = undefined doSomethingWithOutput :: IO a -> IO () doSomethingWithOutput io = do (_ioOutp, stdOutp) <- catchOutput io if stdOutp == "foo" then putStrLn "bar" else putStrLn "fail!" main = doSomethingWithOutput (putStr "foo") The best hypothetical "solution" I've found

How to get the Handle that is executed in winexec or shellexecute?

强颜欢笑 提交于 2019-12-20 05:49:27
问题 i use to create a custom function like winexec(...):Hwnd that will retun the handle of executed application. i did use the findwindow() but having problem if it change window caption. 回答1: There is no general way to get "the" window handle of an application because there's no guarantee that any program has one window handle. A program may have many top-level handles (i.e., Microsoft Word, one for each document), or it may have no windows at all. You might question what you really need the

Invalid object handle error in Matlab

只谈情不闲聊 提交于 2019-12-20 05:33:07
问题 I have the following code which is a graphic rendering of the movement of a satellite around the Earth. function ex global state; fh = figure('Menu','none','Toolbar','none','Units','characters'); hPanAni = uipanel('parent',fh,'Units','characters','Position',... [22.6 10.4 53 23],'title','Controls','FontSize',11,... 'FontAngle','italic','FontWeight','bold'); hIniAni = uicontrol(hPanAni,'Style','pushbutton','Units','normalized',... 'Position',[0.14 0.75 0.5 0.12],'String','Spin',... 'FontSize'

jQuery UI Slider - disable sliding on track/enable on handle mousedown

别说谁变了你拦得住时间么 提交于 2019-12-20 03:23:09
问题 I have a jQuery UI Slider, which I want to disable when a user tries to slide using the track. It should only work/enable when someone drags the handle somewhere. Clicking and trying to drag the sliding to move the handle should be disabled. I'm not sure if this can be done using unbind or mousedown event. The problem I notice is, my handle goes from 1 to 100. When you move the start of the handle, it displays uses the ui.value . But if you try to go outside the handle and slide on the slider