I'm trying to build a resizable Carbon window as part of a tutorial. I am using Interface Builder 3.2.3 on Snow Leopard 10.6.4.
If I create an empty Carbon project and add a window object from the Library (with Close, Minimize, Resize and Zoom buttons in the Inspector all checked), run the Carbon Simulator and then attempt to resize the window by grabbing the resize control, the window vanishes.
However if I create a Carbon project that already has the window object included (i.e instead of an empty project where I add the window myself after first creating it) I have no problem resizing the window in that case.
I try to visually match the selections in the Inspector to see what is different between the settings of these two cases but I don't readily notice any differences in the two sets of parameters that are displayed. Thus I am curious as whether there are more settings that just aren't displayed on the Inspector.
Are there any common reasons for a Carbon window to vanish upon resizing?
Thanks
I notice that if the option to receive clicks is not checked, then the window goes away when you try to resize it. But I don't know how you could uncheck that accidentally.
JWWalker, thanks for the response. Receive Clicks was checked on both versions.
But I think I was able to (sort of) figure out the discrepancy examining the .nib file.
Both files have two keys defined: maxSize (under com.apple.ibtool.document.localizable-all) and gMaxSize (under com.apple.ibtool.document.objects). In the working file both of these have a string setting of {480, 270}. In the nonworking file they had a string setting of {0, 0}. Apparently the default configuration of the working file was setting the maximum size of the window equal to zero. In Inspector the Window Template Size tab had the "Maximum Size" box checked but a "0" for both Width and Height. I clicked the box once to clear the check. Ran the Carbon Simulator again and the window resized properly without disappearing. When I rechecked the box, Inspector automatically filled in the Width and Height parameters with valid values of 480 and 270. I ran the Carbon Simulator again and it resized properly in accordance with the new maximum size constraint.
I don't fully understand the XML code in the .nib file but apparently the default setting for the maximum size of the window was being set to zero. The incorrect code appeared in the .nib file as follows (with non relevant lines deleted):
com.apple.ibtool.document.localizable-all
<dict>
<key>1</key>
<dict>
<key>maxSize</key>
<string>{0, 0}</string>
com.apple.ibtool.document.objects
<dict>
<key>1</key>
<dict>
<key>gMaxSize</key>
<string>{0, 0}</string>
You must uncheck the minimum size and maximum size in window template size or set the correct value.
Related
Following the answer here:
Set QuickLook window size when previewing with QLPreviewingController.preparePreviewOfFile I set the preferredContentSize of the QLPreviewingController, which changes the window size as intended, but this seems to break subsequent auto resizing of all subviews. After setting it, the content will no longer track the preview window size when the user resizes it manually or enters fullscreen.
Any attempts to set view sizes, resizing masks or constraints programmatically after setting the preferredContentSize property will cause errors like
<NSViewServiceMarshal: 0x7fe1b740f170 <QLPreviewExtensionViewController: 0x600000e31b00 <NSServiceViewControllerWindow: 0x7fe1b760b350>>> attempted to set frame of <NSServiceViewControllerWindow: 0x7fe1b760b350> from {{17, 382}, {820, 846}} to {{17, 382}, {800, 600}} and got {{17, 136}, {820, 846}}; set breakpoint on -[NSViewServiceMarshal actualFrame:differsFromSpecifiedFrame:oldFrame:ofWindow:] to catch this
and have no visible effect. Setting the breakpoint only tells me that it happens in a system background thread at about the time I try to change the size of the view.
EDIT: Another finding: If I print the frames values of all views and the window to the log, the printed size is the one I requested, not the smaller one actually showing on the screen! I.e. if I set preferredContentSize to (820, 846), my debug NSLogs and the Xcode Debug View Hierarchy shows a window that is 820 x 846, while the actual window showing onscreen is twice as wide as it is high.
EDIT: Made a video to illustrate this problem: https://youtu.be/l7b1jq7pDWY
Original code is here:
https://github.com/angstsmurf/spatterlight/blob/quicklook-ifiction/iFictionQuickLook/iFictionPreviewController.m
This seems to be a Catalina only bug (earlier versions do not support this kind of Quicklook extension.) Upgrading to Big Sur made it go away.
In Firefox, I use privacy.resistfingerprinting = true. How can I set the window size (1024x768 or 1366x768 or another) that I need? So that I open the browser and the window size matches the resolution I need.
What I did:
Set the values to privacy.window.maxInnerHeight and privacy.window.maxInnerWidth. But the size is 1000x700, 1400x800, etc., i.e. not the one i need.
Used privacy.resistfingerprinting.letterboxing with the specified resolution in .dimensions, it seems to work. BUT, this works with a delay. I open a test page in which resolution is displayed through <body onload="alert (window.innerWidth)"> and at the very beginning the real value is displayed and only then changed using letterboxing. That is, it is possible to intercept the real value.
I tried to resize the window through Window.resizeTo (), but it does not change.
Tell me how to launch a browser with a window of the desired size with privacy.resistfingerprinting enabled?
I've got a dialog box where I need to display the standard Information icon. Here's my RC code:
ICON "",IDC_ICON_INFORMATION,18,70,21,20
I process the WM_INITDIALOG message as follows:
HICON aIcn = LoadIcon(NULL, IDI_INFORMATION);
SendDlgItemMessage(m_hWnd, IDC_ICON_INFORMATION, STM_SETICON, (WPARAM) aIcn, 0);
Everything works great under 96 DPI: the static control displays a 32x32-pixel icon.
However, when I switch to higher DPI's (through right-clicking on the Desktop, choosing Screen resolution, and clicking Make or other items larger or smaller) the icon does not scale! Since everything else scales nicely, the icon looks visually much smaller than the neighboring text. I would expect that on 144 DPI (150%) the icon dimensions will be 48x48 pixels. I did declare my application as DPI-aware through an XML manifest.
The damnedest thing is that when I use my own custom-made icon (also coming from the RC file), everything scales perfectly. Furthermore, the MessageBox function called with the MB_ICONINFORMATION flag does display a scaled version of the icon, as well.
Given these thoughts, I assume of the following:
The static control with the SS_ICON style can display scaled versions of icons.
The icon resource that contains the standard Information icon has a scaled version of the icon (48x48).
What am I doing wrong then?
Use LoadImage() instead of LoadIcon(), and specify the cxDesired and cyDesired params with the values you get from GetSystemMetrics(SM_CYICON) and GetSystemMetrics(SM_CXICON).
Or maybe just declaring your app as DPI aware could be enough? You can try that easily by simple creating a text file making it a manifest file.
See the example in the remarks section for the SetProcessDPIAware API
I have this Win32 user-drawn tab control that is created as:
CONTROL "Tab1",IDC_TAB_CONT,"SysTabControl32",TCS_BOTTOM |
TCS_OWNERDRAWFIXED | NOT WS_VISIBLE,0,14,185,88
I'd like for this control to have its tabs resize as never to have to see the "sliding arrows":
Now, pretty much everything about this control works as expected, except for that fact that it won't respond to TabCtrl_SetItemSize. Try as I may, the size I get for the tabs when I get to draw them (in the DRAWITEMSTRUCT passed to WM_DRAWITEM) is always the size that fits the longest caption in them and never the size I've set with TabCtrl_SetItemSize.
However, in the TabCtrl_SetItemSize documentation, it says that:
[TabCtrl_SetItemSize] sets the width and height of tabs in a
fixed-width or owner-drawn tab
control.
The only way I've managed to have a decent resizing is by setting a dummy string of the desired length in it by sending the control a TCM_SETITEM message, and writing the desired text in it at draw time. This is rather inconvenient and not a particularly nice hack.
Is there anybody who would know
Why TabCtrl_SetItemSize isn't working as expected? and/or
How to set the tab size properly?
Many thanks,
joce.
Setting TCS_OWNERDRAWFIXED style is not enough, you have also to add TCS_FIXEDWIDTH style.
The minimum size of a tab is at least icon width + 3 if icon is present.
If you have icons (imageList attached to tabControl), you might get those "sliding arrows" even with fixed width (if there is less space available than: number of tabs*(icon width+3)
I have made a GUI in Netbeans. Now I want that the frame size should remain constant, means the user cannot do maximize or restore the frame.
When I go the the frame properties dialog box, I didn't see any property that allow me to set the size of the frame.
I opened the frame properties dialog box by right clicking on the "FrameView" node in the "Inspector" window.
How can I do that?
Uncheck "resizable". That will prevent the user from changing the window size.
Next, set the preferredSize property (if you're using java.awt.Frame instead of JFrame set the minimumSize property instead).