Resize NSRunningApplication window - objective-c

I would like to resize a window i got with the runningApplicationWithProcessIdentifier:(pid_t) function of NSRunningApplication class in the the AppKit framework.
Problem is that the NSRunningApplication object does include the .hide() and .unhide() functions but none to resize the window of the application.
Looking forward to your suggestions or solutions.

When I needed to adjust the size of the application window. I resized main window container is my app.
With the help of this: window.contentSize/contentMinSize/contentMaxSize
In visual editor for window:
In code:

Related

Writing app with multiple panels for OS X

I have a regular OS X app (not document-based) that opens image and shows some additional data in separate views.
I want to refactor the same app so that it will use separate panels (or windows) instead of each view.
The panels should have captions and usual window controls.
I do not want this to be a document-based application.
How can it be done?
Update: this is how I do it
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification{
self.pwc=[[SomeWindowController alloc]initWithWindowNibName:#"SomeWindowController"];
[self.pwc showWindow:self.pwc];
The SomeWindowController is derived from NSWindowController
On last line the app crashes. So what is the correct way to deploy additional window?
I figured out the reason of crash. The window contained QLCompactPreview object and in process of initialization it failed.
When I removed the preview the new window appeared.

Creating semi-transparent, round cornered with border Window in Cocoa?

What would be the best approach for creating a Window that is semi-transparent, has round corners and an outline around its border and the arrow, but without the the title bar and buttons.
The window will pop up from the Menu Bar when a use clicks on the menu bar icon.
I'm looking to have an effect similar to the "Applications" and "Downloads" windows:
I guess I will need to do the drawing myself. But I'm wondering what's the best way to do this and whether there is anything already built into Cocoa that can minimize the effort? Or maybe a 3rd party project that has already done that (couldn't find anything exactly like that)?
Thanks.
You can create your window with
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
with a style-mask of NSBorderlessWindowMask which will give an unadorned window. Its how the Dock does its mechanics too.
Note that you must init with this style , you can't change an already init'ed windows style.
Place a custom NSView via the contentView accessor with your desired background custom drawing at the top of the windows view stack.
You might need also to setOpaque to NO
What you are looking for has been done a lot. Too much really.
The classes you want to look into are as follows.
NSStatusItem
This is something that appears in the status bar section of the menu bar to the right side.
NSMenu
If you want this from a menu in the application menus, you'll need to do some clever things with views in menus.
NSWindow
As the other poster notes a borderless window is one way to achieve this.
NSPopover
This is another way. Combined with the above, a fancy technique is to use a clear window called a cover window then, when clicking on the menu or status menu, invoke a popover from a point below that in the clear cover window.
That should be enough to get you started with what you should look into.
Beyond that, peruse the Mac App Store and also look at cocoacontrols.com and GitHub.

A Transparent window without the things inside being transparent

I have been looking all over the internet to find out how to make a window where the window itself isn't there its just a image or a button, for example a free floating image not attached to any windows. I did find the apple roundTransparentWindow page, but it is a bit confusing and really all I would like to know is a image or bu
Creating a completely transparent window is a multi-stage stage process:
Create the window using the style NSBorderlessWindowMask if you are doing it in code. If you are creating the window in a XIB then in Xcode uncheck all the boxes under "Controls" and "Appearance" in the Inspector.
In code set the window's opaque property to NO: [window setOpaque:NO]
In code set the window's background color to nothing: [window setBackgroundColor:[NSColor clearColor]]
Remember that the window will have no window controls (close, resize etc.) the user can interact with - you must manage all these things in your own code.

XCode - Create an application without a window and paint directly on screen

I'm searching now for a while but can't find an entrance…
The application should behave like a ruler app which is always in front of all apps and does not have a window. I want to draw things directly on the screen.
Would be great if someone could help me out with some keywords to search for or a concrete step into.
Thanks in advance.
Create a borderless transparent NSWindow and draw your content inside it. There are many examples for creating those around.
Use setLevel: to control how the window floats over other windows.

Set NSWindow location/size on launch and Lion fullscreen resume = bad layout

I've created an application which initially stores and restores window size and location in the app delegate's applicationWillFinishLaunching: or applicationDidFinishLaunching.
Later I have replaces it with calling [NSWindow setFrameUsingName:] and such to store and load window location and size.
Both storing and loading works just fine (with custom code and with setFrameUsingName)
But now the problem: when I have enabled Fullscreen mode on the application and logout with the option "restore windows". It will launch the application in the separate window to become fullscreen but then my code is called again to set the window size: in effect displaying a small window in the big fullscreen screen.
It seems the lifecycle almost ends with the windowDidEnterFullScreen: call.
The applicationWillFinishLaunching: is called way before the window is put in full screen and the NSWindow's styleMask doesn't show fullscreen there yet.
Anyone able to help me?
The problems where caused by an fade-in animation during application launch.
Make sure you don't start animation on the window in applicationWillFinishLaunching in the app delegate.
Try setting a flag in windowWillEnterFullScreen to let your window know not to set its size.