1 // TortoiseIDiff - an image diff viewer in TortoiseSVN
3 // Copyright (C) 2006-2013, 2015 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "TortoiseIDiff.h"
23 #include "MainWindow.h"
25 #include "TaskbarUUID.h"
27 #pragma comment(lib, "comctl32.lib")
29 tstring
CMainWindow::leftpicpath
;
30 tstring
CMainWindow::leftpictitle
;
32 tstring
CMainWindow::rightpicpath
;
33 tstring
CMainWindow::rightpictitle
;
35 const UINT TaskBarButtonCreated
= RegisterWindowMessage(L
"TaskbarButtonCreated");
37 bool CMainWindow::RegisterAndCreateWindow()
41 // Fill in the window class structure with default parameters
42 wcx
.cbSize
= sizeof(WNDCLASSEX
);
43 wcx
.style
= CS_HREDRAW
| CS_VREDRAW
;
44 wcx
.lpfnWndProc
= CWindow::stWinMsgHandler
;
47 wcx
.hInstance
= hResource
;
48 wcx
.hCursor
= LoadCursor(NULL
, IDC_SIZEWE
);
49 ResString
clsname(hResource
, IDS_APP_TITLE
);
50 wcx
.lpszClassName
= clsname
;
51 wcx
.hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_TORTOISEIDIFF
));
52 wcx
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+1);
53 if (selectionPaths
.empty())
54 wcx
.lpszMenuName
= MAKEINTRESOURCE(IDC_TORTOISEIDIFF
);
56 wcx
.lpszMenuName
= MAKEINTRESOURCE(IDC_TORTOISEIDIFF2
);
57 wcx
.hIconSm
= LoadIcon(wcx
.hInstance
, MAKEINTRESOURCE(IDI_TORTOISEIDIFF
));
58 if (RegisterWindow(&wcx
))
60 if (Create(WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_VISIBLE
, NULL
))
69 void CMainWindow::PositionChildren(RECT
* clientrect
/* = NULL */)
72 if (clientrect
== NULL
)
74 SendMessage(hwndTB
, TB_AUTOSIZE
, 0, 0);
75 GetWindowRect(hwndTB
, &tbRect
);
76 LONG tbHeight
= tbRect
.bottom
-tbRect
.top
-1;
77 HDWP hdwp
= BeginDeferWindowPos(3);
78 if (bOverlap
&& selectionPaths
.empty())
80 SetWindowPos(picWindow1
, NULL
, clientrect
->left
, clientrect
->top
+tbHeight
, clientrect
->right
-clientrect
->left
, clientrect
->bottom
-clientrect
->top
-tbHeight
, SWP_SHOWWINDOW
);
86 if (selectionPaths
.size() != 3)
90 child
.left
= clientrect
->left
;
91 child
.top
= clientrect
->top
+tbHeight
;
92 child
.right
= clientrect
->right
;
93 child
.bottom
= nSplitterPos
-(SPLITTER_BORDER
/2);
94 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow1
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
95 child
.top
= nSplitterPos
+(SPLITTER_BORDER
/2);
96 child
.bottom
= clientrect
->bottom
;
97 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow2
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
101 // three image windows
103 child
.left
= clientrect
->left
;
104 child
.top
= clientrect
->top
+tbHeight
;
105 child
.right
= clientrect
->right
;
106 child
.bottom
= nSplitterPos
-(SPLITTER_BORDER
/2);
107 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow1
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
108 child
.top
= nSplitterPos
+(SPLITTER_BORDER
/2);
109 child
.bottom
= nSplitterPos2
-(SPLITTER_BORDER
/2);
110 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow2
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
111 child
.top
= nSplitterPos2
+(SPLITTER_BORDER
/2);
112 child
.bottom
= clientrect
->bottom
;
113 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow3
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
118 if (selectionPaths
.size() != 3)
122 child
.left
= clientrect
->left
;
123 child
.top
= clientrect
->top
+tbHeight
;
124 child
.right
= nSplitterPos
-(SPLITTER_BORDER
/2);
125 child
.bottom
= clientrect
->bottom
;
126 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow1
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
127 child
.left
= nSplitterPos
+(SPLITTER_BORDER
/2);
128 child
.right
= clientrect
->right
;
129 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow2
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
133 // three image windows
135 child
.left
= clientrect
->left
;
136 child
.top
= clientrect
->top
+tbHeight
;
137 child
.right
= nSplitterPos
-(SPLITTER_BORDER
/2);
138 child
.bottom
= clientrect
->bottom
;
139 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow1
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
140 child
.left
= nSplitterPos
+(SPLITTER_BORDER
/2);
141 child
.right
= nSplitterPos2
-(SPLITTER_BORDER
/2);
142 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow2
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
143 child
.left
= nSplitterPos2
+(SPLITTER_BORDER
/2);
144 child
.right
= clientrect
->right
;
145 if (hdwp
) hdwp
= DeferWindowPos(hdwp
, picWindow3
, NULL
, child
.left
, child
.top
, child
.right
-child
.left
, child
.bottom
-child
.top
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
);
149 if (hdwp
) EndDeferWindowPos(hdwp
);
150 picWindow1
.SetTransparentColor(transparentColor
);
151 picWindow2
.SetTransparentColor(transparentColor
);
152 picWindow3
.SetTransparentColor(transparentColor
);
153 InvalidateRect(*this, NULL
, FALSE
);
156 LRESULT CALLBACK
CMainWindow::WinMsgHandler(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
158 if (uMsg
== TaskBarButtonCreated
)
160 SetUUIDOverlayIcon(hwnd
);
167 picWindow1
.RegisterAndCreateWindow(hwnd
);
168 picWindow2
.RegisterAndCreateWindow(hwnd
);
169 if (selectionPaths
.empty())
171 picWindow1
.SetPic(leftpicpath
, leftpictitle
, true);
172 picWindow2
.SetPic(rightpicpath
, rightpictitle
, false);
174 picWindow1
.SetOtherPicWindow(&picWindow2
);
175 picWindow2
.SetOtherPicWindow(&picWindow1
);
179 picWindow3
.RegisterAndCreateWindow(hwnd
);
181 picWindow1
.SetPic(selectionPaths
[FileTypeMine
], selectionTitles
[FileTypeMine
], false);
182 picWindow2
.SetPic(selectionPaths
[FileTypeBase
], selectionTitles
[FileTypeBase
], false);
183 picWindow3
.SetPic(selectionPaths
[FileTypeTheirs
], selectionTitles
[FileTypeTheirs
], false);
186 picWindow1
.SetSelectionMode(!selectionPaths
.empty());
187 picWindow2
.SetSelectionMode(!selectionPaths
.empty());
188 picWindow3
.SetSelectionMode(!selectionPaths
.empty());
191 // center the splitter
193 GetClientRect(hwnd
, &rect
);
194 if (selectionPaths
.size() != 3)
196 nSplitterPos
= (rect
.right
-rect
.left
)/2;
201 nSplitterPos
= (rect
.right
-rect
.left
)/3;
202 nSplitterPos2
= (rect
.right
-rect
.left
)*2/3;
205 PositionChildren(&rect
);
206 picWindow1
.FitImageInWindow();
207 picWindow2
.FitImageInWindow();
208 picWindow3
.FitImageInWindow();
213 return DoCommand(LOWORD(wParam
), lParam
);
222 ::GetClientRect(*this, &rect
);
223 hdc
= BeginPaint(hwnd
, &ps
);
224 SetBkColor(hdc
, GetSysColor(COLOR_3DFACE
));
225 ::ExtTextOut(hdc
, 0, 0, ETO_OPAQUE
, &rect
, NULL
, 0, NULL
);
229 case WM_GETMINMAXINFO
:
231 MINMAXINFO
* mmi
= (MINMAXINFO
*)lParam
;
232 mmi
->ptMinTrackSize
.x
= WINDOW_MINWIDTH
;
233 mmi
->ptMinTrackSize
.y
= WINDOW_MINHEIGHT
;
240 GetClientRect(hwnd
, &rect
);
244 GetWindowRect(hwndTB
, &tbRect
);
245 LONG tbHeight
= tbRect
.bottom
-tbRect
.top
-1;
246 if (selectionPaths
.size() != 3)
248 nSplitterPos
= (rect
.bottom
-rect
.top
)/2+tbHeight
;
253 nSplitterPos
= (rect
.bottom
-rect
.top
)/3+tbHeight
;
254 nSplitterPos2
= (rect
.bottom
-rect
.top
)*2/3+tbHeight
;
259 if (selectionPaths
.size() != 3)
261 nSplitterPos
= (rect
.right
-rect
.left
)/2;
266 nSplitterPos
= (rect
.right
-rect
.left
)/3;
267 nSplitterPos2
= (rect
.right
-rect
.left
)*2/3;
270 PositionChildren(&rect
);
275 if ((HWND
)wParam
== *this)
279 GetClientRect(*this, &rect
);
281 ScreenToClient(*this, &pt
);
282 if (PtInRect(&rect
, pt
))
286 HCURSOR hCur
= LoadCursor(NULL
, IDC_SIZENS
);
291 HCURSOR hCur
= LoadCursor(NULL
, IDC_SIZEWE
);
297 return DefWindowProc(hwnd
, uMsg
, wParam
, lParam
);
301 Splitter_OnLButtonDown(hwnd
, uMsg
, wParam
, lParam
);
304 Splitter_OnLButtonUp(hwnd
, uMsg
, wParam
, lParam
);
306 case WM_CAPTURECHANGED
:
307 Splitter_CaptureChanged();
310 Splitter_OnMouseMove(hwnd
, uMsg
, wParam
, lParam
);
314 // find out if the mouse cursor is over one of the views, and if
315 // it is, pass the mouse wheel message to that view
317 DWORD ptW
= GetMessagePos();
318 pt
.x
= GET_X_LPARAM(ptW
);
319 pt
.y
= GET_Y_LPARAM(ptW
);
321 GetWindowRect(picWindow1
, &rect
);
322 if (PtInRect(&rect
, pt
))
324 picWindow1
.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam
), GET_WHEEL_DELTA_WPARAM(wParam
));
328 GetWindowRect(picWindow2
, &rect
);
329 if (PtInRect(&rect
, pt
))
331 picWindow2
.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam
), GET_WHEEL_DELTA_WPARAM(wParam
));
335 GetWindowRect(picWindow3
, &rect
);
336 if (PtInRect(&rect
, pt
))
338 picWindow3
.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam
), GET_WHEEL_DELTA_WPARAM(wParam
));
346 // find out if the mouse cursor is over one of the views, and if
347 // it is, pass the mouse wheel message to that view
349 DWORD ptW
= GetMessagePos();
350 pt
.x
= GET_X_LPARAM(ptW
);
351 pt
.y
= GET_Y_LPARAM(ptW
);
353 GetWindowRect(picWindow1
, &rect
);
354 if (PtInRect(&rect
, pt
))
356 picWindow1
.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam
)|MK_SHIFT
, GET_WHEEL_DELTA_WPARAM(wParam
));
360 GetWindowRect(picWindow2
, &rect
);
361 if (PtInRect(&rect
, pt
))
363 picWindow2
.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam
)|MK_SHIFT
, GET_WHEEL_DELTA_WPARAM(wParam
));
367 GetWindowRect(picWindow3
, &rect
);
368 if (PtInRect(&rect
, pt
))
370 picWindow3
.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam
)|MK_SHIFT
, GET_WHEEL_DELTA_WPARAM(wParam
));
378 LPNMHDR pNMHDR
= (LPNMHDR
)lParam
;
379 if (pNMHDR
->code
== TTN_GETDISPINFO
)
383 lpttt
= (LPTOOLTIPTEXT
) lParam
;
384 lpttt
->hinst
= hResource
;
386 // Specify the resource identifier of the descriptive
387 // text for the given button.
388 TCHAR stringbuf
[MAX_PATH
] = {0};
390 mii
.cbSize
= sizeof(MENUITEMINFO
);
391 mii
.fMask
= MIIM_TYPE
;
392 mii
.dwTypeData
= stringbuf
;
393 mii
.cch
= _countof(stringbuf
);
394 GetMenuItemInfo(GetMenu(*this), (UINT
)lpttt
->hdr
.idFrom
, FALSE
, &mii
);
395 _tcscpy_s(lpttt
->lpszText
, 80, stringbuf
);
400 bWindowClosed
= TRUE
;
404 ImageList_Destroy(hToolbarImgList
);
405 ::DestroyWindow(m_hwnd
);
408 return DefWindowProc(hwnd
, uMsg
, wParam
, lParam
);
414 LRESULT
CMainWindow::DoCommand(int id
, LPARAM lParam
)
422 picWindow1
.SetPic(leftpicpath
, _T(""), true);
423 picWindow2
.SetPic(rightpicpath
, _T(""), false);
426 picWindow1
.SetSecondPic(picWindow2
.GetPic(), rightpictitle
, rightpicpath
);
430 picWindow1
.SetSecondPic();
433 GetClientRect(*this, &rect
);
434 PositionChildren(&rect
);
435 picWindow1
.FitImageInWindow();
436 picWindow2
.FitImageInWindow();
440 case ID_VIEW_IMAGEINFO
:
442 bShowInfo
= !bShowInfo
;
443 HMENU hMenu
= GetMenu(*this);
444 UINT uCheck
= MF_BYCOMMAND
;
445 uCheck
|= bShowInfo
? MF_CHECKED
: MF_UNCHECKED
;
446 CheckMenuItem(hMenu
, ID_VIEW_IMAGEINFO
, uCheck
);
448 picWindow1
.ShowInfo(bShowInfo
);
449 picWindow2
.ShowInfo(bShowInfo
);
450 picWindow3
.ShowInfo(bShowInfo
);
452 // change the state of the toolbar button
454 tbi
.cbSize
= sizeof(TBBUTTONINFO
);
455 tbi
.dwMask
= TBIF_STATE
;
456 tbi
.fsState
= bShowInfo
? TBSTATE_CHECKED
| TBSTATE_ENABLED
: TBSTATE_ENABLED
;
457 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_IMAGEINFO
, (LPARAM
)&tbi
);
460 case ID_VIEW_OVERLAPIMAGES
:
462 bOverlap
= !bOverlap
;
463 HMENU hMenu
= GetMenu(*this);
464 UINT uCheck
= MF_BYCOMMAND
;
465 uCheck
|= bOverlap
? MF_CHECKED
: MF_UNCHECKED
;
466 CheckMenuItem(hMenu
, ID_VIEW_OVERLAPIMAGES
, uCheck
);
467 uCheck
|= ((m_BlendType
== CPicWindow::BLEND_ALPHA
) && bOverlap
) ? MF_CHECKED
: MF_UNCHECKED
;
468 CheckMenuItem(hMenu
, ID_VIEW_BLENDALPHA
, uCheck
);
469 UINT uEnabled
= MF_BYCOMMAND
;
470 uEnabled
|= bOverlap
? MF_ENABLED
: MF_DISABLED
| MF_GRAYED
;
471 EnableMenuItem(hMenu
, ID_VIEW_BLENDALPHA
, uEnabled
);
473 // change the state of the toolbar button
475 tbi
.cbSize
= sizeof(TBBUTTONINFO
);
476 tbi
.dwMask
= TBIF_STATE
;
477 tbi
.fsState
= ((m_BlendType
== CPicWindow::BLEND_ALPHA
) && bOverlap
) ? TBSTATE_CHECKED
: 0;
478 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_OVERLAPIMAGES
, (LPARAM
)&tbi
);
480 tbi
.fsState
= (m_BlendType
== CPicWindow::BLEND_ALPHA
) ? TBSTATE_CHECKED
: 0;
482 tbi
.fsState
|= TBSTATE_ENABLED
;
485 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_BLENDALPHA
, (LPARAM
)&tbi
);
490 tbi
.fsState
= bVertical
? TBSTATE_ENABLED
| TBSTATE_CHECKED
: TBSTATE_ENABLED
;
491 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_ARRANGEVERTICAL
, (LPARAM
)&tbi
);
495 bLinkedPositions
= true;
496 picWindow1
.LinkPositions(bLinkedPositions
);
497 picWindow2
.LinkPositions(bLinkedPositions
);
498 tbi
.fsState
= TBSTATE_CHECKED
;
501 tbi
.fsState
= bLinkedPositions
? TBSTATE_ENABLED
| TBSTATE_CHECKED
: TBSTATE_ENABLED
;
502 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_LINKIMAGESTOGETHER
, (LPARAM
)&tbi
);
504 ShowWindow(picWindow2
, bOverlap
? SW_HIDE
: SW_SHOW
);
508 picWindow1
.StopTimer();
509 picWindow2
.StopTimer();
510 picWindow1
.SetSecondPic(picWindow2
.GetPic(), rightpictitle
, rightpicpath
,
511 picWindow2
.GetHPos(), picWindow2
.GetVPos());
512 picWindow1
.SetBlendAlpha(m_BlendType
, 0.5f
);
516 picWindow1
.SetSecondPic();
518 picWindow1
.SetOverlapMode(bOverlap
);
519 picWindow2
.SetOverlapMode(bOverlap
);
523 GetClientRect(*this, &rect
);
524 PositionChildren(&rect
);
529 case ID_VIEW_BLENDALPHA
:
531 if (m_BlendType
== CPicWindow::BLEND_ALPHA
)
532 m_BlendType
= CPicWindow::BLEND_XOR
;
534 m_BlendType
= CPicWindow::BLEND_ALPHA
;
536 HMENU hMenu
= GetMenu(*this);
537 UINT uCheck
= MF_BYCOMMAND
;
538 uCheck
|= ((m_BlendType
== CPicWindow::BLEND_ALPHA
) && bOverlap
) ? MF_CHECKED
: MF_UNCHECKED
;
539 CheckMenuItem(hMenu
, ID_VIEW_BLENDALPHA
, uCheck
);
540 UINT uEnabled
= MF_BYCOMMAND
;
541 uEnabled
|= bOverlap
? MF_ENABLED
: MF_DISABLED
| MF_GRAYED
;
542 EnableMenuItem(hMenu
, ID_VIEW_BLENDALPHA
, uEnabled
);
544 // change the state of the toolbar button
546 tbi
.cbSize
= sizeof(TBBUTTONINFO
);
547 tbi
.dwMask
= TBIF_STATE
;
548 tbi
.fsState
= ((m_BlendType
== CPicWindow::BLEND_ALPHA
) && bOverlap
) ? TBSTATE_CHECKED
| TBSTATE_ENABLED
: TBSTATE_ENABLED
;
549 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_BLENDALPHA
, (LPARAM
)&tbi
);
550 picWindow1
.SetBlendAlpha(m_BlendType
, picWindow1
.GetBlendAlpha());
554 case ID_VIEW_TRANSPARENTCOLOR
:
556 static COLORREF customColors
[16] = {0};
558 memset(&ccDlg
, 0, sizeof(ccDlg
));
559 ccDlg
.lStructSize
= sizeof(ccDlg
);
560 ccDlg
.hwndOwner
= m_hwnd
;
561 ccDlg
.rgbResult
= transparentColor
;
562 ccDlg
.lpCustColors
= customColors
;
563 ccDlg
.Flags
= CC_RGBINIT
| CC_FULLOPEN
;
564 if(ChooseColor(&ccDlg
))
566 transparentColor
= ccDlg
.rgbResult
;
567 picWindow1
.SetTransparentColor(transparentColor
);
568 picWindow2
.SetTransparentColor(transparentColor
);
569 picWindow3
.SetTransparentColor(transparentColor
);
570 // The color picker takes the focus and we don't get it back.
571 ::SetFocus(picWindow1
);
575 case ID_VIEW_FITIMAGEWIDTHS
:
577 bFitWidths
= !bFitWidths
;
578 picWindow1
.FitWidths(bFitWidths
);
579 picWindow2
.FitWidths(bFitWidths
);
580 picWindow3
.FitWidths(bFitWidths
);
582 HMENU hMenu
= GetMenu(*this);
583 UINT uCheck
= MF_BYCOMMAND
;
584 uCheck
|= bFitWidths
? MF_CHECKED
: MF_UNCHECKED
;
585 CheckMenuItem(hMenu
, ID_VIEW_FITIMAGEWIDTHS
, uCheck
);
587 // change the state of the toolbar button
589 tbi
.cbSize
= sizeof(TBBUTTONINFO
);
590 tbi
.dwMask
= TBIF_STATE
;
591 tbi
.fsState
= bFitWidths
? TBSTATE_CHECKED
| TBSTATE_ENABLED
: TBSTATE_ENABLED
;
592 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_FITIMAGEWIDTHS
, (LPARAM
)&tbi
);
595 case ID_VIEW_FITIMAGEHEIGHTS
:
597 bFitHeights
= !bFitHeights
;
598 picWindow1
.FitHeights(bFitHeights
);
599 picWindow2
.FitHeights(bFitHeights
);
600 picWindow3
.FitHeights(bFitHeights
);
602 HMENU hMenu
= GetMenu(*this);
603 UINT uCheck
= MF_BYCOMMAND
;
604 uCheck
|= bFitHeights
? MF_CHECKED
: MF_UNCHECKED
;
605 CheckMenuItem(hMenu
, ID_VIEW_FITIMAGEHEIGHTS
, uCheck
);
607 // change the state of the toolbar button
609 tbi
.cbSize
= sizeof(TBBUTTONINFO
);
610 tbi
.dwMask
= TBIF_STATE
;
611 tbi
.fsState
= bFitHeights
? TBSTATE_CHECKED
| TBSTATE_ENABLED
: TBSTATE_ENABLED
;
612 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_FITIMAGEHEIGHTS
, (LPARAM
)&tbi
);
615 case ID_VIEW_LINKIMAGESTOGETHER
:
617 bLinkedPositions
= !bLinkedPositions
;
618 picWindow1
.LinkPositions(bLinkedPositions
);
619 picWindow2
.LinkPositions(bLinkedPositions
);
620 picWindow3
.LinkPositions(bLinkedPositions
);
622 HMENU hMenu
= GetMenu(*this);
623 UINT uCheck
= MF_BYCOMMAND
;
624 uCheck
|= bLinkedPositions
? MF_CHECKED
: MF_UNCHECKED
;
625 CheckMenuItem(hMenu
, ID_VIEW_LINKIMAGESTOGETHER
, uCheck
);
627 // change the state of the toolbar button
629 tbi
.cbSize
= sizeof(TBBUTTONINFO
);
630 tbi
.dwMask
= TBIF_STATE
;
631 tbi
.fsState
= bLinkedPositions
? TBSTATE_CHECKED
| TBSTATE_ENABLED
: TBSTATE_ENABLED
;
632 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_LINKIMAGESTOGETHER
, (LPARAM
)&tbi
);
636 picWindow1
.SetBlendAlpha(m_BlendType
, 0.0f
);
638 case ID_VIEW_ALPHA255
:
639 picWindow1
.SetBlendAlpha(m_BlendType
, 1.0f
);
641 case ID_VIEW_ALPHA127
:
642 picWindow1
.SetBlendAlpha(m_BlendType
, 0.5f
);
644 case ID_VIEW_ALPHATOGGLE
:
645 picWindow1
.ToggleAlpha();
647 case ID_VIEW_FITIMAGESINWINDOW
:
649 picWindow1
.FitImageInWindow();
650 picWindow2
.FitImageInWindow();
651 picWindow3
.FitImageInWindow();
654 case ID_VIEW_ORININALSIZE
:
656 picWindow1
.SetZoom(100, false);
657 picWindow2
.SetZoom(100, false);
658 picWindow3
.SetZoom(100, false);
659 picWindow1
.CenterImage();
660 picWindow2
.CenterImage();
661 picWindow3
.CenterImage();
666 picWindow1
.Zoom(true, false);
667 if ((!(bFitWidths
|| bFitHeights
))&&(!bOverlap
))
669 picWindow2
.Zoom(true, false);
670 picWindow3
.Zoom(true, false);
674 case ID_VIEW_ZOOMOUT
:
676 picWindow1
.Zoom(false, false);
677 if ((!(bFitWidths
|| bFitHeights
))&&(!bOverlap
))
679 picWindow2
.Zoom(false, false);
680 picWindow3
.Zoom(false, false);
684 case ID_VIEW_ARRANGEVERTICAL
:
686 bVertical
= !bVertical
;
688 GetClientRect(*this, &rect
);
692 GetWindowRect(hwndTB
, &tbRect
);
693 LONG tbHeight
= tbRect
.bottom
-tbRect
.top
-1;
694 if (selectionPaths
.size() != 3)
696 nSplitterPos
= (rect
.bottom
-rect
.top
)/2+tbHeight
;
701 nSplitterPos
= (rect
.bottom
-rect
.top
)/3+tbHeight
;
702 nSplitterPos2
= (rect
.bottom
-rect
.top
)*2/3+tbHeight
;
707 if (selectionPaths
.size() != 3)
709 nSplitterPos
= (rect
.right
-rect
.left
)/2;
714 nSplitterPos
= (rect
.right
-rect
.left
)/3;
715 nSplitterPos2
= (rect
.right
-rect
.left
)*2/3;
718 HMENU hMenu
= GetMenu(*this);
719 UINT uCheck
= MF_BYCOMMAND
;
720 uCheck
|= bVertical
? MF_CHECKED
: MF_UNCHECKED
;
721 CheckMenuItem(hMenu
, ID_VIEW_ARRANGEVERTICAL
, uCheck
);
722 // change the state of the toolbar button
724 tbi
.cbSize
= sizeof(TBBUTTONINFO
);
725 tbi
.dwMask
= TBIF_STATE
;
726 tbi
.fsState
= bVertical
? TBSTATE_CHECKED
| TBSTATE_ENABLED
: TBSTATE_ENABLED
;
727 SendMessage(hwndTB
, TB_SETBUTTONINFO
, ID_VIEW_ARRANGEVERTICAL
, (LPARAM
)&tbi
);
729 PositionChildren(&rect
);
734 CAboutDlg
dlg(*this);
735 dlg
.DoModal(hInst
, IDD_ABOUT
, *this);
738 case SELECTBUTTON_ID
:
740 HWND hSource
= (HWND
)lParam
;
741 if (picWindow1
== hSource
)
743 if (!selectionResult
.empty())
744 CopyFile(selectionPaths
[FileTypeMine
].c_str(), selectionResult
.c_str(), FALSE
);
745 PostQuitMessage(FileTypeMine
);
747 if (picWindow2
== hSource
)
749 if (!selectionResult
.empty())
750 CopyFile(selectionPaths
[FileTypeBase
].c_str(), selectionResult
.c_str(), FALSE
);
751 PostQuitMessage(FileTypeBase
);
753 if (picWindow3
== hSource
)
755 if (!selectionResult
.empty())
756 CopyFile(selectionPaths
[FileTypeTheirs
].c_str(), selectionResult
.c_str(), FALSE
);
757 PostQuitMessage(FileTypeTheirs
);
762 ::PostQuitMessage(0);
772 void CMainWindow::DrawXorBar(HDC hdc
, int x1
, int y1
, int width
, int height
)
774 static WORD _dotPatternBmp
[8] =
776 0x0055, 0x00aa, 0x0055, 0x00aa,
777 0x0055, 0x00aa, 0x0055, 0x00aa
781 HBRUSH hbr
, hbrushOld
;
783 hbm
= CreateBitmap(8, 8, 1, 1, _dotPatternBmp
);
784 hbr
= CreatePatternBrush(hbm
);
786 SetBrushOrgEx(hdc
, x1
, y1
, 0);
787 hbrushOld
= (HBRUSH
)SelectObject(hdc
, hbr
);
789 PatBlt(hdc
, x1
, y1
, width
, height
, PATINVERT
);
791 SelectObject(hdc
, hbrushOld
);
797 LRESULT
CMainWindow::Splitter_OnLButtonDown(HWND hwnd
, UINT
/*iMsg*/, WPARAM
/*wParam*/, LPARAM lParam
)
804 pt
.x
= (short)LOWORD(lParam
); // horizontal position of cursor
805 pt
.y
= (short)HIWORD(lParam
);
807 GetClientRect(hwnd
, &clientrect
);
808 GetWindowRect(hwnd
, &rect
);
810 ClientToScreen(hwnd
, &zero
);
811 OffsetRect(&clientrect
, zero
.x
-rect
.left
, zero
.y
-rect
.top
);
813 ClientToScreen(hwnd
, &pt
);
814 // find out which drag bar is used
816 if (!selectionPaths
.empty())
819 GetWindowRect(picWindow2
, &pic2Rect
);
822 if (pic2Rect
.bottom
<= pt
.y
)
827 if (pic2Rect
.right
<= pt
.x
)
832 //convert the mouse coordinates relative to the top-left of
837 //same for the window coordinates - make them relative to 0,0
838 OffsetRect(&rect
, -rect
.left
, -rect
.top
);
842 if (pt
.x
> rect
.right
-4)
846 if (pt
.y
> rect
.bottom
-4)
847 pt
.y
= rect
.bottom
-4;
853 hdc
= GetWindowDC(hwnd
);
855 DrawXorBar(hdc
, clientrect
.left
, pt
.y
+2, clientrect
.right
-clientrect
.left
-2, 4);
857 DrawXorBar(hdc
, pt
.x
+2, clientrect
.top
, 4, clientrect
.bottom
-clientrect
.top
-2);
858 ReleaseDC(hwnd
, hdc
);
866 void CMainWindow::Splitter_CaptureChanged()
871 LRESULT
CMainWindow::Splitter_OnLButtonUp(HWND hwnd
, UINT
/*iMsg*/, WPARAM
/*wParam*/, LPARAM lParam
)
878 pt
.x
= (short)LOWORD(lParam
); // horizontal position of cursor
879 pt
.y
= (short)HIWORD(lParam
);
881 if (bDragMode
== FALSE
)
884 GetClientRect(hwnd
, &clientrect
);
885 GetWindowRect(hwnd
, &rect
);
887 ClientToScreen(hwnd
, &zero
);
888 OffsetRect(&clientrect
, zero
.x
-rect
.left
, zero
.y
-rect
.top
);
890 ClientToScreen(hwnd
, &pt
);
894 OffsetRect(&rect
, -rect
.left
, -rect
.top
);
898 if (pt
.x
> rect
.right
-4)
902 if (pt
.y
> rect
.bottom
-4)
903 pt
.y
= rect
.bottom
-4;
905 hdc
= GetWindowDC(hwnd
);
907 DrawXorBar(hdc
, clientrect
.left
, oldy
+2, clientrect
.right
-clientrect
.left
-2, 4);
909 DrawXorBar(hdc
, oldx
+2, clientrect
.top
, 4, clientrect
.bottom
-clientrect
.top
-2);
910 ReleaseDC(hwnd
, hdc
);
917 //convert the splitter position back to screen coords.
918 GetWindowRect(hwnd
, &rect
);
922 //now convert into CLIENT coordinates
923 ScreenToClient(hwnd
, &pt
);
924 GetClientRect(hwnd
, &rect
);
925 #define MINWINSIZE 10
930 if (pt
.y
< (nSplitterPos
+MINWINSIZE
))
931 pt
.y
= nSplitterPos
+MINWINSIZE
;
932 nSplitterPos2
= pt
.y
;
936 if (pt
.y
> (nSplitterPos2
-MINWINSIZE
))
937 pt
.y
= nSplitterPos2
-MINWINSIZE
;
945 if (pt
.x
< (nSplitterPos
+MINWINSIZE
))
946 pt
.x
= nSplitterPos
+MINWINSIZE
;
947 nSplitterPos2
= pt
.x
;
951 if (pt
.x
> (nSplitterPos2
-MINWINSIZE
))
952 pt
.x
= nSplitterPos2
-MINWINSIZE
;
959 //position the child controls
960 PositionChildren(&rect
);
964 LRESULT
CMainWindow::Splitter_OnMouseMove(HWND hwnd
, UINT
/*iMsg*/, WPARAM wParam
, LPARAM lParam
)
972 if (bDragMode
== FALSE
)
975 pt
.x
= (short)LOWORD(lParam
); // horizontal position of cursor
976 pt
.y
= (short)HIWORD(lParam
);
978 GetClientRect(hwnd
, &clientrect
);
979 GetWindowRect(hwnd
, &rect
);
981 ClientToScreen(hwnd
, &zero
);
982 OffsetRect(&clientrect
, zero
.x
-rect
.left
, zero
.y
-rect
.top
);
984 //convert the mouse coordinates relative to the top-left of
986 ClientToScreen(hwnd
, &pt
);
990 //same for the window coordinates - make them relative to 0,0
991 OffsetRect(&rect
, -rect
.left
, -rect
.top
);
995 if (pt
.x
> rect
.right
-4)
999 if (pt
.y
> rect
.bottom
-4)
1000 pt
.y
= rect
.bottom
-4;
1002 if ((wParam
& MK_LBUTTON
) && ((bVertical
&& (pt
.y
!= oldy
)) || (!bVertical
&& (pt
.x
!= oldx
))))
1004 hdc
= GetWindowDC(hwnd
);
1008 DrawXorBar(hdc
, clientrect
.left
, oldy
+2, clientrect
.right
-clientrect
.left
-2, 4);
1009 DrawXorBar(hdc
, clientrect
.left
, pt
.y
+2, clientrect
.right
-clientrect
.left
-2, 4);
1013 DrawXorBar(hdc
, oldx
+2, clientrect
.top
, 4, clientrect
.bottom
-clientrect
.top
-2);
1014 DrawXorBar(hdc
, pt
.x
+2, clientrect
.top
, 4, clientrect
.bottom
-clientrect
.top
-2);
1017 ReleaseDC(hwnd
, hdc
);
1026 bool CMainWindow::OpenDialog()
1028 return (DialogBox(hResource
, MAKEINTRESOURCE(IDD_OPEN
), *this, (DLGPROC
)OpenDlgProc
)==IDOK
);
1031 BOOL CALLBACK
CMainWindow::OpenDlgProc(HWND hwndDlg
, UINT message
, WPARAM wParam
, LPARAM
/*lParam*/)
1037 // center on the parent window
1038 HWND hParentWnd
= ::GetParent(hwndDlg
);
1039 RECT parentrect
, childrect
, centeredrect
;
1040 GetWindowRect(hParentWnd
, &parentrect
);
1041 GetWindowRect(hwndDlg
, &childrect
);
1042 centeredrect
.left
= parentrect
.left
+ ((parentrect
.right
-parentrect
.left
-childrect
.right
+childrect
.left
)/2);
1043 centeredrect
.right
= centeredrect
.left
+ (childrect
.right
-childrect
.left
);
1044 centeredrect
.top
= parentrect
.top
+ ((parentrect
.bottom
-parentrect
.top
-childrect
.bottom
+childrect
.top
)/2);
1045 centeredrect
.bottom
= centeredrect
.top
+ (childrect
.bottom
-childrect
.top
);
1046 SetWindowPos(hwndDlg
, NULL
, centeredrect
.left
, centeredrect
.top
, centeredrect
.right
-centeredrect
.left
, centeredrect
.bottom
-centeredrect
.top
, SWP_SHOWWINDOW
);
1048 if (!leftpicpath
.empty())
1049 SetDlgItemText(hwndDlg
, IDC_LEFTIMAGE
, leftpicpath
.c_str());
1054 switch (LOWORD(wParam
))
1056 case IDC_LEFTBROWSE
:
1058 TCHAR path
[MAX_PATH
] = {0};
1059 if (AskForFile(hwndDlg
, path
))
1061 SetDlgItemText(hwndDlg
, IDC_LEFTIMAGE
, path
);
1065 case IDC_RIGHTBROWSE
:
1067 TCHAR path
[MAX_PATH
] = {0};
1068 if (AskForFile(hwndDlg
, path
))
1070 SetDlgItemText(hwndDlg
, IDC_RIGHTIMAGE
, path
);
1076 TCHAR path
[MAX_PATH
] = {0};
1077 if (!GetDlgItemText(hwndDlg
, IDC_LEFTIMAGE
, path
, _countof(path
)))
1080 if (!GetDlgItemText(hwndDlg
, IDC_RIGHTIMAGE
, path
, _countof(path
)))
1082 rightpicpath
= path
;
1086 EndDialog(hwndDlg
, wParam
);
1093 bool CMainWindow::AskForFile(HWND owner
, TCHAR
* path
)
1095 OPENFILENAME ofn
= {0}; // common dialog box structure
1096 // Initialize OPENFILENAME
1097 ofn
.lStructSize
= sizeof(OPENFILENAME
);
1098 ofn
.hwndOwner
= owner
;
1099 ofn
.lpstrFile
= path
;
1100 ofn
.nMaxFile
= MAX_PATH
;
1101 ResString
sTitle(::hResource
, IDS_OPENIMAGEFILE
);
1102 ofn
.lpstrTitle
= sTitle
;
1103 ofn
.Flags
= OFN_DONTADDTORECENT
| OFN_FILEMUSTEXIST
| OFN_EXPLORER
;
1104 ofn
.hInstance
= ::hResource
;
1105 TCHAR filters
[] = _T("Images\0*.wmf;*.jpg;*jpeg;*.bmp;*.gif;*.png;*.ico;*.dib;*.emf\0All (*.*)\0*.*\0\0");
1106 ofn
.lpstrFilter
= filters
;
1107 ofn
.nFilterIndex
= 1;
1108 // Display the Open dialog box.
1109 if (GetOpenFileName(&ofn
)==FALSE
)
1116 bool CMainWindow::CreateToolbar()
1118 // Ensure that the common control DLL is loaded.
1119 INITCOMMONCONTROLSEX icex
;
1120 icex
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1121 icex
.dwICC
= ICC_BAR_CLASSES
| ICC_WIN95_CLASSES
;
1122 InitCommonControlsEx(&icex
);
1124 hwndTB
= CreateWindowEx(0,
1127 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| TBSTYLE_FLAT
| TBSTYLE_TOOLTIPS
,
1130 (HMENU
)IDC_TORTOISEIDIFF
,
1133 if (hwndTB
== INVALID_HANDLE_VALUE
)
1136 SendMessage(hwndTB
, TB_BUTTONSTRUCTSIZE
, (WPARAM
) sizeof(TBBUTTON
), 0);
1139 // create an imagelist containing the icons for the toolbar
1140 hToolbarImgList
= ImageList_Create(24, 24, ILC_COLOR32
| ILC_MASK
, 12, 4);
1141 if (hToolbarImgList
== NULL
)
1145 if (selectionPaths
.empty())
1147 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_OVERLAP
));
1148 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1149 tbb
[index
].idCommand
= ID_VIEW_OVERLAPIMAGES
;
1150 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1151 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1152 tbb
[index
].dwData
= 0;
1153 tbb
[index
++].iString
= 0;
1155 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_BLEND
));
1156 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1157 tbb
[index
].idCommand
= ID_VIEW_BLENDALPHA
;
1158 tbb
[index
].fsState
= 0;
1159 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1160 tbb
[index
].dwData
= 0;
1161 tbb
[index
++].iString
= 0;
1163 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_LINK
));
1164 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1165 tbb
[index
].idCommand
= ID_VIEW_LINKIMAGESTOGETHER
;
1166 tbb
[index
].fsState
= TBSTATE_ENABLED
| TBSTATE_CHECKED
;
1167 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1168 tbb
[index
].dwData
= 0;
1169 tbb
[index
++].iString
= 0;
1171 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_FITWIDTHS
));
1172 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1173 tbb
[index
].idCommand
= ID_VIEW_FITIMAGEWIDTHS
;
1174 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1175 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1176 tbb
[index
].dwData
= 0;
1177 tbb
[index
++].iString
= 0;
1179 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_FITHEIGHTS
));
1180 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1181 tbb
[index
].idCommand
= ID_VIEW_FITIMAGEHEIGHTS
;
1182 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1183 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1184 tbb
[index
].dwData
= 0;
1185 tbb
[index
++].iString
= 0;
1187 tbb
[index
].iBitmap
= 0;
1188 tbb
[index
].idCommand
= 0;
1189 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1190 tbb
[index
].fsStyle
= BTNS_SEP
;
1191 tbb
[index
].dwData
= 0;
1192 tbb
[index
++].iString
= 0;
1194 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_VERTICAL
));
1195 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1196 tbb
[index
].idCommand
= ID_VIEW_ARRANGEVERTICAL
;
1197 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1198 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1199 tbb
[index
].dwData
= 0;
1200 tbb
[index
++].iString
= 0;
1202 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_FITINWINDOW
));
1203 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1204 tbb
[index
].idCommand
= ID_VIEW_FITIMAGESINWINDOW
;
1205 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1206 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1207 tbb
[index
].dwData
= 0;
1208 tbb
[index
++].iString
= 0;
1210 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_ORIGSIZE
));
1211 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1212 tbb
[index
].idCommand
= ID_VIEW_ORININALSIZE
;
1213 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1214 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1215 tbb
[index
].dwData
= 0;
1216 tbb
[index
++].iString
= 0;
1218 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_ZOOMIN
));
1219 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1220 tbb
[index
].idCommand
= ID_VIEW_ZOOMIN
;
1221 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1222 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1223 tbb
[index
].dwData
= 0;
1224 tbb
[index
++].iString
= 0;
1226 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_ZOOMOUT
));
1227 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1228 tbb
[index
].idCommand
= ID_VIEW_ZOOMOUT
;
1229 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1230 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1231 tbb
[index
].dwData
= 0;
1232 tbb
[index
++].iString
= 0;
1234 tbb
[index
].iBitmap
= 0;
1235 tbb
[index
].idCommand
= 0;
1236 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1237 tbb
[index
].fsStyle
= BTNS_SEP
;
1238 tbb
[index
].dwData
= 0;
1239 tbb
[index
++].iString
= 0;
1241 hIcon
= LoadIcon(hResource
, MAKEINTRESOURCE(IDI_IMGINFO
));
1242 tbb
[index
].iBitmap
= ImageList_AddIcon(hToolbarImgList
, hIcon
);
1243 tbb
[index
].idCommand
= ID_VIEW_IMAGEINFO
;
1244 tbb
[index
].fsState
= TBSTATE_ENABLED
;
1245 tbb
[index
].fsStyle
= BTNS_BUTTON
;
1246 tbb
[index
].dwData
= 0;
1247 tbb
[index
++].iString
= 0;
1249 SendMessage(hwndTB
, TB_SETIMAGELIST
, 0, (LPARAM
)hToolbarImgList
);
1250 SendMessage(hwndTB
, TB_ADDBUTTONS
, (WPARAM
)index
, (LPARAM
) (LPTBBUTTON
) &tbb
);
1251 SendMessage(hwndTB
, TB_AUTOSIZE
, 0, 0);
1252 ShowWindow(hwndTB
, SW_SHOW
);
1256 void CMainWindow::SetSelectionImage( FileType ft
, const std::wstring
& path
, const std::wstring
& title
)
1258 selectionPaths
[ft
] = path
;
1259 selectionTitles
[ft
] = title
;