Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4612996
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:28:59+00:00 2026-05-22T01:28:59+00:00

I have an instance of NSWindow that I resize programatically (with setFrame). At its

  • 0

I have an instance of NSWindow that I resize programatically (with setFrame). At its creation, it has a default size of 50×50. I then call setFrame to resize it to 350×450: everything is fine, I can drag my window all I want. Then, later in the program, I resize it to 1024×768. At this point, the only part of the title bar that I can drag is the first 350 pixels: the left part. Nothing happens if I drag the right part. As if the title bar still thinks the window has its previous size.

Updated (Added the code that sets the frame):

void CGLWindowMac::_setSize(int width, int height)
    {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        NSRect sFrame;

        sFrame = [NSWindow contentRectForFrameRect:[mObjcImp frame] styleMask:[mObjcImp styleMask]];

        sFrame.origin.y += sFrame.size.height;
        sFrame.origin.y -= height;
        sFrame.size.height = height;
        sFrame.size.width = width;
        sFrame = [NSWindow frameRectForContentRect:sFrame
                                                    styleMask:[mObjcImp styleMask]];

        NSLog(@"Frame Before setsize: cur Size(%f, %f) ", [mObjcImp frame].size.width, [mObjcImp frame].size.height);

        [mObjcImp setFrame:sFrame display:YES animate:NO];

        NSLog(@"Frame After setsize: cur Size(%f, %f) new val(%d, %d)", [mObjcImp frame].size.width, [mObjcImp frame].size.height, width, height);

        // Tell the application that the window size has change.
        onSize(width, height);

        [pool release];
    }

And here is the output:

2011-05-04 08:50:47.313 ClientProMac[2461:a0f] Frame Before setsize: cur Size(50.000000, 72.000000) 
2011-05-04 08:50:47.340 ClientProMac[2461:a0f] Frame After setsize: cur Size(350.000000, 472.000000) new val(350, 450)
2011-05-04 08:50:49.148 ClientProMac[2461:7003] Frame Before setsize: cur Size(350.000000, 472.000000) 
2011-05-04 08:50:49.160 ClientProMac[2461:7003] Frame After setsize: cur Size(1024.000000, 790.000000) new val(1024, 768)

The weird thing is that if I then resize the window by dragging its corner, the full title bar becomes draggable again: the bug disappear.

Anyone saw this behavior before? What causes it and how can I fix it.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:29:00+00:00Added an answer on May 22, 2026 at 1:29 am

    NSWindow (and most GUI operations in cocoa) are not thread safe. Make sure you’re resizing the window on the main thread.

    For example:

    NSRect frame = NSMakeRect(42, 42, 420, 420);
    dispatch_sync(dispatch_get_main_queue(), ^{
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        [window setFrame:frame];
        [pool release];
    });
    

    If you need backwards compatibility and don’t want to use GCD, you can use -[NSObject performSelectorOnMainThread:withObject:waitUntilDone:].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have an instance of a System.Timers.Timer that has a long interval -
lets say I have an NSWindow Class, that has several events for mouse and
Collections is a public class, then we can call its implicit default constructor. It
I have an instance of a UITableView, and a separate class that adheres to
I have an instance of Class A that I want to refer to in
How do you change the title of an NSWindow instance? I have one window
I have an instance of the Department entity, which in turn has a relationship
I have some instance variables in my class that I'd want to be accessible
I have installed SQL Server 2005 and now have instance name as the default
Looking at the docs for Control.Applicative , I notice that they have instance declarations

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.