Skip to main content
gamedev.net
🔒 Locked

Question about coding a friendly windows application

Started by Steve-B 10 replies 1.7k views
Original Post
Steve-B
Steve-B
Hi My first question is: I have set my menu in my program to underline the hot-keys (I'm using VC++ 6) for use when you press ALT. For example file is &File etc. The problem is that the underscore under the letter F (same for the whole menu) only appears when you press the Alt key. How do I change it so it appears in the menu all the time? My second question is: Are there any good tutorials online which show you in a nice easy manner how to add scrollbars to your program. I tried ages ago and it was a total bitch so I just gave in. My third question is: I have created an image viewing program which displays an image in a window. I use DirectDraw to dump the image to screen. I've found that each pixel in the image has to be converted to the same pixel format as the users desktop. This means I have to check the desktop colour depth before I do anything! Not only that but when I dump it to the screen I have to write the data especially for each individual desktop colour depth (16/24/32-bit). I've found this a complete pain in the arse. I didn't realise how much work would be involved and how long-winded the whole process is. Is this how all image viewing programs work or am I doing things the hard way?? Is there a better way? My fourth question is: Carrying on from question 3, I would like to know of a good way of converting from 24-bit image to a 16-bit image at 5-bits per pixel. I wrote some code which works but not very well. Any images which use 256 colours or more look like they're only using something like 32 colours. I am basically just taking each eight bit pixel value and right shifting the data by 3 places to do the converting. Is there a better way of doing this?? Thanks for taking the time to read this long long post. :) Steve
Extrarius
Extrarius
1) That is an OS setting, and has nothing to do with your application

2) AFAIK, it IS a pain to add scrollbars

3) I suggest you use GDI with DIBs (Device Independant Bitmaps) instead. You can make a DIB a specific bit depth, then use GDI functions to display it. CreateDIBSection is the function to make a DIB

4) You just need shift each color component (red, green, blue) over some. Yes, it will make pictures look worse. If you want to preserve the look of the image instead of the actual values, you could try to use some dithering, but you'll have to look that up yourself as I know nothing about dithering algorithms.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Steve-B
Steve-B
Extrarius

Thanks for your response...

1) No, I don't think you're correct here. Other programs (for example Word and VC++) have the menu names with the hotkeys underlined so I don't see why my program doesn't display them by default.

2) Yup! ;)

3) Interesting. :)

4) What I don't understand is how a converted 256 colour image looks like it uses 32 colours when there are over 65,000 colours to choose from in 16-bit mode???
Extrarius
Extrarius
Quote:
Original post by Steve-B
Extrarius

Thanks for your response...

1) No, I don't think you're correct here. Other programs (for example Word and VC++) have the menu names with the hotkeys underlined so I don't see why my program doesn't display them by default.

2) Yup! ;)

3) Interesting. :)

4) What I don't understand is how a converted 256 colour image looks like it uses 32 colours when there are over 65,000 colours to choose from in 16-bit mode???

1) I know XP has such a setting, but it might not be the problem. Word and VS and other MS programs don't really prove anything though, because often times MS programs use custom versions of everything instead of the one built into the OS, so that could be why they have underlines.

4) Are you sure you're shifting the individual portions of the colors instead of the palette indexes themselves? 256 >> 3 (5 bits remaining) = 32, so if you're shifting the index thats exactly what you would get.
Also, often times the palette will have many similar colors, so when you drop the lower 3 bits of each component you might end up with many colors that were slihtly different now being exactly the same.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Anon Mike
Anon Mike
The OS setting to always show underlines is documented in MSDN. Try changing it and see what happens with your app.

MS Office (and hence Word) is notorius for reinventing the wheel and doing everything slightly differently than everybody else in the universe. You can't really use them as an example of how normal apps work. I have no clue about Firefox.
-Mike
Staffan E
Staffan E
Note: Use the SystemParametersInfo() function with the SPI_GETKEYBOARDCUES flag to set the global hotkey underlining preference from within your program.

If you really want to have underlines show all the time in your program, you could intercept the WM_PAINT message of the menu bar and draw the menu titles yourself using the DrawText() function.

Regards
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
daerid
daerid
Firefox uses it's own UI rendering scheme, and doesn't use standard Win32 menus. That's why the indicators are underlined all the time.
daerid@gmail.com
mutex
mutex
Just FYI, you'll want to adhere to the menu underlining settings, so that people who prefer them off (like me) will have their desires honored.

Steve-B
Steve-B
Quote:
Original post by mutex
Just FYI, you'll want to adhere to the menu underlining settings, so that people who prefer them off (like me) will have their desires honored.

Yes, I think I'll just leave the menu as it is with the default settings. Thanks for all the replies even if they were to the least significant of my questions. Such is life. lol. Cheers. :)

Steve-B
jeroenb
jeroenb
2) If you want to add scrollbars to your application, I would recommend using MFC to program your application. It has the ScrollView class available which makes it fairly simple to create a sophisticated scrolling window. Otherwise, when you want to code it all yourself you must handle the WM_HSCROLL and WM_VSCROLL messages (and add the scrollbars during creation of the window). if you want I might be able to write a tutorial about it on my website.

3) Here again, when you want to use bitmaps in your application, I would recommend using MFC. It has the CBitmap class which makes life much easier. The hard way is to call the Win32 LoadImage function which can load a bitmap file into a device context for you, which you can BitBlt (or StretchBlt, etc) to your window.

4) You might want to use a standard painting program to convert image resolution :)
Crafter 2D: the open source 2D game framework ?Github: https://github.com/crafter2d/crafter2d
Twitter: [twitter]crafter_2d[/twitter]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.