DRawable Panel, Resize and Scrollbars !
-
This is starting to get to me ! So, let me ask you all, just in case someone has a quick solution for my problem. Here's what I would like to do. Imageine a simple Win App, with a main form with a couple of buttons, and a panel. The buttons are "Rectangle", "Ellipses", and "None". If you click on the "Rectangle" button, you can draw a rectangle in the panel (by clicking-dragging in the panel). Similarly, if you click on the "Ellipses" button, you'll be able to draw an ellipses in the panel. The "None" button is there simply to let you go back to your standard mouse situation. So far so good. I got all of that working by using the GDI+ DrawRectangle and DrawEllipses functions. Now, my problem is that I can't make the panel pop-up the scrollbars (both vertical and horizontal) as needed. In other words, if I open up the application, maximize it to full screen, and draw something in the lower-right corner of the panel, when I resize the application to a smaller size, the drawn object does not show up in the panel (duh! it's out there somewhere). But, most importantly, the scrollbars of the panel do not appear either ! I've tried to set to true the AutoScroll property of the panel, and set the minimum size and the actual size of the scrollbars to (5,5), but that had no impact. As far as I can tell, the problem is that the AutoScroll property comes into play only if some "Control" is placed outside the viewable area of the panel at some point, while the rectangles and circles are (being drawn with GDI+) not considered controls ! Any suggestions ? Thanks in advance for your 2 pennies :-) F.O.R.
-
This is starting to get to me ! So, let me ask you all, just in case someone has a quick solution for my problem. Here's what I would like to do. Imageine a simple Win App, with a main form with a couple of buttons, and a panel. The buttons are "Rectangle", "Ellipses", and "None". If you click on the "Rectangle" button, you can draw a rectangle in the panel (by clicking-dragging in the panel). Similarly, if you click on the "Ellipses" button, you'll be able to draw an ellipses in the panel. The "None" button is there simply to let you go back to your standard mouse situation. So far so good. I got all of that working by using the GDI+ DrawRectangle and DrawEllipses functions. Now, my problem is that I can't make the panel pop-up the scrollbars (both vertical and horizontal) as needed. In other words, if I open up the application, maximize it to full screen, and draw something in the lower-right corner of the panel, when I resize the application to a smaller size, the drawn object does not show up in the panel (duh! it's out there somewhere). But, most importantly, the scrollbars of the panel do not appear either ! I've tried to set to true the AutoScroll property of the panel, and set the minimum size and the actual size of the scrollbars to (5,5), but that had no impact. As far as I can tell, the problem is that the AutoScroll property comes into play only if some "Control" is placed outside the viewable area of the panel at some point, while the rectangles and circles are (being drawn with GDI+) not considered controls ! Any suggestions ? Thanks in advance for your 2 pennies :-) F.O.R.
Got it ! Just for future reference of anyone who stumbles upon this: look at the following two articles here on CodeProject: http://www.codeproject.net/books/1861004990.asp and http://www.codeproject.com/cs/miscctrl/tracker.asp As a summary, I think my main mistake was to set the AutoScrollMinSIze to a value that was too small (5,5). Once I set this to the value of the highest X (and Y) coordinate of the stuff I was drawing, it worked much better! HTH, F.O.R. PS: funny thing is I *do* have the WROX book from the first link, but I left it at the office !