Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

printf

macrumors regular
Original poster
Aug 27, 2008
105
0
ok, i have a chromless hiview window, which i programmatically handle the dragging and resizing for. i'm experiencing a weird issue when attempting to drag the window AFTER it has been resized. what happens is this:

1) drag window. result: ok
2) resize window. result: ok
3) drag window away from top left of screen. result: window inexplicably grows while dragging

to outline a few HIPoints (hehe):
i've created the window using CreateCustomWindow and passing in a hiview created with HIObjectCreate. to use the transparency features, i turn off kWindowIsOpaque using HIWindowChangeFeatures and in the kEventControlDraw event, just before drawing, i call CGContextClearRect. this all of course, allows me to create windows with custom shapes, or in my case, just a simple chromeless window in which i draw my titlebar and contents dynamically.

i can provide more code if you need it. i'm using a slightly modified version of the CarbonTransparentWindow example here if you'd like to take a look at that: http://developer.apple.com/samplecode/CarbonTransparentWindow/index.html

here's a snippet of the kEventControlTrack event where the problem occurs:

Code:
				case kEventControlTrack:
				{
					
					Point pt;
					status = GetEventParameter(inEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(pt), NULL, &pt);

					WindowRef window = GetControlOwner(myData->view);
					
					Rect viewBounds;
					GetWindowBounds(window, kWindowStructureRgn, &viewBounds );

					int bl_dragging = 0;
					if(pt.v<20){ //only drag if mouse in top 20px area					
						pt.h += viewBounds.left;
						pt.v += viewBounds.top;
						DragWindow(window, pt, NULL);									
						bl_dragging = 1;
					}else{						
						Rect result_rc;
						GetWindowBounds(window,kWindowStructureRgn,&result_rc);						
						//resize code here...
						result_rc.right-=1;
						SetWindowBounds(window,kWindowStructureRgn,&result_rc);					
					}
					return noErr;	
}

to simplify the issue for you, i've replaced my dragging code with DragWindow as they both do the same thing and produce the same erroneous results. i've also removed the resize code and replaced it with a simple decremental statement: result_rc.right-=1;

again, this anomaly only occurs after a resize as noted in the numbered steps above and the 'growing' effect is magnified proportionately with dragging it to the lower right of the screen. (ie. dragging the window all the way toward the lower right of the screen will result in a window that is at least as large as the desktop).

final note. an interesting observation i noticed in my custom window dragging code which is done in a do while loop using TrackMouseLocation: if i call SetWindowBounds twice, the first time, the window will grow large, but the second call will set it to the expected size. in a kMouseTrackingMouseDragged event loop, this creates a flickering behavior as the window sizes back and forth... strange!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.