Native WinAPI Sortable (Button) List Functionality

Started by
2 comments, last by Stani R 8 years ago

I know this is a long shot but does WinAPI have Sortable List functionality similar to JQuery's Sortable Lists? And to push my luck even further, does similar functionality exist for a vertical list of Button controls (as opposed to ListBox items)? Could I possibly use Drag and Drop for this? Or possibly DragDetect()?

If there's no native functionality, do you know of any 3rd Party libraries (C WinAPI). Without knowing the proper name for this functionality (sortable lists?) its hard to search for a 3rd party library.

e4d70d728d734083a11eef0338b70525_jqueryf

Advertisement

The magic you see there is a combination of many heavy technologies. HTML DOM objects floating freely, moving by script inside a JIT script runner inside a browser, the task of dragging and sliding requires a relatively powerful computer to make it look smooth.

The smooth UI of moving large boxes around like that is relatively recent with modern processing power. Back in the Win95 and Win98 days a company I was at was trying to build similar custom controls, and the animations would typically peg the CPU as small boxes were moving. We recommended at least a 600MHz Pentium 3 as a minimum spec for smooth display.

There is nothing built in to Windows that looks similar. The tech built in to the API is extremely lightweight, mostly about forwarding events and data packets that your program can respond to, the core of the Windows API stuff was built for processors from the 1980s and 1990s.

For implementation, options include creating your own owner-drawn component with movable boxes inside it, creating small boxes that respond to events and push themselves up and down, or otherwise doing much of it yourself.

Drag and drop could work, but it is normally less visible than you describe. For Windows drag and drop typically only the mouse cursor changes when you are dragging, and the application may do some extra paint calls to perhaps drop a marker where the drop will take place. Whatever drawing you do is also custom work. It would not look like what you see in jQueryUI. If you are using any of the tools like WinForms to build your UI it may be a little easier since it is visually on screen as you edit, but still will require some work.

Another option is to embed some HTML viewer in your program. A very heavyweight solution, but it can be done.

Another option is to buy a controls library, like those sold by DevExpress, which was the way things were often done before the modern web browsers and web apps. Most of these controls cost several hundred dollars. It may be a lot for a hobby developer, but for a business that is cheaper than paying a worker for the weeks it would take to develop, refine, debug, and generalize the solutions.

Whatever you end up going with, good luck on it.

There is nothing natively available in win32 for this, so you'll have to implement it yourself. May I recommend an alternative GUI library for you that has this functionality and more? Sciter. I've switched from win32 to Sciter and never looked back since then. It's an HTML/JavaScript/CSS engine that is ALSO lightweight and free for commercial and non-commercial use. You can easily setup drag and drop for a button list if you look at the drag-n-drop samples in the SDK.

There is a bit of a learning curve though. One neat characteristic is that you don't have to replace your existing application's GUI completely if your application is not at its development start. You can create Sciter windows in addition to your existing native windows.

p.s: I'm not affiliated with Sciter in any way - I just like it and think it deserves more popularity.

In Qt, QListWidget and probably also QListView can be configured for similar functionality (rearranging list elements with drag&drop). But while it can be styled with CSS, I don't think you'll be able to make it look as pretty as jQuery.

Otherwise I would also consider embedding CEF or Awesonium, depending on how far you want to go with imitating javascript UI.

This topic is closed to new replies.

Advertisement