ShellExecute from within a procedure - shellexecute

i want to call this.. well as good as
ShellExecute(Handle, 'open', 'c:\Windows\notepad.exe', nil, nil, SW_SHOWNORMAL)
i can call this without issue from within a method of form1
but i just had a procedure "procedure transformdataset();" that i want to call this in and it does not recognise handle... do i just need to make this procedure a method of form1?
how do i do that? is that the solution.

Yes, ShellExecute needs the Window Handle. The most straightforward solution is to pass it in to your method. I find this a bit ugly though so, personally, I'd consider calling ShellExecute when the method returns. If the call is optional (dependent on data), consider returning a status flag from the method that indicates whether the ShellExecute call is required. Either way works, though.

Related

What does the `free` method from TProcess do?

What does the free method do in TProcess. It's used in several examples I found on the net but there's nothing in the reference about it? So far I used it and everything works fine. Can I continue to use it or should I use a different method?
It is the Free method defined in TObject, at the very root of the class hierarchy. This method does the same thing in every single class, there is nothing special with TProcess in this regard.
It is documented:
Free will check the Self pointer and calls Destroy if it is different from Nil. This is a safer method than calling Destroy directly.

Why is the lock activated by XInitThreads non-recursive?

Consider the following call flow:
Function A calls XCheckIfEvent passing a pointer to function B in the predicate parameter. Function B calls XGetWindowProperty.
If XLib is initialized with the XInitThreads function, the above call flow hangs at the call to XGetWindowProperty. It seems to me that the lock which is activated when XInitThreads is called is not recursive. If true, why? Is there a way to make it recursive? Or is it officially prohibited to call XLib functions from within a callback passed to an XLib function?
From the man page:
If Xlib has been initialized for threads, the predicate is called with
the display locked and the result of a call by the predicate to any
Xlib function that locks the display is not defined unless the caller
has first called XLockDisplay.
From the other man page:
Nested calls to XLockDisplay work correctly
So it seems that the predicate must call XLockDisplay, and XUnlockDisplay when it's done.

Xcode won't run or step into one of my called methods

I'm not sure what's expected for me to leave here, but basically, I've passed an object of type AwesomeMenu into an ActionControl object's (subclass of NSOBject) initializer class so that the ActionControl object has a reference to the AwesomeMenu. However, in one of the ActionControl functions, there is a call like
[self.menu updateButton];
Where self.menu is the AwesomeMenu and updateButton is a function within AwesomeMenu. For some reason, XCode never enters updateButton. I've tried setting up breakpoints inside updateButton. They don't ever trip. I tried stepping INTO updateButton (it just shows me the parameters and then it skips past the line without taking me into the function), etc. I don't get any errors either. My chosen path through the program takes me over that function call multiple times but it never actually calls.
What's happening?
I did not assign self.menu prior to calling one of its functions; self.menu's value was nil. I just had to switch my initialization statements around to get it to work.

Invoking a method at the end of Cocoa's main event loop

How would it be possible to invoke a method at the end of Cocoa's main event loop after each iteration? I want to do the exact same thing that NSManagedObjectContext's -processPendingChanges does. According to the documentation, "In AppKit-based applications, this method is invoked automatically at least once during the event loop (at the end of the loop)." I need to do the same thing for one of my own methods. Is this possible? I've read documentation about NSRunLoop and NSApplication's -run method, but I haven't been able to find the solution to this problem. Any help would be much appreciated.
I believe you can achieve what you want by installing a CFRunLoopObserver. You can get the current CFRunLoopRef via CFRunLoopGetCurrent() or from an NSRunLoop via -[NSRunLoop getCFRunLoop].

How to find the current name of the test being executing?

I know I can figure out the name of the method as its being executed, just wondering if there is a way from the setup method. I guess an attribute method would work but from the setup method it would be the best.
EDIT NUnit
I know this is going to sound negative, but don't do it! :-)
The idea behind the setup method is that it executes something required by every test, which means that it doesn't matter which test is being executed, so you don't need to know the name of the method.
If you are after different data used in initialisation, then call a separate method with the data passed as a parameter from your test method.
If you really want what you are asking for, then you may need a different method that takes the name of the current method as a parameter and call that from your test method.

Resources