2

I am coding a media player in VC++ using pure Win32 API's. Everything is done so far. But for a seek bar currently I am using slider control. But the problem with slider control is that when a user clicks on the end of slider then the thumb of slider will jump only to the next tick. I want to make a seekbar like VLC, thus whenever a user clicks somewhere on the slider then it jump accurately. Do anyone can tell me how can I make a seekbar like VLC without using MFC, QT or other UI framework, I am just using pure Win32 API's.

Thanking you

  • AFAIR, foobar2000 uses a custom control for this purpose. You can actually check that or VLC seekbar with Spy++. Try subclassing the slider control and setting the slider position manually on mouse and keyboard events. – skink May 10 '13 at 15:57
  • VLC uses QT interface and I tried subclassing the slider control but nothing happens. May be I am doing wrong, thus seeking for the help. – user2370419 May 10 '13 at 16:05
  • Would you like to share what you've tried? This way it'd be possible to tell you what's wrong. – skink May 10 '13 at 16:10
  • This will certainly help you: http://forums.codeguru.com/showthread.php?534731 – skink May 10 '13 at 17:12
  • @Joulukuusi: Thanks for your link, it's really useful. But how can I skin it? I mean look like VLC or something good related to media players – user2370419 May 11 '13 at 06:43
  • I am not able to convert this MFC code in plain Win32 because I have not idea of MFC.http://forums.codeguru.com/showthread.php?534731-Trackbar-Position-OnClick&p=2106081#post2106081 – user2370419 May 11 '13 at 07:47
  • The conversion should be easy: `GetChannelRect` -> `TBM_GETCHANNELRECT`, `GetThumbRect` -> `TBM_GETTHUMBRECT`, you get the idea. `InflateRect` and `PtInRect` are native WinAPI functions. `CSliderCtrl::OnLButtonDown()` is just a plain `CallWindowFunction`. Regarding skinning: this is a separate question, and it has been answered here at Stack Overflow. Check http://stackoverflow.com/questions/9216917/, or do a search! – skink May 11 '13 at 08:02
  • I tried converting the MFC code, and here is what I have done. http://pastebin.com/e1HNg8yf but now the slider is not working. :( – user2370419 May 11 '13 at 08:33
  • You don't need `GetCursorPos`, because [`WM_LBUTTONDOWN`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms645607.aspx) message already has the coordinates in `lParam`. You're also passing wrong first parameter to `SendMessage`, it should be `hwnd` of your slider control callback (i.e. slider handle). And make sure you're calling `CallWindowProc` at the end of the callback! – skink May 11 '13 at 08:45

0 Answers0