-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBroFrame.cpp
3793 lines (3526 loc) · 98.7 KB
/
BroFrame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "stdafx.h"
#include "Sazabi.h"
#include "BroFrame.h"
#include "Sazabi.h"
#include "MainFrm.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
static UINT indicators[] =
{
ID_INDICATOR_ICON, // status icon
ID_SEPARATOR, // status line indicator
ID_INDICATOR_PROCESS, // progress bar
ID_INDICATOR_SSL,
ID_INDICATOR_COMPAT,
ID_INDICATOR_ZOOM,
};
IMPLEMENT_DYNAMIC(CBrowserFrame, CFrameWndBase)
BEGIN_MESSAGE_MAP(CBrowserFrame, CFrameWndBase)
//{{AFX_MSG_MAP(CBrowserFrame)
ON_WM_DESTROY()
ON_WM_CREATE()
ON_WM_NCCREATE()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_CLOSE()
ON_WM_ACTIVATE()
ON_WM_NCACTIVATE()
ON_WM_MOUSEACTIVATE()
ON_WM_GETMINMAXINFO()
ON_WM_SETCURSOR()
ON_COMMAND(ID_SET_ADDRESSBAR, OnSetAddressbar)
ON_COMMAND(ID_SET_SEARCHBAR, OnSetSearchbar)
//}}AFX_MSG_MAP
ON_MESSAGE(ID_MYCOMBO_OK, OnNewAddressEnter)
ON_MESSAGE(ID_MYCOMBO_SELENDOK, OnNewAddress)
ON_MESSAGE(WM_SEL_SEARCH, OnSearchString)
ON_COMMAND_RANGE(ID_FAV_START, ID_FAV_END, OnFavMenu)
ON_COMMAND_RANGE(ID_WINDOW_START, ID_WINDOW_END, OnWndMenu)
ON_COMMAND_RANGE(ID_CLOSE_WINDOW_START, ID_CLOSE_WINDOW_END, OnCloseWndMenu)
ON_COMMAND_RANGE(ID_SEL_TAB_1, ID_SEL_TAB_LAST, OnSelTab)
ON_COMMAND(ID_ADD_FAVORITE, OnFavoriteAdd)
ON_COMMAND(ID_ORGANIZE_FAVORITE, OnFavoriteOrganize)
ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset)
ON_WM_SYSCOMMAND()
ON_COMMAND(ID_INDICATOR_ICON, OnStatusBarDoubleClick)
ON_COMMAND(ID_INDICATOR_COMPAT, OnStatusBarCompatClick)
ON_COMMAND(ID_INDICATOR_ZOOM, OnStatusBarZoomClick)
//ON_COMMAND(WM_CLOSE_DELAY,OnCloseDelay)
ON_COMMAND(ID_FULL_SCREEN, OnFullScreen)
ON_COMMAND(ID_W_CLOSE, OnWClose)
ON_MESSAGE(WM_ADD_FAVORITE, OnFavoriteAddSendMsg)
ON_COMMAND(ID_PREV_WND, OnPrevWnd)
ON_COMMAND(ID_NEXT_WND, OnNextWnd)
ON_COMMAND(ID_TAB_CLOSE_LEFT, OnTabCloseLeft)
ON_COMMAND(ID_TAB_CLOSE_RIGHT, OnTabCloseRight)
ON_COMMAND(ID_RESTORE_WND, OnRestoreWnd)
ON_COMMAND(ID_SAVE_WND, OnSaveWnd)
ON_COMMAND(ID_OPEN_THIN_FILER, OpenThinFiler)
ON_COMMAND(IDC_APP_EXIT, OnAppExitEx)
ON_COMMAND(IDC_APP_EXIT_BUT_THIS, OnAppExitExBT)
ON_COMMAND(IDC_APP_DELETE_CACHE, &CBrowserFrame::OnAppDeleteCache)
ON_WM_SIZING()
ON_WM_SIZE()
ON_WM_MOVE()
ON_WM_NCLBUTTONDOWN()
ON_WM_CAPTURECHANGED()
ON_WM_ENTERSIZEMOVE()
ON_WM_EXITSIZEMOVE()
ON_MESSAGE(MYWM_TAB_WINDOW_NOTIFY, OnTabNotify)
ON_WM_ERASEBKGND()
ON_COMMAND(ID_TAB_LIST, OnTabListShow)
ON_MESSAGE(WM_POWERBROADCAST, OnPowerBroadcast)
ON_REGISTERED_MESSAGE(AFX_WM_CHANGEVISUALMANAGER, &CBrowserFrame::OnChangeVisualManager)
ON_WM_WINDOWPOSCHANGED()
ON_COMMAND(WM_ACTIVE_FRM, OnActiveFrm)
END_MESSAGE_MAP()
CBrowserFrame::CBrowserFrame()
{
m_bIME = FALSE;
m_bFullScreen = FALSE;
m_FullScreen_ShowCommand = SW_NORMAL;
m_wndTitleBar = NULL;
m_iStatusIconIndexCache_Zoom = 0;
m_pwndMenuBar = NULL;
m_pwndReBar = NULL;
m_pwndToolBar = NULL;
m_pwndAddress = NULL;
m_pwndStatusBar = NULL;
m_MenuBarCreateFlg = FALSE;
m_pwndReBarCreateFlg = FALSE;
m_pwndToolBarCreateFlg = FALSE;
m_pwndAddressCreateFlg = FALSE;
m_pwndStatusBarCreateFlg = FALSE;
m_wndpLogo = NULL;
m_wndEditSearch = NULL;
m_bMT_View = FALSE;
m_bOLEViewer = FALSE;
m_pCurrentThread = NULL;
m_pDlgMsgP = NULL;
m_bDownloadProgress = FALSE;
m_bDownloadBlankPage = FALSE;
m_bIsPopupWindow = FALSE;
m_cTabWnd = NULL;
m_RendererPID = 0;
m_nBrowserState = 0;
}
CBrowserFrame::~CBrowserFrame()
{
if (m_wndTitleBar)
{
delete m_wndTitleBar;
m_wndTitleBar = NULL;
}
if (m_pwndMenuBar)
{
delete m_pwndMenuBar;
m_pwndMenuBar = NULL;
}
if (m_pwndReBar)
{
delete m_pwndReBar;
m_pwndReBar = NULL;
}
if (m_pwndToolBar)
{
delete m_pwndToolBar;
m_pwndToolBar = NULL;
}
if (m_pwndAddress)
{
delete m_pwndAddress;
m_pwndAddress = NULL;
}
if (m_pwndStatusBar)
{
delete m_pwndStatusBar;
m_pwndStatusBar = NULL;
}
if (m_wndpLogo)
{
delete m_wndpLogo;
m_wndpLogo = NULL;
}
if (m_wndEditSearch)
{
delete m_wndEditSearch;
m_wndEditSearch = NULL;
}
if (m_pDlgMsgP)
{
delete m_pDlgMsgP;
m_pDlgMsgP = NULL;
}
if (m_cTabWnd)
{
delete m_cTabWnd;
m_cTabWnd = NULL;
}
}
BOOL CBrowserFrame::PreTranslateMessage(MSG* pMsg)
{
if (theApp.m_bTabEnable_Init)
{
if (m_cTabWnd)
{
if (pMsg->message == WM_MOUSEMOVE)
{
CPoint ptw = pMsg->pt;
//Tabウインドウにマウスカーソルが載っている
if (pMsg->hwnd == m_cTabWnd->GetHwnd() || pMsg->hwnd == m_cTabWnd->m_hwndTab)
{
//閉じるボタンが作成済み且つこのFrameの場合、カーソルの載っているタブの座標を取得
if (theApp.IsWnd(theApp.m_wndpClose) && theApp.m_wndpClose->m_pParent == this)
{
CRect rc(0, 0, 0, 0);
theApp.m_wndpClose->GetWindowRect(rc);
int iWidth = 0, iHeight = 0;
iWidth = rc.Width();
iHeight = rc.Height();
TC_HITTESTINFO kChkHit2 = {0};
kChkHit2.pt = pMsg->pt;
::ScreenToClient(m_cTabWnd->m_hwndTab, &kChkHit2.pt);
kChkHit2.flags = TCHT_ONITEM | TCHT_NOWHERE;
//閉じるボタンが作成済み且つこのFrameの場合、カーソルの載っているタブの座標を取得
LRESULT iResult2 = ::SendMessage(m_cTabWnd->m_hwndTab, TCM_HITTEST, 0, (LPARAM)&kChkHit2);
if (iResult2 > -1)
{
CRect rcOver(0, 0, 0, 0);
::SendMessage(m_cTabWnd->m_hwndTab, TCM_GETITEMRECT, iResult2, (LPARAM)&rcOver);
rcOver.InflateRect(0, -6, -2, 0);
::ClientToScreen(m_cTabWnd->m_hwndTab, (LPPOINT)&rcOver.left);
::ClientToScreen(m_cTabWnd->m_hwndTab, (LPPOINT)&rcOver.right);
ScreenToClient(rcOver);
rc.left = rcOver.right - iWidth;
rc.top = rcOver.top;
rc.right = rc.left + iWidth;
rc.bottom = rc.top + iHeight;
HWND hwndUpDown = {0};
hwndUpDown = ::FindWindowEx(m_cTabWnd->m_hwndTab, NULL, UPDOWN_CLASS, 0); // タブ内の Up-Down コントロール
if (hwndUpDown != NULL && ::IsWindowVisible(hwndUpDown))
{
CRect rcUp;
::GetWindowRect(hwndUpDown, &rcUp);
CRect rcHitTest;
if (rcHitTest.IntersectRect(rcUp, rc))
theApp.m_wndpClose->ShowWindow(SW_HIDE);
else
//閉じるボタンの位置を移動する。
theApp.m_wndpClose->MoveWnd(rc);
}
else
{
//閉じるボタンの位置を移動する。
theApp.m_wndpClose->MoveWnd(rc);
}
}
//マウスカーソルがタブに載っていないので非表示にする。
else
{
if (theApp.IsWnd(theApp.m_wndpClose))
theApp.m_wndpClose->ShowWindow(SW_HIDE);
}
}
//Tabウインドウにマウスがあるが、閉じるボタンが未生成orこのFramで作られた物ではない。
else
{
//一度も作成されたことが無い
if (NULL == theApp.m_wndpClose)
{
theApp.m_wndpClose = new CCloseNilButton();
theApp.m_wndpClose->Init(55, this, this);
}
//作成されているが、このFrameではない。
else if (theApp.m_wndpClose && theApp.m_wndpClose->m_pParent != this)
{
theApp.m_wndpClose->DestroyWindow();
delete theApp.m_wndpClose;
theApp.m_wndpClose = NULL;
theApp.m_wndpClose = new CCloseNilButton();
theApp.m_wndpClose->Init(55, this, this);
}
}
}
//タブ以外にマウスカーソルが移動した場合は、xボタンを非表示にする。
else
{
if (theApp.IsWnd(theApp.m_wndpClose))
theApp.m_wndpClose->ShowWindow(SW_HIDE);
}
////////////////////////////////////////////////////////////////////////////////////////////////
//選択されているタブに青いラインを表示する
////////////////////////////////////////////////////////////////////////////////////////////////
if (::theApp.IsWndVisible(m_cTabWnd->GetHwnd()))
{
//一度も作成されたことが無い
if (NULL == theApp.m_wndpActiveTabLine)
{
theApp.m_wndpActiveTabLine = new CActiveTabLine();
theApp.m_wndpActiveTabLine->Init(56, this, this);
}
//作成済みだが、このFrameではない。
else if (theApp.m_wndpActiveTabLine && theApp.m_wndpActiveTabLine->m_pParent != this)
{
theApp.m_wndpActiveTabLine->DestroyWindow();
delete theApp.m_wndpActiveTabLine;
theApp.m_wndpActiveTabLine = NULL;
theApp.m_wndpActiveTabLine = new CActiveTabLine();
theApp.m_wndpActiveTabLine->Init(56, this, this);
}
//タブラインが作成されているandこのFrameの場合
if (theApp.IsWnd(theApp.m_wndpActiveTabLine) && theApp.m_wndpActiveTabLine->m_pParent == this)
{
CRect rc(0, 0, 0, 0);
theApp.m_wndpActiveTabLine->GetWindowRect(rc);
int nCurSel = TabCtrl_GetCurSel(m_cTabWnd->m_hwndTab);
if (nCurSel > -1)
{
CRect rcOver(0, 0, 0, 0);
::SendMessage(m_cTabWnd->m_hwndTab, TCM_GETITEMRECT, nCurSel, (LPARAM)&rcOver);
//rcOver.InflateRect(0, -2, -2, 0);
::ClientToScreen(m_cTabWnd->m_hwndTab, (LPPOINT)&rcOver.left);
::ClientToScreen(m_cTabWnd->m_hwndTab, (LPPOINT)&rcOver.right);
ScreenToClient(rcOver);
rc.left = rcOver.left - 1; // -4;
rc.top = rcOver.top - 1; // -3;
rc.right = rcOver.right + 1; // +4;
rc.bottom = rcOver.top + 3; // +3;
//Viewにフォーカスをセットする。
if (theApp.m_wndpActiveTabLine->m_Rc != rc)
{
if (this->m_wndView)
this->m_wndView.bSetCefBrowserFocus();
}
if (m_nBrowserState & CEF_BIT_IS_LOADING)
{
rc.top -= 2;
theApp.m_wndpActiveTabLine->MoveWnd(rc);
if (!theApp.m_wndpActiveTabLine->m_bProgress)
{
theApp.m_wndpActiveTabLine->m_bProgress = TRUE;
theApp.m_wndpActiveTabLine->InvalidateRect(NULL);
}
}
else
{
theApp.m_wndpActiveTabLine->MoveWnd(rc);
if (theApp.m_wndpActiveTabLine->m_bProgress)
{
theApp.m_wndpActiveTabLine->m_bProgress = FALSE;
theApp.m_wndpActiveTabLine->InvalidateRect(NULL);
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////
//NewTabButton
//一度も作成されたことが無い
if (NULL == theApp.m_wndpNewTab)
{
theApp.m_wndpNewTab = new CNewTabButton();
theApp.m_wndpNewTab->Init(57, this, this);
}
//作成済みだが、このFrameではない。
else if (theApp.m_wndpNewTab && theApp.m_wndpNewTab->m_pParent != this)
{
theApp.m_wndpNewTab->DestroyWindow();
delete theApp.m_wndpNewTab;
theApp.m_wndpNewTab = NULL;
theApp.m_wndpNewTab = new CNewTabButton();
theApp.m_wndpNewTab->Init(57, this, this);
}
//作成されているandこのFrameの場合
if (theApp.IsWnd(theApp.m_wndpNewTab) && theApp.m_wndpNewTab->m_pParent == this)
{
CRect rc(0, 0, 0, 0);
theApp.m_wndpNewTab->GetWindowRect(rc);
int iWidth = 0, iHeight = 0;
iWidth = rc.Width();
iHeight = rc.Height();
int nCurSel = TabCtrl_GetItemCount(m_cTabWnd->m_hwndTab);
if (nCurSel > 0)
{
CRect rcOver(0, 0, 0, 0);
::SendMessage(m_cTabWnd->m_hwndTab, TCM_GETITEMRECT, nCurSel - 1, (LPARAM)&rcOver);
::ClientToScreen(m_cTabWnd->m_hwndTab, (LPPOINT)&rcOver.left);
::ClientToScreen(m_cTabWnd->m_hwndTab, (LPPOINT)&rcOver.right);
ScreenToClient(rcOver);
rc.left = rcOver.right + 3; //- iWidth;
rc.top = rcOver.top + 2;
rc.right = rc.left + iWidth;
rc.bottom = rc.top + iHeight;
HWND hwndUpDown = {0};
hwndUpDown = ::FindWindowEx(m_cTabWnd->m_hwndTab, NULL, UPDOWN_CLASS, 0); // タブ内の Up-Down コントロール
if (hwndUpDown != NULL && ::IsWindowVisible(hwndUpDown))
{
CRect rcUp;
::GetWindowRect(hwndUpDown, &rcUp);
CRect rcHitTest;
if (rcHitTest.IntersectRect(rcUp, rc))
theApp.m_wndpNewTab->ShowWindow(SW_HIDE);
else
theApp.m_wndpNewTab->MoveWnd(rc);
}
else
{
theApp.m_wndpNewTab->MoveWnd(rc);
}
}
}
}
}
else if (pMsg->message == WM_LBUTTONDOWN)
{
CPoint ptw = pMsg->pt;
if (pMsg->hwnd == m_cTabWnd->GetHwnd() || pMsg->hwnd == m_cTabWnd->m_hwndTab)
{
if (theApp.IsWnd(theApp.m_wndpClose) && theApp.m_wndpClose->m_pParent == this)
{
POINT pt = {0};
::GetCursorPos(&pt);
this->ScreenToClient(&pt);
if (theApp.m_wndpClose->m_Rc.PtInRect(pt))
{
TC_HITTESTINFO kChkHit2 = {0};
kChkHit2.pt = pMsg->pt;
::ScreenToClient(m_cTabWnd->m_hwndTab, &kChkHit2.pt);
kChkHit2.flags = TCHT_ONITEM | TCHT_NOWHERE;
LRESULT iResult2 = ::SendMessage(m_cTabWnd->m_hwndTab, TCM_HITTEST, 0, (LPARAM)&kChkHit2);
if (iResult2 > -1)
{
TCITEM item = {0};
item.mask = TCIF_PARAM;
::SendMessage(m_cTabWnd->m_hwndTab, TCM_GETITEM, iResult2, (LPARAM)&item);
HWND hCloseWnd = NULL;
hCloseWnd = (HWND)item.lParam;
if (IsWindow(hCloseWnd))
{
::PostMessage(hCloseWnd, WM_COMMAND, ID_W_CLOSE, 0);
theApp.m_wndpClose->ShowWindow(SW_HIDE);
return TRUE;
}
}
}
}
}
if (pMsg->hwnd == m_cTabWnd->GetHwnd() || pMsg->hwnd == m_cTabWnd->m_hwndTab)
{
if (theApp.IsWnd(theApp.m_wndpNewTab) && theApp.m_wndpNewTab->m_pParent == this)
{
POINT pt = {0};
::GetCursorPos(&pt);
this->ScreenToClient(&pt);
if (theApp.m_wndpNewTab->m_Rc.PtInRect(pt))
{
TC_HITTESTINFO kChkHit2 = {0};
kChkHit2.pt = pMsg->pt;
::ScreenToClient(m_cTabWnd->m_hwndTab, &kChkHit2.pt);
kChkHit2.flags = TCHT_ONITEM | TCHT_NOWHERE;
LRESULT iResult2 = ::SendMessage(m_cTabWnd->m_hwndTab, TCM_HITTEST, 0, (LPARAM)&kChkHit2);
if (iResult2 < 0)
{
::PostMessage(this->m_hWnd, WM_COMMAND, ID_NEW_BLANK, 0);
return TRUE;
}
}
}
}
CPoint ptSpinTab = pMsg->pt;
if (::IsChild(m_cTabWnd->m_hwndTab, pMsg->hwnd))
{
HWND hwndUpDown = {0};
DWORD nScrollPos = {0};
hwndUpDown = ::FindWindowEx(m_cTabWnd->m_hwndTab, NULL, UPDOWN_CLASS, 0); // タブ内の Up-Down コントロール
if (hwndUpDown != NULL && ::IsWindowVisible(hwndUpDown))
{
nScrollPos = LOWORD(UpDown_GetPos(hwndUpDown));
// 現在位置 nScrollPos と画面表示とを一致させる
((CMainFrame*)theApp.m_pMainWnd)->Tab_HScrollSync(this->GetSafeHwnd(), SB_THUMBPOSITION, nScrollPos, NULL);
}
}
}
}
}
return CFrameWndEx::PreTranslateMessage(pMsg);
}
BOOL CBrowserFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnNcCreate(lpCreateStruct) == -1)
return FALSE;
return TRUE;
}
int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
PROC_TIME(OnCreate)
//Tabあり
if (theApp.m_bTabEnable_Init)
{
WINDOWPLACEMENT zFramePlacement = {0};
zFramePlacement = theApp.GetActiveFrameWindowPlacement(); //m_ActiveFramePlacement;
if (zFramePlacement.rcNormalPosition.bottom > 0)
{
CRect rcNormal(zFramePlacement.rcNormalPosition);
if (zFramePlacement.showCmd == SW_MAXIMIZE)
{
CRect rcDesktop;
CWnd* pView = NULL;
HWND hWnd = {0};
pView = (CWnd*)theApp.GetActiveViewPtr();
if (theApp.IsWnd(pView))
{
hWnd = pView->m_hWnd;
}
if (hWnd == NULL)
hWnd = ::GetDesktopWindow();
SBUtil::GetMonitorWorkRect(hWnd, &rcDesktop);
if (theApp.m_iWinOSVersion >= 100)
{
CRect rectAdj;
rcDesktop.left -= 7;
rcDesktop.right += 7;
rcDesktop.bottom += 7;
}
lpCreateStruct->x = rcDesktop.left;
lpCreateStruct->y = rcDesktop.top;
lpCreateStruct->cx = rcDesktop.Width();
lpCreateStruct->cy = rcDesktop.Height();
}
else if (zFramePlacement.showCmd == SW_NORMAL)
{
lpCreateStruct->x = rcNormal.left;
lpCreateStruct->y = rcNormal.top;
lpCreateStruct->cx = rcNormal.Width();
lpCreateStruct->cy = rcNormal.Height();
}
}
}
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
CFrameImpl::AddFrame(this);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAppendMenu;
pSysMenu->AppendMenu(MF_SEPARATOR);
strAppendMenu.Format(_T("About %s ..."), (LPCTSTR)theApp.m_strThisAppName);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAppendMenu);
if (theApp.InVirtualEnvironment() != VE_NA && theApp.IsSGMode())
{
strAppendMenu = _T("Open Task Manager");
pSysMenu->AppendMenu(MF_STRING, IDM_TASK_MGR, strAppendMenu);
}
strAppendMenu = _T("Close All Window");
pSysMenu->AppendMenu(MF_STRING, IDM_APP_EXIT, strAppendMenu);
}
this->SetWindowText(theApp.m_strThisAppName);
this->CreateView();
return 0;
}
void CBrowserFrame::CreateView()
{
PROC_TIME(CreateView)
CRect rect;
GetClientRect(rect);
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
rect, this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return;
}
//popup
if (m_bIsPopupWindow)
{
//Addressbarのみ必要 Chromium準拠
CreateRebarsPopup();
//Statusbarは不要
return;
}
//normal
else
{
if (theApp.m_bTabEnable_Init)
{
if (m_bOLEViewer)
return;
if (!m_cTabWnd)
m_cTabWnd = new CTabWnd;
m_cTabWnd->CreateTab(theApp.m_hInstance, this, &m_wndView, m_wndView.GetSafeHwnd());
HWND my_hwnd = this->m_hWnd;
BOOL disable = TRUE;
DwmSetWindowAttribute(my_hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &disable, sizeof disable);
m_FaviconCB.SetFramePtr(this);
}
}
CreateRebars();
CreateStatusbar();
}
void CBrowserFrame::CreateRebarsPopup()
{
PROC_TIME(CreateRebarsPopup)
CMenu* pMenu = NULL;
pMenu = this->GetMenu();
if (pMenu)
pMenu->DestroyMenu();
SetMenu(NULL);
PROC_TIME_S(CreateRebars_ADDRESSBAR)
if (theApp.m_AppSettings.IsRebar())
{
if (m_pwndAddress == NULL)
m_pwndAddress = new CMyComboBoxEx;
}
if (m_pwndAddress)
{
if (!m_pwndAddressCreateFlg)
{
// create a combo box for the address bar
if (!m_pwndAddress->Create(CBS_DROPDOWN | WS_CHILD | CBS_AUTOHSCROLL, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 3))
{
return; // fail to create
}
m_pwndAddressCreateFlg = TRUE;
m_pwndAddress->SetImageList(&theApp.m_imgMenuIcons);
if (m_pwndAddress)
{
COMBOBOXEXITEM cbi = {0};
cbi.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
cbi.iItem = -1;
cbi.iImage = (int)SBUtil::ICON_INDEX::IE_FILE_FAV;
cbi.iSelectedImage = (int)SBUtil::ICON_INDEX::IE_FILE_FAV;
m_pwndAddress->SetItem(&cbi);
}
}
}
PROC_TIME_E(CreateRebars_ADDRESSBAR)
//--------------
// Create rebar:
//--------------
PROC_TIME_S(CreateRebars_REBAR)
CString strAddressText;
strAddressText.LoadString(IDS_STRING_FRM1);
if (theApp.m_AppSettings.IsRebar())
{
if (m_pwndReBar == NULL)
{
PROC_TIME_S(CreateRebars_REBAR_NEW)
m_pwndReBar = new CMyReBar;
m_pwndReBar->m_bMultiThreaded = TRUE;
PROC_TIME_E(CreateRebars_REBAR_NEW)
}
}
if (m_pwndReBar)
{
if (!m_pwndReBarCreateFlg)
{
PROC_TIME_S(CreateRebars_REBAR_Create)
if (!m_pwndReBar->Create(this, 0))
{
TRACE0("Failed to create rebar\n");
return; // fail to create
}
m_pwndReBarCreateFlg = TRUE;
PROC_TIME_E(CreateRebars_REBAR_Create)
PROC_TIME_S(CreateRebars_REBAR_AddBar_Address)
if (m_pwndAddress)
m_pwndReBar->AddBar(m_pwndAddress, strAddressText, NULL,
RBBS_NOGRIPPER | RBBS_BREAK);
PROC_TIME_E(CreateRebars_REBAR_AddBar_Address)
EnableDocking(CBRS_ALIGN_TOP);
m_pwndReBar->EnableDocking(CBRS_TOP);
DockPane(m_pwndReBar);
}
}
PROC_TIME_E(CreateRebars_REBAR)
}
void CBrowserFrame::CreateRebars()
{
PROC_TIME(CreateRebars)
PROC_TIME_S(CreateRebars_MENUBAR)
if (m_pwndMenuBar == NULL)
m_pwndMenuBar = new CMyMenuBar;
if (m_pwndMenuBar)
{
if (!m_MenuBarCreateFlg)
{
if (!m_pwndMenuBar->Create(this))
{
TRACE0("Failed to create menubar\n");
return; // fail to create
}
m_MenuBarCreateFlg = TRUE;
if (theApp.m_AppSettings.IsRebar())
{
m_pwndMenuBar->SetPaneStyle(m_pwndMenuBar->GetPaneStyle() | CBRS_SIZE_DYNAMIC);
//---------------------------------
// Set toolbar and menu image size:
//---------------------------------
m_pwndMenuBar->SetSizes(CSize(36, 30), CSize(23, 23));
m_pwndMenuBar->SetMenuSizes(CSize(22, 22), CSize(16, 16));
}
}
if (theApp.m_AppSettings.IsRebar())
{
CMFCPopupMenu::SetForceMenuFocus(FALSE);
EnableDocking(CBRS_ALIGN_TOP);
DockPane(m_pwndMenuBar);
//------------------------------------
// Remove menubar gripper and borders:
//------------------------------------
m_pwndMenuBar->SetPaneStyle(m_pwndMenuBar->GetPaneStyle() &
~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
}
else
{
m_pwndMenuBar->ShowPane(FALSE, 0, FALSE);
}
}
PROC_TIME_E(CreateRebars_MENUBAR)
PROC_TIME_S(CreateRebars_TOOLBAR)
double dSizeX = 0.0;
double dSizeY = 0.0;
int iSizeX = 0;
int iSizeY = 0;
dSizeX = 28 * theApp.m_ScaleDPI;
dSizeY = 28 * theApp.m_ScaleDPI;
iSizeX = (int)dSizeX;
iSizeY = (int)dSizeY;
CClientDC dc(this);
BOOL bIsHighColor = dc.GetDeviceCaps(BITSPIXEL) > 8;
UINT uiToolbarHotID = bIsHighColor ? IDB_HOTTOOLBAR : 0;
UINT uiToolbarColdID = bIsHighColor ? IDB_COLDTOOLBAR : 0;
UINT uiMenuID = 0;
if (theApp.m_AppSettings.IsRebar())
{
if (m_pwndToolBar == NULL)
{
PROC_TIME_S(CreateRebars_TOOLBAR_NEW)
m_pwndToolBar = new CMyToolBar;
PROC_TIME_E(CreateRebars_TOOLBAR_NEW)
}
}
if (m_pwndToolBar)
{
if (!m_pwndToolBarCreateFlg)
{
PROC_TIME_S(CreateRebars_TOOLBAR_Create)
DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_SIZE_FIXED | CBRS_HIDE_INPLACE;
if (!m_pwndToolBar->Create(this, dwStyle, AFX_IDW_TOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return; // fail to create
}
PROC_TIME_E(CreateRebars_TOOLBAR_Create)
/////////////////////////////////////////////////////////////////////
PROC_TIME_S(CreateRebars_TOOLBAR_LoadToolBar)
PROC_TIME_S(CreateRebars_TOOLBAR_LoadToolBar_STAGE1)
if (!m_pwndToolBar->LoadToolBar(IDR_MAINFRAME, uiToolbarColdID, uiMenuID, FALSE /* Not locked */, 0, 0, uiToolbarHotID))
{
TRACE0("Failed to create toolbar\n");
return; // fail to create
}
if (theApp.m_ScaleDPI > 1)
m_pwndToolBar->SetSizes(CSize(iSizeX, iSizeY), CSize(23, 23));
m_pwndToolBar->m_bDontScaleImages = TRUE;
m_pwndToolBar->m_bMultiThreaded = TRUE;
PROC_TIME_E(CreateRebars_TOOLBAR_LoadToolBar_STAGE1)
PROC_TIME_S(CreateRebars_TOOLBAR_LoadToolBar_STAGE2)
int iSearchIndex = 0;
iSearchIndex = m_pwndToolBar->GetCount();
iSearchIndex -= 1;
if (iSearchIndex > 0)
{
// セパレータの幅を設定
m_pwndToolBar->SetButtonInfo(iSearchIndex, IDC_EDIT_SEARCH, TBBS_SEPARATOR, 500);
PROC_TIME_E(CreateRebars_TOOLBAR_LoadToolBar_STAGE2)
//ツールバーのセパレータ上にエディットボックスを載せる
PROC_TIME_S(CreateRebars_TOOLBAR_LoadToolBar_STAGE3)
CRect rect;
m_pwndToolBar->GetItemRect(iSearchIndex, &rect);
rect.DeflateRect(1, 2);
if (!m_wndEditSearch)
m_wndEditSearch = new CIconEdit;
m_wndEditSearch->m_pParentWnd = this;
if (!m_wndEditSearch->CreateEx(
WS_EX_CLIENTEDGE, _T("EDIT"), _T(""),
WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ES_MULTILINE,
rect,
m_pwndToolBar,
IDC_EDIT_SEARCH))
{
TRACE0("Failed to create edit-box\n");
return;
}
m_wndEditSearch->SetIcon(theApp.m_imgMenuIcons.ExtractIcon((int)SBUtil::ICON_INDEX::FIND_PAGE));
}
PROC_TIME_E(CreateRebars_TOOLBAR_LoadToolBar_STAGE3)
PROC_TIME_E(CreateRebars_TOOLBAR_LoadToolBar)
m_pwndToolBarCreateFlg = TRUE;
m_pwndToolBar->SetWindowText(_T("Standard"));
m_pwndToolBar->SetBorders();
//------------------------------------
// Remove toolbar gripper and borders:
//------------------------------------
m_pwndToolBar->SetPaneStyle(m_pwndToolBar->GetPaneStyle() &
~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
}
}
PROC_TIME_E(CreateRebars_TOOLBAR)
PROC_TIME_S(CreateRebars_ADDRESSBAR)
if (theApp.m_AppSettings.IsRebar())
{
if (m_pwndAddress == NULL)
m_pwndAddress = new CMyComboBoxEx;
}
if (m_pwndAddress)
{
if (!m_pwndAddressCreateFlg)
{
// create a combo box for the address bar
if (!m_pwndAddress->Create(CBS_DROPDOWN | WS_CHILD | CBS_AUTOHSCROLL, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 3))
{
return; // fail to create
}
m_pwndAddressCreateFlg = TRUE;
m_pwndAddress->SetImageList(&theApp.m_imgMenuIcons);
if (m_pwndAddress)
{
COMBOBOXEXITEM cbi = {0};
cbi.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
cbi.iItem = -1;
cbi.iImage = (int)SBUtil::ICON_INDEX::IE_FILE_FAV;
cbi.iSelectedImage = (int)SBUtil::ICON_INDEX::IE_FILE_FAV;
m_pwndAddress->SetItem(&cbi);
}
}
}
PROC_TIME_E(CreateRebars_ADDRESSBAR)
//--------------
// Create rebar:
//--------------
PROC_TIME_S(CreateRebars_REBAR)
CString strAddressText;
strAddressText.LoadString(IDS_STRING_FRM1);
if (theApp.m_AppSettings.IsRebar())
{
if (m_pwndReBar == NULL)
{
PROC_TIME_S(CreateRebars_REBAR_NEW)
m_pwndReBar = new CMyReBar;
m_pwndReBar->m_bMultiThreaded = TRUE;
PROC_TIME_E(CreateRebars_REBAR_NEW)
}
}
if (m_pwndReBar)
{
if (!m_pwndReBarCreateFlg)
{
PROC_TIME_S(CreateRebars_REBAR_Create)
if (!m_pwndReBar->Create(this, 0))
{
TRACE0("Failed to create rebar\n");
return; // fail to create
}
m_pwndReBarCreateFlg = TRUE;
PROC_TIME_E(CreateRebars_REBAR_Create)
PROC_TIME_S(CreateRebars_REBAR_AddBar_ToolBar)
if (m_pwndToolBar)
{
m_pwndReBar->AddBar(m_pwndToolBar, NULL, NULL,
RBBS_NOGRIPPER | RBBS_BREAK);
}
PROC_TIME_E(CreateRebars_REBAR_AddBar_ToolBar)
PROC_TIME_S(CreateRebars_REBAR_AddBar_Address)
if (m_pwndAddress)
m_pwndReBar->AddBar(m_pwndAddress, strAddressText, NULL,
RBBS_NOGRIPPER | RBBS_BREAK);
PROC_TIME_E(CreateRebars_REBAR_AddBar_Address)
if (m_pwndToolBar)
{
EnableDocking(CBRS_ALIGN_TOP);
m_pwndReBar->EnableDocking(CBRS_TOP);
DockPane(m_pwndReBar);
if (theApp.m_AppSettings.IsShowLogo())
{
m_wndpLogo = new CNilButton;
if (!m_wndpLogo->Init(53, m_pwndToolBar, this))
{
if (m_wndpLogo)
{
delete m_wndpLogo;
m_wndpLogo = NULL;
}
}
}
}
if (theApp.m_bTabEnable_Init)
{
if (!m_pwndReBar)
{
if (!theApp.m_AppSettings.IsRebar())
{
if (m_pwndReBar == NULL)
{
m_pwndReBar = new CMyReBar;
m_pwndReBar->m_bMultiThreaded = TRUE;
if (!m_pwndReBar->Create(this))
{
TRACE0("Failed to create rebar\n");
return; // fail to create
}
m_pwndReBarCreateFlg = TRUE;
EnableDocking(CBRS_ALIGN_TOP);
m_pwndReBar->EnableDocking(CBRS_TOP);
DockPane(m_pwndReBar);
}
}
}
if (m_cTabWnd)
{
m_pwndReBar->AddBar(CWnd::FromHandle(m_cTabWnd->GetHwnd()), NULL, NULL,
RBBS_NOGRIPPER | RBBS_BREAK);
}
}
}
}
else
{
// Even though IsRebar option is disabled (EnableRebar=0), create rebar as a
// container for only packing cTabWnd purpose.
// It fixes the issue (When rebar is disabled, the top of website content
// in tab is hidden unexpectedly, in other words,
// the content rendering is clipped and can't access hidden parts)
if (m_cTabWnd)
{
PROC_TIME_S(CreateRebars_REBAR_NEW_AsContainer)
m_pwndReBar = new CMyReBar;
m_pwndReBar->m_bMultiThreaded = TRUE;
PROC_TIME_E(CreateRebars_REBAR_NEW_AsContainer)
PROC_TIME_S(CreateRebars_REBAR_CreateFlgForContainer)
if (!m_pwndReBar->Create(this, 0))
{
TRACE0("Failed to create rebar as a container of tab\n");
return;
}
m_pwndReBarCreateFlg = TRUE;
PROC_TIME_E(CreateRebars_REBAR_CreateFlgForContainer)
EnableDocking(CBRS_ALIGN_TOP);
m_pwndReBar->EnableDocking(CBRS_TOP);
DockPane(m_pwndReBar);
m_pwndReBar->AddBar(CWnd::FromHandle(m_cTabWnd->GetHwnd()), NULL, NULL,
RBBS_NOGRIPPER | RBBS_BREAK);
}
}
PROC_TIME_E(CreateRebars_REBAR)
}
void CBrowserFrame::CreateStatusbar()
{
PROC_TIME(CreateStatusbar)
//-------------------
// Create status bar:
//-------------------
if (theApp.m_AppSettings.IsStatusbar())
{
if (m_pwndStatusBar == NULL)
m_pwndStatusBar = new CMyStatusBar;
}
if (!m_pwndStatusBar)
return;
if (m_pwndStatusBarCreateFlg)
return;
else
{
if (!m_pwndStatusBar->Create(this))
{
TRACE0("Failed to create status bar\n");
return; // fail to create