开发者

Simple Win32 Trackbar

I have created a simple game using Win32 and gdi. I would like to have a track bar at the bottom that tracks a globa开发者_高级运维l variable. I'm just not sure how to add controls. How could I add a trackbar? I can imagine it would get created in the wm_create event.


Do you mean TrackBar or StatusBar?

A StatusBar is normally located at the bottom of a window and displays informational messages about the application status, a TrackBar allows the user to select a value. Do you want to allow the user to select the value of your global variable or do you just want to display the current value of the variable? (I'm not sure if the trackbar will display the current value of the variable without extra work.)

Either way, there are samples for both StatusBar and TrackBar located on MSDN.

The child windows are normally created either in the WM_CREATE of the parent or after the parent window has been created (i.e. when you obtain a valid hWnd for the parent) and after calling InitCommonControls() and/or initializing COM if needed.


To create controls on the fly, in general use the CreateWindow function. With a bit of googling for "TrackBar+CreateWindow" you'll find a number of samples for your question:

i.e.:

http://zetcode.com/gui/winapi/controlsII/ or

http://msdn.microsoft.com/en-us/library/bb760151%28VS.85%29.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