3 static const TCHAR szMainWndClass
[] = TEXT("ImageSoftWndClass");
5 #define ID_MDI_FIRSTCHILD 50000
6 #define ID_MDI_WINDOWMENU 5
10 TBBUTTON StdButtons
[] = {
11 /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
12 {TBICON_NEW
, ID_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0}, /* new */
13 {TBICON_OPEN
, ID_OPEN
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0}, /* open */
14 {TBICON_SAVE
, ID_SAVE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0}, /* save */
16 {10, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
18 {TBICON_PRINT
, ID_PRINTPRE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* print */
19 {TBICON_PRINTPRE
, ID_PRINT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* print preview */
21 {10, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
23 {TBICON_CUT
, ID_CUT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* cut */
24 {TBICON_COPY
, ID_COPY
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* copy */
25 {TBICON_PASTE
, ID_PASTE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* paste */
27 {10, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
29 {TBICON_UNDO
, ID_UNDO
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* undo */
30 {TBICON_REDO
, ID_REDO
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* redo */
32 {10, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0},
35 TBBUTTON TextButtons
[] = {
36 {10, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
38 {TBICON_BOLD
, ID_BOLD
, TBSTATE_ENABLED
, BTNS_BUTTON
| TBSTYLE_CHECK
, {0}, 0, 0}, /* bold */
39 {TBICON_ITALIC
, ID_ITALIC
, TBSTATE_ENABLED
, BTNS_BUTTON
| TBSTYLE_CHECK
, {0}, 0, 0}, /* italic */
40 {TBICON_ULINE
, ID_ULINE
, TBSTATE_ENABLED
, BTNS_BUTTON
| TBSTYLE_CHECK
, {0}, 0, 0}, /* underline */
42 {10, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
44 {TBICON_TXTLEFT
, ID_TXTLEFT
, TBSTATE_ENABLED
| TBSTATE_CHECKED
, BTNS_BUTTON
| TBSTYLE_GROUP
| TBSTYLE_CHECK
, {0}, 0, 0 }, /* left justified */
45 {TBICON_TXTCENTER
,ID_TXTCENTER
,TBSTATE_ENABLED
, BTNS_BUTTON
| TBSTYLE_GROUP
| TBSTYLE_CHECK
, {0}, 0, 0 }, /* centered */
46 {TBICON_TXTRIGHT
, ID_TXTRIGHT
, TBSTATE_ENABLED
, BTNS_BUTTON
| TBSTYLE_GROUP
| TBSTYLE_CHECK
, {0}, 0, 0 }, /* right justified */
48 {10, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
54 static const MENU_HINT MainMenuHintTable
[] = {
56 {ID_BLANK
, IDS_HINT_BLANK
},
57 {ID_NEW
, IDS_HINT_NEW
},
58 {ID_OPEN
, IDS_HINT_OPEN
},
59 {ID_CLOSE
, IDS_HINT_CLOSE
},
60 {ID_CLOSEALL
, IDS_HINT_CLOSEALL
},
61 {ID_SAVE
, IDS_HINT_SAVE
},
62 {ID_SAVEAS
, IDS_HINT_SAVEAS
},
63 {ID_PRINTPRE
, IDS_HINT_PRINTPRE
},
64 {ID_PRINT
, IDS_HINT_PRINT
},
65 {ID_PROP
, IDS_HINT_PROP
},
66 {ID_EXIT
, IDS_HINT_EXIT
},
69 {ID_TOOLS
, IDS_HINT_TOOLS
},
70 {ID_COLOR
, IDS_HINT_COLORS
},
71 {ID_HISTORY
, IDS_HINT_HISTORY
},
72 {ID_STATUSBAR
, IDS_HINT_STATUS
},
75 {ID_WINDOW_NEXT
, IDS_HINT_NEXT
},
76 {ID_WINDOW_CASCADE
, IDS_HINT_CASCADE
},
77 {ID_WINDOW_TILE_HORZ
, IDS_HINT_TILE_HORZ
},
78 {ID_WINDOW_TILE_VERT
, IDS_HINT_TILE_VERT
},
79 {ID_WINDOW_ARRANGE
, IDS_HINT_ARRANGE
}
82 static const MENU_HINT SystemMenuHintTable
[] = {
83 {SC_RESTORE
, IDS_HINT_SYS_RESTORE
},
84 {SC_MOVE
, IDS_HINT_SYS_MOVE
},
85 {SC_SIZE
, IDS_HINT_SYS_SIZE
},
86 {SC_MINIMIZE
, IDS_HINT_SYS_MINIMIZE
},
87 {SC_MAXIMIZE
, IDS_HINT_SYS_MAXIMIZE
},
88 {SC_CLOSE
, IDS_HINT_CLOSE
},
89 {SC_NEXTWINDOW
, IDS_HINT_NEXT
},
94 #define ID_TOOLBAR_STANDARD 0
95 #define ID_TOOLBAR_TEXT 1
96 static const TCHAR szToolbarStandard
[] = TEXT("STANDARD");
97 static const TCHAR szToolbarText
[] = TEXT("TEXT");
101 #define ID_TOOLBAR_TEST 5
102 static const TCHAR szToolbarTest
[] = TEXT("TEST");
105 static const DOCKBAR MainDockBars
[] = {
106 {ID_TOOLBAR_STANDARD
, szToolbarStandard
, IDS_TOOLBAR_STANDARD
, TOP_DOCK
},
107 {ID_TOOLBAR_TEST
, szToolbarTest
, IDS_TOOLBAR_TEST
, TOP_DOCK
},
108 {ID_TOOLBAR_TEXT
, szToolbarText
, IDS_TOOLBAR_TEXT
, TOP_DOCK
},
113 MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS
*TbDocks
,
114 const DOCKBAR
*Dockbar
,
119 const TBBUTTON
*Buttons
= NULL
;
121 UINT StartImageRes
= 0;
122 HWND hWndClient
= NULL
;
124 UNREFERENCED_PARAMETER(Context
);
126 switch (Dockbar
->BarId
)
128 case ID_TOOLBAR_STANDARD
:
130 Buttons
= StdButtons
;
131 NumButtons
= sizeof(StdButtons
) / sizeof(StdButtons
[0]);
132 StartImageRes
= IDB_MAINNEWICON
;
136 case ID_TOOLBAR_TEXT
:
138 Buttons
= TextButtons
;
139 NumButtons
= sizeof(TextButtons
) / sizeof(TextButtons
[0]);
140 StartImageRes
= IDB_TEXTBOLD
;
144 case ID_TOOLBAR_TEST
:
146 hWndClient = CreateWindowEx(WS_EX_TOOLWINDOW,
149 WS_CHILD | WS_VISIBLE,
164 hWndClient
= CreateWindowEx(0,
167 WS_CHILD
| WS_CLIPSIBLINGS
|
168 CCS_NOPARENTALIGN
| CCS_NOMOVEY
| CCS_NORESIZE
| CCS_NODIVIDER
|
169 TBSTYLE_FLAT
| TBSTYLE_TOOLTIPS
,
178 if (hWndClient
!= NULL
)
180 HIMAGELIST hImageList
;
182 SendMessage(hWndClient
,
185 TBSTYLE_EX_HIDECLIPPEDBUTTONS
);
187 SendMessage(hWndClient
,
192 SendMessage(hWndClient
,
195 (LPARAM
)MAKELONG(TB_BMP_WIDTH
, TB_BMP_HEIGHT
));
197 hImageList
= InitImageList(NumButtons
,
200 ImageList_Destroy((HIMAGELIST
)SendMessage(hWndClient
,
203 (LPARAM
)hImageList
));
205 SendMessage(hWndClient
,
213 switch (Dockbar
->BarId
)
215 case ID_TOOLBAR_TEXT
:
220 /* font selection combo */
221 hFontType
= CreateWindowEx(0,
224 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
|
225 CBS_DROPDOWN
| CBS_SORT
| CBS_HASSTRINGS
, //| CBS_OWNERDRAWFIXED,
232 if (hFontType
!= NULL
)
234 MakeFlatCombo(hFontType
);
239 if (!ToolbarInsertSpaceForControl(hWndClient
,
245 DestroyWindow(hFontType
);
248 /* Create the list of fonts */
249 FillFontStyleComboList(hFontType
);
252 /* font size combo */
253 hFontSize
= CreateWindowEx(0,
256 WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWN
,
262 if (hFontSize
!= NULL
)
264 MakeFlatCombo(hFontSize
);
269 if (!ToolbarInsertSpaceForControl(hWndClient
,
275 DestroyWindow(hFontSize
);
278 /* Update the font-size-list */
279 FillFontSizeComboList(hFontSize
);
285 if (hWndClient
!= NULL
)
295 MainWndDestroyToolbarClient(struct _TOOLBAR_DOCKS
*TbDocks
,
296 const DOCKBAR
*Dockbar
,
300 UNREFERENCED_PARAMETER(TbDocks
);
301 UNREFERENCED_PARAMETER(Dockbar
);
302 UNREFERENCED_PARAMETER(Context
);
309 MainWndToolbarInsertBand(struct _TOOLBAR_DOCKS
*TbDocks
,
310 const DOCKBAR
*Dockbar
,
317 case ID_TOOLBAR_TEXT
:
318 case ID_TOOLBAR_STANDARD
:
322 if (SendMessage(rbi
->hwndChild
,
327 rbi
->fStyle
|= RBBS_USECHEVRON
| RBBS_HIDETITLE
;
328 rbi
->fMask
|= RBBIM_SIZE
| RBBIM_CHILDSIZE
| RBBIM_IDEALSIZE
;
329 rbi
->cx
= rbi
->cxIdeal
= Size
.cx
;
331 rbi
->cyMinChild
= Size
.cy
;
336 case ID_TOOLBAR_TEST
:
340 if (GetWindowRect(rbi
->hwndChild
,
343 rbi
->fStyle
|= RBBS_HIDETITLE
;
344 rbi
->fMask
|= RBBIM_SIZE
| RBBIM_CHILDSIZE
;
345 rbi
->cx
= rcBtn
.right
- rcBtn
.left
;
347 rbi
->cyMinChild
= rcBtn
.bottom
- rcBtn
.top
;
356 TbCustomControlChange(HWND hWndToolbar
,
360 /* the toolbar changed from horizontal to vertical or vice versa... */
365 MainWndToolbarDockBand(struct _TOOLBAR_DOCKS
*TbDocks
,
366 const DOCKBAR
*Dockbar
,
368 DOCK_POSITION DockFrom
,
369 DOCK_POSITION DockTo
,
372 if (rbi
->fMask
& RBBIM_CHILD
&& rbi
->hwndChild
!= NULL
)
376 case ID_TOOLBAR_TEXT
:
377 case ID_TOOLBAR_STANDARD
:
381 DWORD dwStyle
= (DWORD
)SendMessage(rbi
->hwndChild
,
389 dwStyle
|= CCS_VERT
| TBSTYLE_WRAPABLE
;
394 dwStyle
&= ~(CCS_VERT
| TBSTYLE_WRAPABLE
);
399 SendMessage(rbi
->hwndChild
,
404 ToolbarUpdateControlSpaces(rbi
->hwndChild
,
405 TbCustomControlChange
);
407 if (SendMessage(rbi
->hwndChild
,
412 rbi
->fMask
|= RBBIM_SIZE
| RBBIM_CHILDSIZE
| RBBIM_IDEALSIZE
;
413 rbi
->cx
= rbi
->cxIdeal
= (Vert
? Size
.cy
: Size
.cx
);
415 rbi
->cyMinChild
= (Vert
? Size
.cx
: Size
.cy
);
420 case ID_TOOLBAR_TEST
:
422 if (DockTo
== NO_DOCK
)
424 rbi
->fMask
|= RBBIM_SIZE
| RBBIM_CHILDSIZE
| RBBIM_IDEALSIZE
;
425 rbi
->cx
= rbi
->cxIdeal
= 150;
427 rbi
->cyMinChild
= 40;
436 MainWndToolbarChevronPushed(struct _TOOLBAR_DOCKS
*TbDocks
,
437 const DOCKBAR
*Dockbar
,
440 LPNMREBARCHEVRON lpnm
)
444 case ID_TOOLBAR_STANDARD
:
446 MapWindowPoints(lpnm
->hdr
.hwndFrom
,
450 /* Create a popup menu for all toolbar icons hidden */
457 MainWndMoveFloatingWindows(PMAIN_WND_INFO Info
,
460 RECT wndNewPos
, TbRect
;
461 INT i
, xMoved
, yMoved
;
462 PFLT_WND WndArr
[NUM_FLT_WND
];
464 if (GetWindowRect(Info
->hSelf
,
468 xMoved
= wndNewPos
.left
- wndOldPos
->left
;
469 yMoved
= wndNewPos
.top
- wndOldPos
->top
;
471 /* store the pointers in an array */
472 WndArr
[0] = Info
->fltTools
;
473 WndArr
[1] = Info
->fltColors
;
474 WndArr
[2] = Info
->fltHistory
;
476 for (i
= 0; i
< NUM_FLT_WND
; i
++)
478 GetWindowRect(WndArr
[i
]->hSelf
,
481 WndArr
[i
]->x
= TbRect
.left
+ xMoved
;
482 WndArr
[i
]->y
= TbRect
.top
+ yMoved
;
484 MoveWindow(WndArr
[i
]->hSelf
,
492 CopyMemory(wndOldPos
,
500 MainWndResetFloatingWindows(PMAIN_WND_INFO Info
)
504 if (GetWindowRect(Info
->hMdiClient
,
509 MoveWindow(Info
->fltTools
->hSelf
,
512 Info
->fltTools
->Width
,
513 Info
->fltTools
->Height
,
517 MoveWindow(Info
->fltColors
->hSelf
,
519 rect
.bottom
- Info
->fltColors
->Height
- 5,
520 Info
->fltColors
->Width
,
521 Info
->fltColors
->Height
,
525 MoveWindow(Info
->fltHistory
->hSelf
,
526 rect
.right
- Info
->fltHistory
->Width
- 5,
528 Info
->fltHistory
->Width
,
529 Info
->fltHistory
->Height
,
535 MainWndCreateFloatWindows(PMAIN_WND_INFO Info
)
540 PFLT_WND WndArr
[NUM_FLT_WND
]; /* temp array for looping */
543 Info
->fltTools
= HeapAlloc(ProcessHeap
,
546 Info
->fltColors
= HeapAlloc(ProcessHeap
,
549 Info
->fltHistory
= HeapAlloc(ProcessHeap
,
553 /* set window dimensions */
554 Info
->fltTools
->Width
= 53;
555 Info
->fltTools
->Height
= 300;
556 Info
->fltColors
->Width
= 200;
557 Info
->fltColors
->Height
= 200;
558 Info
->fltHistory
->Width
= 150;
559 Info
->fltHistory
->Height
= 150;
561 if (! GetWindowRect(Info
->hMdiClient
,
567 /* Set window datums */
568 Info
->fltTools
->x
= rect
.left
+ 5;
569 Info
->fltTools
->y
= rect
.top
+ 5;
571 Info
->fltColors
->x
= rect
.left
+ 5;
572 Info
->fltColors
->y
= rect
.bottom
- Info
->fltColors
->Height
- 5;
574 Info
->fltHistory
->x
= rect
.right
- Info
->fltHistory
->Width
- 5;
575 Info
->fltHistory
->y
= rect
.top
+ 5;
577 /* save pointers into array incrementing within the loop*/
578 WndArr
[0] = Info
->fltTools
;
579 WndArr
[1] = Info
->fltColors
;
580 WndArr
[2] = Info
->fltHistory
;
582 for (i
= 0, Res
= IDS_FLT_TOOLS
; Res
< IDS_FLT_TOOLS
+ NUM_FLT_WND
; Res
++, i
++)
584 if (! AllocAndLoadString(&WndArr
[i
]->lpName
,
588 WndArr
[i
]->lpName
= NULL
;
591 WndArr
[i
]->hSelf
= CreateWindowEx(WS_EX_TOOLWINDOW
,
592 TEXT("ImageSoftFloatWndClass"),
594 WS_POPUPWINDOW
| WS_DLGFRAME
| WS_VISIBLE
,
603 ShowWindow(WndArr
[i
]->hSelf
, SW_HIDE
);
606 hMenu
= GetMenu(Info
->hSelf
);
608 if (Info
->fltTools
->hSelf
!= NULL
)
610 if (FloatToolbarCreateToolsGui(Info
))
616 ShowHideWindow(Info
->fltTools
->hSelf
);
620 if (Info
->fltColors
->hSelf
!= NULL
)
622 if (FloatToolbarCreateColorsGui(Info
))
628 if (Info
->fltHistory
->hSelf
!= NULL
)
630 if (FloatToolbarCreateHistoryGui(Info
))
639 MainWndDestroyFloatWindows(PMAIN_WND_INFO Info
)
641 if (Info
->fltTools
!= NULL
)
642 HeapFree(ProcessHeap
, 0, Info
->fltTools
);
644 if (Info
->fltColors
!= NULL
)
645 HeapFree(ProcessHeap
, 0, Info
->fltColors
);
647 if (Info
->fltHistory
!= NULL
)
648 HeapFree(ProcessHeap
, 0, Info
->fltHistory
);
653 static const DOCKBAR_ITEM_CALLBACKS MainWndDockBarCallbacks
= {
654 MainWndCreateToolbarClient
,
655 MainWndDestroyToolbarClient
,
656 MainWndToolbarInsertBand
,
657 MainWndToolbarDockBand
,
658 MainWndToolbarChevronPushed
,
662 CreateToolbars(PMAIN_WND_INFO Info
)
666 for (i
= 0; i
< sizeof(MainDockBars
) / sizeof(MainDockBars
[0]); i
++)
668 /* FIXME - lookup whether to display the toolbar */
669 TbdAddToolbar(&Info
->ToolDocks
,
672 &MainWndDockBarCallbacks
);
675 MainWndCreateFloatWindows(Info
);
679 MainWndResize(PVOID Context
,
687 PMAIN_WND_INFO Info
= (PMAIN_WND_INFO
)Context
;
689 /* Calculate the MDI client rectangle */
691 rcClient
.bottom
= cy
;
693 if (Info
->hStatus
!= NULL
)
695 GetWindowRect(Info
->hStatus
,
697 rcClient
.bottom
-= (rcStatus
.bottom
- rcStatus
.top
);
700 /* Adjust the client rect if docked toolbars are visible */
701 DocksVisible
= TbdAdjustUpdateClientRect(&Info
->ToolDocks
,
704 dwp
= BeginDeferWindowPos(2 + DocksVisible
);
707 /* Update the toolbar docks */
708 if (DocksVisible
!= 0)
710 dwp
= TbdDeferDocks(dwp
,
716 /* Update the MDI client */
717 if (Info
->hMdiClient
!= NULL
)
719 dwp
= DeferWindowPos(dwp
,
724 rcClient
.right
- rcClient
.left
,
725 rcClient
.bottom
- rcClient
.top
,
731 /* Update the status bar */
732 if (Info
->hStatus
!= NULL
)
734 dwp
= DeferWindowPos(dwp
,
738 cy
- (rcStatus
.bottom
- rcStatus
.top
),
740 rcStatus
.bottom
- rcStatus
.top
,
746 EndDeferWindowPos(dwp
);
751 InitMainWnd(PMAIN_WND_INFO Info
)
753 CLIENTCREATESTRUCT ccs
;
754 INT statwidths
[] = {110, -1};
756 /* FIXME - create controls and initialize the application */
758 /* create the status bar */
759 Info
->hStatus
= CreateWindowEx(0,
762 WS_VISIBLE
| WS_CHILD
| WS_CLIPSIBLINGS
| CCS_NOPARENTALIGN
| SBARS_SIZEGRIP
,
768 (HMENU
)IDC_STATUSBAR
,
772 if (Info
->hStatus
!= NULL
)
773 SendMessage(Info
->hStatus
,
775 sizeof(statwidths
)/sizeof(int),
778 /* create the MDI client window */
779 ccs
.hWindowMenu
= GetSubMenu(GetMenu(Info
->hSelf
),
781 ccs
.idFirstChild
= ID_MDI_FIRSTCHILD
;
782 Info
->hMdiClient
= CreateWindowEx(WS_EX_ACCEPTFILES
| WS_EX_CLIENTEDGE
,
785 WS_VISIBLE
| WS_CHILD
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
| WS_VSCROLL
| WS_HSCROLL
,
795 TbdInitializeDocks(&Info
->ToolDocks
,
800 CreateToolbars(Info
);
802 /* initialize file open/save structure */
803 FileInitialize(Info
->hSelf
);
807 MainWndCommand(PMAIN_WND_INFO Info
,
811 static TCHAR szFileName
[MAX_PATH
];
812 static TCHAR szImageName
[MAX_PATH
];
814 UNREFERENCED_PARAMETER(hControl
);
820 MessageBox(NULL
, _T("Not yet implemented"), NULL
, 0);
826 OPEN_IMAGE_EDIT_INFO OpenInfo
;
828 if (DoOpenFile(Info
->hSelf
,
829 szFileName
, /* full file path */
830 szImageName
)) /* file name */
832 OpenInfo
.CreateNew
= FALSE
;
834 OpenInfo
.Open
.lpImagePath
= szFileName
;
835 OpenInfo
.lpImageName
= szImageName
;
837 CreateImageEditWindow(Info
,
840 /* FIXME: move flt wnd's if scroll bars show
841 MainWndResetFloatingWindows(Info->hMdiClient); */
849 HMENU hMenu
= GetMenu(Info
->hSelf
);
853 UINT uCheck
= MF_CHECKED
;
855 if (ShowHideWindow(Info
->fltTools
->hSelf
))
856 uCheck
= MF_UNCHECKED
;
867 HMENU hMenu
= GetMenu(Info
->hSelf
);
871 UINT uCheck
= MF_CHECKED
;
873 if (ShowHideWindow(Info
->fltColors
->hSelf
))
874 uCheck
= MF_UNCHECKED
;
885 HMENU hMenu
= GetMenu(Info
->hSelf
);
889 UINT uCheck
= MF_CHECKED
;
891 if (ShowHideWindow(Info
->fltHistory
->hSelf
))
892 uCheck
= MF_UNCHECKED
;
902 DialogBoxParam(hInstance
,
903 MAKEINTRESOURCE(IDD_BRIGHTNESS
),
910 /* FIXME : Create a window for contrast */
913 case ID_BLACKANDWHITE
:
915 if (Info
->ImageEditors
)
917 DisplayBlackAndWhite(Info
->ImageEditors
->hSelf
,
918 Info
->ImageEditors
->hDCMem
,
919 Info
->ImageEditors
->hBitmap
);
924 case ID_INVERTCOLORS
:
926 if (Info
->ImageEditors
)
928 DisplayInvertedColors(Info
->ImageEditors
->hSelf
,
929 Info
->ImageEditors
->hDCMem
,
930 Info
->ImageEditors
->hBitmap
);
937 if (Info
->ImageEditors
)
939 DisplayBlur(Info
->ImageEditors
->hSelf
,
940 Info
->ImageEditors
->hDCMem
,
941 Info
->ImageEditors
->hBitmap
);
948 if (Info
->ImageEditors
)
950 DisplaySharpness(Info
->ImageEditors
->hSelf
,
951 Info
->ImageEditors
->hDCMem
,
952 Info
->ImageEditors
->hBitmap
);
958 SendMessage(Info
->hSelf
,
965 case ID_WINDOW_TILE_HORZ
:
966 SendMessage(Info
->hMdiClient
,
972 case ID_WINDOW_TILE_VERT
:
973 SendMessage(Info
->hMdiClient
,
979 case ID_WINDOW_CASCADE
:
980 SendMessage(Info
->hMdiClient
,
986 case ID_WINDOW_ARRANGE
:
987 SendMessage(Info
->hMdiClient
,
994 SendMessage(Info
->hMdiClient
,
1002 DialogBox(hInstance
,
1003 MAKEINTRESOURCE(IDD_ABOUTBOX
),
1011 DestroyMainWnd(PMAIN_WND_INFO Info
)
1013 /* FIXME - cleanup allocated resources */
1015 MainWndDestroyFloatWindows(Info
);
1020 UpdateMainStatusBar(PMAIN_WND_INFO Info
)
1022 if (Info
->hStatus
!= NULL
)
1024 SendMessage(Info
->hStatus
,
1026 (WPARAM
)Info
->InMenuLoop
,
1032 MainWndMenuHint(PMAIN_WND_INFO Info
,
1034 const MENU_HINT
*HintArray
,
1039 const MENU_HINT
*LastHint
;
1040 UINT HintId
= DefHintId
;
1042 LastHint
= HintArray
+ HintsCount
;
1043 while (HintArray
!= LastHint
)
1045 if (HintArray
->CmdId
== CmdId
)
1047 HintId
= HintArray
->HintId
;
1054 StatusBarLoadString(Info
->hStatus
,
1062 static LRESULT CALLBACK
1063 MainWndProc(HWND hwnd
,
1068 PMAIN_WND_INFO Info
;
1070 static BOOL bLBMouseDown
= FALSE
;
1071 static RECT wndOldPos
;
1073 /* Get the window context */
1074 Info
= (PMAIN_WND_INFO
)GetWindowLongPtr(hwnd
,
1076 if (Info
== NULL
&& uMsg
!= WM_CREATE
)
1078 goto HandleDefaultMessage
;
1088 /* NOTE - do *not* forward this message to DefFrameProc! Otherwise the MDI client
1089 will attempt to resize itself */
1091 /* reposition the floating toolbars */
1092 if ((wParam
== SIZE_MAXIMIZED
) || (wParam
== SIZE_RESTORED
))
1093 MainWndResetFloatingWindows(Info
);
1098 case WM_NCLBUTTONDOWN
:
1099 bLBMouseDown
= TRUE
;
1106 case WM_NCLBUTTONUP
:
1108 bLBMouseDown
= FALSE
;
1117 /* if the main window is moved, move the toolbars too */
1119 MainWndMoveFloatingWindows(Info
, &wndOldPos
);
1126 LPNMHDR pnmhdr
= (LPNMHDR
)lParam
;
1127 if (!TbdHandleNotifications(&Info
->ToolDocks
,
1131 if (TbdDockBarIdFromClientWindow(&Info
->ToolDocks
,
1137 case ID_TOOLBAR_TEXT
:
1138 switch (pnmhdr
->code
)
1140 case TBN_DELETINGBUTTON
:
1142 LPNMTOOLBAR lpnmtb
= (LPNMTOOLBAR
)lParam
;
1144 ToolbarDeleteControlSpace(pnmhdr
->hwndFrom
,
1158 MainWndCommand(Info
,
1161 goto HandleDefaultMessage
;
1166 if (Info
->hStatus
!= NULL
)
1168 if (!MainWndMenuHint(Info
,
1171 sizeof(MainMenuHintTable
) / sizeof(MainMenuHintTable
[0]),
1174 MainWndMenuHint(Info
,
1176 SystemMenuHintTable
,
1177 sizeof(SystemMenuHintTable
) / sizeof(SystemMenuHintTable
[0]),
1184 case WM_ENTERMENULOOP
:
1186 Info
->InMenuLoop
= TRUE
;
1187 UpdateMainStatusBar(Info
);
1191 case WM_EXITMENULOOP
:
1193 Info
->InMenuLoop
= FALSE
;
1194 UpdateMainStatusBar(Info
);
1200 DestroyWindow(hwnd
);
1206 TbdHandleEnabling(&Info
->ToolDocks
,
1209 goto HandleDefaultMessage
;
1214 TbdHandleActivation(&Info
->ToolDocks
,
1218 goto HandleDefaultMessage
;
1221 case WM_ACTIVATEAPP
:
1223 //TbdShowFloatingToolbars(&Info->ToolDocks,
1225 goto HandleDefaultMessage
;
1230 Info
= (PMAIN_WND_INFO
)(((LPCREATESTRUCT
)lParam
)->lpCreateParams
);
1232 /* Initialize the main window context */
1235 SetWindowLongPtr(hwnd
,
1241 /* Show the window */
1244 /* get the windows position */
1253 DestroyMainWnd(Info
);
1255 HeapFree(ProcessHeap
,
1258 SetWindowLongPtr(hwnd
,
1262 /* Break the message queue loop */
1269 HandleDefaultMessage
:
1270 if (Info
!= NULL
&& Info
->hMdiClient
!= NULL
)
1272 Ret
= DefFrameProc(hwnd
,
1280 Ret
= DefWindowProc(hwnd
,
1293 MainWndGetCurrentEditor(PMAIN_WND_INFO MainWnd
,
1296 MDI_EDITOR_TYPE EditorType
;
1298 if (MainWnd
->ActiveEditor
!= NULL
)
1300 EditorType
= *((PMDI_EDITOR_TYPE
)MainWnd
->ActiveEditor
);
1301 *Info
= MainWnd
->ActiveEditor
;
1305 EditorType
= metUnknown
;
1313 MainWndSwitchEditorContext(PMAIN_WND_INFO Info
,
1317 PMDI_EDITOR_TYPE EditorType
;
1319 /* FIXME - optimize light weight switching
1320 when switching from and to an editor of same type */
1322 if (hDeactivate
!= NULL
)
1324 EditorType
= (PMDI_EDITOR_TYPE
)GetWindowLongPtr(hDeactivate
,
1326 if (EditorType
!= NULL
)
1328 switch (*EditorType
)
1330 case metImageEditor
:
1331 SetImageEditorEnvironment((PEDIT_WND_INFO
)EditorType
,
1339 Info
->ActiveEditor
= NULL
;
1343 if (hActivate
!= NULL
)
1345 EditorType
= (PMDI_EDITOR_TYPE
)GetWindowLongPtr(hActivate
,
1347 if (EditorType
!= NULL
)
1349 Info
->ActiveEditor
= EditorType
;
1351 switch (*EditorType
)
1353 case metImageEditor
:
1354 SetImageEditorEnvironment((PEDIT_WND_INFO
)EditorType
,
1366 CreateMainWindow(LPCTSTR lpCaption
,
1369 PMAIN_WND_INFO Info
;
1370 HWND hMainWnd
= NULL
;
1372 Info
= HeapAlloc(ProcessHeap
,
1374 sizeof(MAIN_WND_INFO
));
1378 sizeof(MAIN_WND_INFO
));
1379 Info
->nCmdShow
= nCmdShow
;
1381 /* FIXME - load the window position from the registry */
1383 hMainWnd
= CreateWindowEx(WS_EX_WINDOWEDGE
,
1386 WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
,
1395 if (hMainWnd
== NULL
)
1397 HeapFree(ProcessHeap
,
1407 MainWndTranslateMDISysAccel(HWND hwnd
,
1410 PMAIN_WND_INFO Info
;
1412 /* Get the window context */
1413 Info
= (PMAIN_WND_INFO
)GetWindowLongPtr(hwnd
,
1415 if (Info
!= NULL
&& Info
->hMdiClient
!= NULL
)
1417 return TranslateMDISysAccel(Info
->hMdiClient
,
1425 InitMainWindowImpl(VOID
)
1427 WNDCLASSEX wc
= {0};
1429 wc
.cbSize
= sizeof(WNDCLASSEX
);
1430 wc
.lpfnWndProc
= MainWndProc
;
1431 wc
.hInstance
= hInstance
;
1432 wc
.hIcon
= LoadIcon(hInstance
,
1433 MAKEINTRESOURCE(IDI_IMAGESOFTICON
));
1434 wc
.hCursor
= LoadCursor(NULL
,
1436 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
1437 wc
.lpszMenuName
= MAKEINTRESOURCE(IDR_MAINMENU
);
1438 wc
.lpszClassName
= szMainWndClass
;
1439 wc
.hIconSm
= (HICON
)LoadImage(hInstance
,
1440 MAKEINTRESOURCE(IDI_IMAGESOFTICON
),
1446 return RegisterClassEx(&wc
) != (ATOM
)0;
1450 UninitMainWindowImpl(VOID
)
1452 UnregisterClass(szMainWndClass
,