How to attach a band to the right side of CReBar control - windows

On my frame window I have a CReBar control with non-movable bands on several lines. On the last line there are two bands, which currently aligned to the left, the second immediately after the first.
+--------+-------+------------------------------------+
|11111111|2222222|
+--------+-------+------------------------------------+
But my product management wants me to attach the second band to the right side of the line, with empty space in the middle.
+--------+------------------------------------+-------+
|11111111| |2222222|
+--------+------------------------------------+-------+
I cannot find anywhere how to do that. I would be grateful for any help.
Edit:
The actual code uses the Xtreme GUI library, but its structure is pretty standard:
// ... Create toolbars
// Add toolbars to ReBar.
if (m_wndReBar.Create(this) &&
m_wndReBar.AddToolBar(pNavigateTB, RBBS_BREAK | RBBS_NOGRIPPER) &&
m_wndReBar.AddBar(&m_wndAddressBar, NULL, NULL, RBBS_NOGRIPPER) &&
m_wndReBar.AddToolBar(pMainToolBar, RBBS_BREAK | RBBS_NOGRIPPER) &&
m_wndReBar.AddToolBar(pViewsHelpTB, RBBS_NOGRIPPER))
{
...
}
Here m_wndReBar is a CReBar-derived class, and toolbars are Xtreme wrappers of the common Toolbar control. They use the regular MFC flags, and I didn't find an option to align toolbar to the right.

There is no style or parameter of a toolbar, which forces it to align to the right. However, it is possible to expand the previous toolbar in a way that it will push the subsequent toolbar to the rightmost position.
Let, as in the first figure above, two consecutive toolbars are on the same line in the CReBar, and the first toolbar has index I. Than the command
m_ReBar.SendMessage(RB_MAXIMIZEBAND, I, 0);
will move the second toolbar to the right, as in the second figure. This rightmost position will be kept during the window resizing, but adding a new toolbar to the rebar can break it.

Related

How to grab the scrolling amount in one window?

This is the first step to scroll two windows simulteneously, the second step is to find a way to apply that amount to the other program. But I really don't know where to start, all I see in from Google is about modifying the behavior of the scroll of the mouse, not the scrolling amount in one window. Advantages of using this instead of listening to the keys:
Scrolling will be seamless since the other program are scrolled in the background
Clicking on the scrollbar works
Different scrolling speeds don't affect the comparison
Moving lines in text editors won't scroll pages in PDF viewers
I can tell you what I would do, but it's not going to be fun...
Assuming the text is roughly evenly distributed (which it might not be between two languages like that, and two windows with different text sizes and widths, really consider this carefully before you do the work), then the goal is to force both scroll bars to be at the same percent relative to their whole. So what you need to do is write a function to determine what percent each scroll bar is at. I would screen capture both windows and crop out the important parts of the scroll bar like this:
Specifically the up and down buttons, the top of the scroll handle, the bottom of the scroll handle. Save them in their own files. Do it for both windows in case they draw their scroll bars a little differently.
Now the tricky part. Write a function that does the following: imagesearch for the top button within rightmost 25 pixels or of the specified window. Same for the bottom button. Same for the top of the handle. Same for the bottom of the handle. Use this to determine where your window is.
SetTitleMatchMode, 2 ; so it matches the end of the title
WinGetPos , X, Y, Width, Height, LibreOffice Writer ;exact substring of window name required
Use something like this to find the scroll bar parts.
CoordMode, Pixel , Screen ;so image search searches entire screen
barwidth = 25 ; make sure it's more than the bar is wide.
ImageSearch, TopButtonX, TopButtonY, X+Width-barwidth , Y, X+Width, Y+Height, TopButton.bmp ; no jpg, fuzzy edges make searches fail
Then do some math, something like:
TopButtonY := TopButtonY+TopButtonImageHeight ; because we only care about the position of the bottom of the button.
BottomHandleY := BottomHandleY+BottomHandleImageHeight ; because we only care about where the bottom of the handle is.
HandleHeight := TopHandleY - BottomHandleY ; how tall the scroll handle is
TotalHeight := TopButtonY - BottomButtonY - HandleHeight ;how tall the scroll field is
HandleOffset := TopHandleY - TopButtonY ;how far it is from the top
HandlePercent := HandleOffset / TotalHeight ; the part we care about. return this value
With a function like that, you can know how scrolled each window is. All that's left is to send the scroll commands. There's a few choices.
; ControlSend , Control, Keys, LibreOffice Writer
ControlSend , Control, {Pgdown}, LibreOffice Writer ; or {Pgup}
ControlSend , Control, {WheelUp}, LibreOffice Writer ; or {wheeldown}
ControlSend , Control, {Up}, LibreOffice Writer ; or {down}
If it lets you move the caret with up/down arrows while the window is inactive, that is probably the most precise option, even if it takes a bit longer. The fastest most precise way is to simulate a click drag also using control send. To use ControlSend you need to figure out which control you're working on. WindowSpy can help you with that.
So first: Find the scroll positions of both windows. Second determine which window is active. Third, nudge the inactive window in the correct direction. Repeat until they're within a certain tolerance range (otherwise it will bounce up and down endlessly).
I can't emphasize this enough, but please make sure that getting the scroll bars in approximately the same positions is sufficiently close before even attempting this. If it isn't, you will have wasted a lot of time fiddling with it. Keep in mind it will be less and less accurate the longer the text is.
If it is an option, I would definitely consider copying the contents of both windows into a program that gives you more access to the controls (or better one that is specialized for this purpose). If you had more access, you could use the paragraph breaks to line up the texts with far more precision.
If you really just want to see both texts side by side (and the paragraphs do line up), you could find a text editor that tells you information like this:
If autohotkey will let you read the text of that information, you can copy the PDF into autohotkey's memory (separated by line) and use autohotkey to show only the corresponding paragraph of the PDF as you move around in the editable document.
Hope something I said helps, good luck.

