 |
 |
Screen Resolution Problems
|
 |
|
 |
|
Junior Member
Join Date: Oct 2001
Status:
Offline
|
|
After I set the resolution to 800X600
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
// Get the screen rect of our main display
frame = [[NSScreen mainScreen] frame];
cgFrame = CGDisplayBounds(kCGDirectMainDisplay);
printf("%f,%f,::%f,%f\n",frame.s ize.width, frame.size.height, cgFrame.size.width, cgFrame.size.height);</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">frame has the value of the original resolution and cgFrame has the new resolution. Am I missing something?
type R
|
|
I be that insane n***a from the psycho ward.
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by type_r503:
<strong>After I set the resolution to 800X600
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
// Get the screen rect of our main display
frame = [[NSScreen mainScreen] frame];
cgFrame = CGDisplayBounds(kCGDirectMainDisplay);
printf("%f,%f,::%f,%f\n",frame.s ize.width, frame.size.height, cgFrame.size.width, cgFrame.size.height);</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">frame has the value of the original resolution and cgFrame has the new resolution. Am I missing something?
type R</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Well, this sounded like a possible bug, so I whipped up a small program with one method and a button in the main window to call it. This is the complete code in the method:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> NSRect cocoaRect;
CGRect cgRect;
cocoaRect = [[NSScreen mainScreen] frame];
cgRect = CGDisplayBounds(kCGDirectMainDisplay);
NSLog(@"\nThe Cocoa method says it is %f x %f\nThe CG way says it's %f x %f", cocoaRect.size.width, cocoaRect.size.height, cgRect.size.width, cgRect.size.height);</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I get the same numbers on both lines (no matter how many times I change the resolution), so I don't imagine there's anything wrong with the functions.
So here's my theory: Project Builder doesn't seem to handle printf() quite right for some reason, so the rects might actually be right while the printing is delayed. Try using NSLog() and see if you get the results you were expecting.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by Chuckit:
<strong>So here's my theory: Project Builder doesn't seem to handle printf() quite right for some reason, so the rects might actually be right while the printing is delayed. Try using NSLog() and see if you get the results you were expecting.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Use fflush(stdout) to make sure all stdout is flushed. 
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|