Advertisement

Icon windows? Lock that splitter window?

Started by February 22, 2000 01:28 PM
3 comments, last by Stoffel 24 years, 6 months ago
Continuing my development of the MFC board game: - First: Thanks Fel. You had mentioned that my idea of storing bitmaps for each tile wouldn''t be the best way to do it. I finally implemented it, and it just wasn''t effective. - I have an SDI MFC app, using a splitter window. On the right side of the splitter is my game board, and on the left is a FormView (a Dialog box in a window). I got it so that the window starts up with the correct size and the splitter bar where I want it, but I want to disallow the user from being able to move the splitter. Is there a way to do this? - On my Board graphic, I''ve overloaded the erase background message to draw the board (which never changes). Fel suggested I use icons for the pieces as they move around the board, which sounds like a great idea, but I''ve never worked with icons before. How do I go about doing this? Does the view own the icons, or the frame? And I don''t want the user to be able to move them, they''re just for display purposes. Thanks for the continued help, everyone.
For your splitter bar, you'll need to derive a class from the base splitter class and capture all of the mouse input. This will keep it from going on to the base class so the splitter won't change. You can also keep the mouse from chaning cursors this way.

If you are talking about using icons like I think you are, they are handled like other resources. They are stored, normally, in the executable and you can retrieve them using a couple Windows functions. You'll need to look in the docs for these.

Edited by - I-Shaolin on 2/22/00 2:37:31 PM
Advertisement
Here''s a few pointers about icons, just to get you started:

Icons are resources, but they aren''t the same thing as bitmaps. They have an inherent device image, which changes per device context. In order to use them correctly, you need to take a look at all the icon device images you have (it''s a dropdown above your icon display window when you have it up). Figure out which one you want. Go to Image->Delete Device Image to delete the ones you don''t. You can create new device images to be the size you want, if the ones that are present aren''t the right size and/or color depth. You can support anything that will fit on the screen size wise and up to 256 colors. Remember to use the special transparent paint bucket to paint in your background, the internal transparent background handling is the coolest thing about icons. Keep in mind here that just because something is teal it doesn''t mean it''s transparent, you might have made it the color teal by accident.

Bitmaps can be turned into icons. You can load a bitmap out of a bitmap file using the bitmap resource set, then copy and paste that onto a new icon (just get the device image size and color depth set right first). Then delete the bitmap, you don''t need it anymore.

It makes me wince whenever people say they''re overloading the erase background message because I''ve seen it used badly so much... Why do you feel you need to do that? Invalidate supports a BOOL choice of whether or not to redraw the back, and if you''re really concerned InvalidateRect is the way to go. There are a few valid reasons to override the erase background function... but most people don''t run into them.

As for splitter windows, I haven''t messed with those much... but I believe there''s a function called SetColumnInfo. Maybe you could try messing with that and setting the miminum width of each of your two panes to be the default width, and recalc and reset every time the user resizes (if you''re letting them resize). Haven''t tried it, don''t have any projects loaded with splitter windows at the moment, so not sure if it will work, but is worth a try.

g''luck
-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
I''m overloading OnEraseBackground because it really is the background I''m drawing in that call. The "board", along with the background of the board, never change. Also, all the objects I''ll be drawing on top of the board (game pieces, movement arrows, etc.) should obscure the board as they go by and then reveal the board again when they''re done. As I understand it, the default OnEraseBackground just fills the clip area with the default brush for the window. Since I''m writing over everything anyway (and probably want to have a watermark-like bitmap as the background to the board eventually), I''m just overriding that function.

I''ll try overriding the splitter window. Maybe I should dig through the source for CSplitterWnd and see what it''s doing.

Thanks for the icon tips. I''ll see if I can make them work.
Something I forgot to mention:
Sometimes when you import a bitmap, you get a weird looking result, color-wise. To fix that, save your palette and load it into devstudio by using Image->Load Palette.
If you''re lucky you won''t have to deal with that tho.

Are you overriding OnDraw to draw your board?

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~

This topic is closed to new replies.

Advertisement