Rebar - toolbars overlapping problem
-
Hi, I am struggling to create a decent-looking toolbar using the Windows API with no MFC (it may well be easier with MFC if you know it, but I have yet to plough through my MFC books and I don't want to port the whole of my nearly-finished current project). After struggling for a couple of days to get a 'flat' look (using TBSTYLE_FLAT) without having all the buttons become transparent, I discovered that to get the look I wanted, I needed to use Rebars. I used the code from MSDN (here) to create a test rebar, and it gave me the look I wanted - except that it is still screwy in another way (probably because MSDN assumes two other functions that it doesn't provide - CreateToolBar() and CreateComboBox()). Essentially, I want two rows of toolbars, so I figured that I would need to create two toolbars and two 'bands' in my rebar to hold them (ie. two calls of RB_INSERTBAND with the RBBS_BREAK style. I have successfully set up my test proggy so that it has two bands of the correct size, but the problem is that the toolbar buttons that should be on the second band aren't in the right place - they overlap the toolbar buttons on the first band (ie. both toolbars seem to have been created at window co-ords 0,0). I can better explain what I mean by posting a picture: Picture Here The CPP file for this test proggy can be downloaded here - this is the only file of the project, so can be compiled to the test prog. It's messy because it's just a test program that I threw together to try and get rebars and toolbars working. CreateRebar() was ripped from MSDN, with only minor modifications. The problem might be there, or it might be in CreateToolBar() (which creates a toolbar with three text buttons) or CreateToolBarIcons() (which creates a toolbar with some standard Windows buttons). I've stared and stared, experimented, tested and generally poked around, but I just can't see what I'm doing wrong. If anybody has a chance to scan these functions to see what my mistake is, or just make some suggestions as to what you might think the problem could be, I would really appreciate it. Obviously I don't expect anybody to debug my code - I only attach the CPP file because it is easier than posting three long functions here. Many thanks to anyone who can help, KB
-
Hi, I am struggling to create a decent-looking toolbar using the Windows API with no MFC (it may well be easier with MFC if you know it, but I have yet to plough through my MFC books and I don't want to port the whole of my nearly-finished current project). After struggling for a couple of days to get a 'flat' look (using TBSTYLE_FLAT) without having all the buttons become transparent, I discovered that to get the look I wanted, I needed to use Rebars. I used the code from MSDN (here) to create a test rebar, and it gave me the look I wanted - except that it is still screwy in another way (probably because MSDN assumes two other functions that it doesn't provide - CreateToolBar() and CreateComboBox()). Essentially, I want two rows of toolbars, so I figured that I would need to create two toolbars and two 'bands' in my rebar to hold them (ie. two calls of RB_INSERTBAND with the RBBS_BREAK style. I have successfully set up my test proggy so that it has two bands of the correct size, but the problem is that the toolbar buttons that should be on the second band aren't in the right place - they overlap the toolbar buttons on the first band (ie. both toolbars seem to have been created at window co-ords 0,0). I can better explain what I mean by posting a picture: Picture Here The CPP file for this test proggy can be downloaded here - this is the only file of the project, so can be compiled to the test prog. It's messy because it's just a test program that I threw together to try and get rebars and toolbars working. CreateRebar() was ripped from MSDN, with only minor modifications. The problem might be there, or it might be in CreateToolBar() (which creates a toolbar with three text buttons) or CreateToolBarIcons() (which creates a toolbar with some standard Windows buttons). I've stared and stared, experimented, tested and generally poked around, but I just can't see what I'm doing wrong. If anybody has a chance to scan these functions to see what my mistake is, or just make some suggestions as to what you might think the problem could be, I would really appreciate it. Obviously I don't expect anybody to debug my code - I only attach the CPP file because it is easier than posting three long functions here. Many thanks to anyone who can help, KB
P.S. Depending on what version of comctl32.lib you are using, you may have to change MIIM_STRING to MIIM_TYPE to get main.cpp to compile - or just comment out the whole of CreateMenu() as it has nothing to do with my toolbar problem anyway. Any replies or help much appreciated! Many thanks, KB