CKEditor inline toolbar position

Simple question : how can I make the inline CKEditor toolbar float top right (or bottom right) of my editable element instead of the default top left position ?
Have been googling it but no luck so far :(
Thank you
It does not have a configuration option for this. There are only four options for the X,Y offset in pinned and docked modes - e.g. config.floatSpacePinnedOffsetY.
The only idea that I have is implementing your own plugin like Floating Space, or modifying the current implementation.
And as the last resort, you can use the Shared Space plugin to place the toolbar in a container chosen by you and then position it as you wish. Check the second demo (Inline Editor with Shared Toolbar and Bottom Bar) on the SDK sample page for an example.
we can do it with floatSpacePreferRight config
only we need to set
config.floatSpacePreferRight = true;
default value of floatSpacePreferRight is false;
so with this configuration, we can align inline toolbar position to right

is there a trick to working with multiple visual studio panel objects at design time

Is there some sort of shortcut key that I am missing here for swapping panels around in the form editor of vs2010?
I have numerous panels which are swapped at runtime according to an enum "toggle" value and the only way I seem to be able to move them back and forth is to make one panel smaller than another and right click it. Half the time I end up selecting some other object in the action of trying to right my panels.
I figured there must be something i'm missing here.
there are icons on the layout toolbar for this task. I pick the panel in properties and move it around with those. Way easier than right clicking and hoping for the best.
edit: although sometimes the buttons are not enabled when you need them to be. Still right clicking a resize handle adorner dot will pop up the context menu where you can then choose to move back/forward.
I still wish there was some key combo I could press. Hitting the 4px of display area that the adorner dot occupies on my screen is sort of a dexterity test of sorts and slows me down.

How to tell the position of a menu item in VB6?

I am using Visual Basic 6 (please don't laugh), and I would like to dynamically position a control, at runtime, in a position based upon the position of one of the "top level" menu items (such as "File", "Edit", "View").
Unfortunately, VB's Menu control (which is the type of control that these "File", "Edit", etc. things are) does not have any properties like "Top", "Left", "Height", or "Width".
I could just experiment, eyeballing it, and eventually arrive at numbers that I'll hardcode, but for various reasons I would prefer that the code actually figure out where the control should go.
I am thinking that perhaps there is some Windows API call that I can use to figure out the position of the Menu control?
Thanks in advance.
Edit: In case it matters, this is on an MDI form.
Edit #2:
OK, answering my own question:
You can get the position of each item on the main menu bar via the GetMenuBarInfo function, such as:
Dim mbi as MENUBARINFO
mbi.cbSize = LenB(mbi)
GetMenuBarInfo Me.hWnd, OBJID_MENU, lMenuNumber, mbi
Where "lMenuNumber" is 1 for the first (e.g. "File"), 2 for the second (e.g. "Edit"), etc.
That mbi struct has an rcBar member, which is the coordinates of the rectangle where that menu item is.
Unfortunately, it's in absolute coordinates relative to the screen, not relative to the MDI form. So, get the mbi the one you're interested in and of the first, and subtract.
Plus, the position as given in the mbi is in pixels, so convert as necessary to twips or whatever.
This is sort of doomed. Standard menus will vary in appearance and width with the version of Windows and the user's settings for UI fonts and such. For all we know Windows Next/8 may put them along the left side of the window!
If this information were meant to be used it would be available.
Perhaps if you could explain more about what you are trying to do with your UI we might have alternative suggestions.
OK, answering my own question:
You can get the position of each item on the main menu bar via the GetMenuBarInfo function, such as:
Dim mbi as MENUBARINFO
mbi.cbSize = LenB(mbi)
GetMenuBarInfo Me.hWnd, OBJID_MENU, lMenuNumber, mbi
Where "lMenuNumber" is 1 for the first (e.g. "File"), 2 for the second (e.g. "Edit"), etc.
That mbi struct has an rcBar member, which is the coordinates of the rectangle where that menu item is.
Unfortunately, it's in absolute coordinates relative to the screen, not relative to the MDI form. So, get the mbi the one you're interested in and of the first, and subtract.
Plus, the position as given in the mbi is in pixels, so convert as necessary to twips or whatever.

How can I position QDockWidgets as the screen shot shows using code?

I want a Qt window to come up with the following arrangement of dock widgets on the right.
alt text http://img72.imageshack.us/img72/6180/docksonside.png
Qt allows you to provide an argument to the addDockWidget method of QMainWindow to specify the position (top, bottom, left or right) but apparently not how two QDockWidgets placed on the same side will be arranged.
Here is the code that adds the dock widgets. this uses PyQt4 but it should be the same for Qt with C++
self.memUseGraph = mem_use_widget(self)
self.memUseDock = QDockWidget("Memory Usage")
self.memUseDock.setObjectName("Memory Usage")
self.memUseDock.setWidget(self.memUseGraph)
self.addDockWidget(Qt.DockWidgetArea(Qt.RightDockWidgetArea),self.memUseDock)
self.diskUsageGraph = disk_usage_widget(self)
self.diskUsageDock = QDockWidget("Disk Usage")
self.diskUsageDock.setObjectName("Disk Usage")
self.diskUsageDock.setWidget(self.diskUsageGraph)
self.addDockWidget(Qt.DockWidgetArea(Qt.RightDockWidgetArea),self.diskUsageDock)
When this code is used to add both of them to the right side, one is above the other, not like the screen shot I made. The way I made that shot was to drag them there with the mouse after starting the program, but I need it to start that way.
You can use QMainWindow::splitDockWidget .
From the docs:
Splits the space covered by the first dock widget into two parts, moves the first dock widget into the first part, and moves the second dock widget into the second part.
The orientation specifies how the space is divided: A Qt::Horizontal split places the second dock widget to the right of the first; a Qt::Vertical split places the second dock widget below the first.
You have to set QMainWindow::dockNestingEnabled to true first (but I guess you already did that).
I never tried it but I think you can set the orientation of the dock widget when adding it to the main window:
void QMainWindow::addDockWidget ( Qt::DockWidgetArea area, QDockWidget * dockwidget, Qt::Orientation orientation )

Resources