├── .gitattributes
├── .gitignore
├── EasyWindow 4.0.sln
├── EasyWindow 4.0
├── EasyWindow 4.0.vcxitems
├── EasyWindow.c
└── EasyWindow.h
├── EasyWindowDemo
├── EasyWindowDemo.vcxproj
├── EasyWindowDemo.vcxproj.filters
└── Main.c
└── LICENSE
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/EasyWindow 4.0.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.106
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EasyWindow 4.0", "EasyWindow 4.0\EasyWindow 4.0.vcxitems", "{EAD29E18-C688-46A0-B8A7-01DC01C9FA12}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EasyWindowDemo", "EasyWindowDemo\EasyWindowDemo.vcxproj", "{63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}"
9 | EndProject
10 | Global
11 | GlobalSection(SharedMSBuildProjectFiles) = preSolution
12 | EasyWindow 4.0\EasyWindow 4.0.vcxitems*{63ab13fd-00da-46d0-acb6-633f8fbdd89a}*SharedItemsImports = 4
13 | EasyWindow 4.0\EasyWindow 4.0.vcxitems*{ead29e18-c688-46a0-b8a7-01dc01c9fa12}*SharedItemsImports = 9
14 | EndGlobalSection
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|x64 = Debug|x64
17 | Debug|x86 = Debug|x86
18 | Release|x64 = Release|x64
19 | Release|x86 = Release|x86
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Debug|x64.ActiveCfg = Debug|x64
23 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Debug|x64.Build.0 = Debug|x64
24 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Debug|x86.ActiveCfg = Debug|Win32
25 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Debug|x86.Build.0 = Debug|Win32
26 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Release|x64.ActiveCfg = Release|x64
27 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Release|x64.Build.0 = Release|x64
28 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Release|x86.ActiveCfg = Release|Win32
29 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}.Release|x86.Build.0 = Release|Win32
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {A2BD6D13-E6A3-42CB-8AE5-29881B7A27D8}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/EasyWindow 4.0/EasyWindow 4.0.vcxitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | {ead29e18-c688-46a0-b8a7-01dc01c9fa12}
7 |
8 |
9 |
10 | %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/EasyWindow 4.0/EasyWindow.c:
--------------------------------------------------------------------------------
1 | #include"EasyWindow.h"
2 |
3 | //*******************************************************************************************
4 | // 函数实体
5 | //*******************************************************************************************
6 |
7 | //初始化函数
8 | BOOL InitEZWindow()
9 | {
10 | WNDCLASS wndclass;
11 | //注册窗口类
12 | wndclass.style = CS_HREDRAW | CS_VREDRAW;
13 | wndclass.lpfnWndProc = EZParentWndProc;
14 | wndclass.cbClsExtra = 0;
15 | wndclass.cbWndExtra = sizeof(LONG_PTR);
16 | wndclass.hInstance = GetModuleHandle(NULL);
17 | wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
18 | wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
19 | wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
20 | wndclass.lpszMenuName = NULL;
21 | wndclass.lpszClassName = EZWindowClass;
22 | if (!RegisterClass(&wndclass))
23 | {
24 | return FALSE;
25 | }
26 |
27 |
28 | return TRUE;
29 | }
30 |
31 |
32 |
33 | //创建窗口函数
34 | EZWND CreateEZParentWindowEx(DWORD EZStyle, int x, int y, int Width, int Height, DWORD WinStyle, EZWNDPROC ezWndProc, HMENU hMenu, HWND hParent)
35 | {
36 | HWND hwndParent;//这是Windows句柄的父窗口
37 | EZWND ezwndParent;//这是和Win窗口等大的EZ窗口,返回给用户。该窗口摧毁时同时摧毁Win窗口
38 |
39 |
40 | ezwndParent = (EZWND)malloc(sizeof(EZWINDOW));
41 |
42 |
43 | //Create tht EZ Window With out Using "CreateEZWindow"
44 | if (!ezwndParent)//检查内存
45 | {
46 | return (EZWND)0;
47 | }
48 |
49 | ezwndParent->TopWndExtend = (pTWE)malloc(sizeof(TopWndExt));
50 |
51 | if (!ezwndParent->TopWndExtend)//检查内存
52 | {
53 | free(ezwndParent);
54 | return (EZWND)0;
55 | }
56 |
57 |
58 | ezwndParent->EZStyle = EZStyle;
59 |
60 | if (EZStyle != 0L)
61 | {
62 | ezwndParent->Extend = (pEZSE)malloc(sizeof(EZSE));
63 |
64 | ZeroMemory(ezwndParent->Extend, sizeof(EZSE));
65 | }
66 | else
67 | {
68 | ezwndParent->Extend = NULL;//防野指针
69 | }
70 |
71 |
72 |
73 | //ezwndParent->Extend = 0;
74 |
75 |
76 | int i;
77 | for (i = 0; i < MAX_EZ_TIMER; i++)
78 | {
79 | ezwndParent->TopWndExtend->Timer[i].ezWnd = NULL;
80 | ezwndParent->TopWndExtend->Timer[i].WinTimerID = 0;
81 | }
82 |
83 |
84 |
85 |
86 | ezwndParent->x = x;
87 | ezwndParent->y = y;
88 | ezwndParent->Width = Width;
89 | ezwndParent->Height = Height;
90 |
91 |
92 | ezwndParent->px = 0;
93 | ezwndParent->py = 0;
94 |
95 | ezwndParent->ScrollX = 0;
96 | ezwndParent->ScrollY = 0;
97 |
98 |
99 | ezwndParent->FirstChild = NULL;
100 | ezwndParent->LastEZWnd = NULL;
101 | ezwndParent->NextEZWnd = NULL;
102 | ezwndParent->ezParent = NULL;//没有,空。
103 | ezwndParent->ezRootParent = ezwndParent;//你自己
104 |
105 | ezwndParent->TopWndExtend->CptMouseWindow = NULL;//没有的,2333
106 | ezwndParent->TopWndExtend->FocusWindow = NULL;
107 | ezwndParent->TopWndExtend->MouseOnWnd = NULL;
108 |
109 |
110 | ezwndParent->IsTopWindow = TRUE;//是的,是顶层窗口。
111 |
112 | ezwndParent->FocusState = FALSE;
113 |
114 | ezwndParent->MouseMsgRecv = 1;
115 |
116 | ezwndParent->ShowState = 1;
117 |
118 | ezwndParent->MouseOn = FALSE;
119 |
120 | ezwndParent->Update = FALSE;//刚开始,肯定没有更新过。
121 |
122 | ezwndParent->Transparent = 255;//不透明
123 |
124 | ezwndParent->ezWndProc = ezWndProc;
125 |
126 | ezwndParent->TopWndExtend->FocusWindow = NULL;
127 |
128 |
129 | ezwndParent->IsWinWnd = 0;
130 | ezwndParent->hChild = 0;
131 |
132 |
133 | ezwndParent->IsStyleWindow = FALSE;
134 |
135 | ezwndParent->ezID = 0;
136 |
137 | //大部分内容都初始化完毕了。ezwndParent被作为参数提交给WM_CREATE消息,并在期间将这个指针设置为窗口扩展
138 | hwndParent = CreateWindow(EZWindowClass, TEXT(""), WinStyle, x, y, Width, Height, hParent, hMenu, GetModuleHandle(NULL), ezwndParent);
139 |
140 | // EZRepaint(ezwndParent, NULL);
141 |
142 | return ezwndParent;
143 | }
144 |
145 | EZWND CreateEZWindowEx(EZWND ezParent, DWORD EZStyle, int x, int y, int Width, int Height, EZWNDPROC ezWndProc)
146 | {
147 | HWND hParent;
148 | EZWND ezWnd;
149 | HDC fhdc;
150 | if (!IsEZWindow(ezParent))
151 | {
152 | return (EZWND)0;
153 | }
154 |
155 | if (!(ezWnd = (EZWND)malloc(sizeof(EZWINDOW))))//创建并检查内存
156 | {
157 | return (EZWND)0;
158 | }
159 |
160 | ezWnd->EZStyle = EZStyle;
161 |
162 | if (EZStyle != 0L)
163 | {
164 | ezWnd->Extend = (pEZSE)malloc(sizeof(EZSE));
165 |
166 | ZeroMemory(ezWnd->Extend, sizeof(EZSE));
167 | }
168 | else
169 | {
170 | ezWnd->Extend = NULL;//防野指针
171 | }
172 |
173 | ezWnd->TopWndExtend = NULL;
174 |
175 | ezWnd->x = x;
176 | ezWnd->y = y;
177 | ezWnd->Width = Width;
178 | ezWnd->Height = Height;
179 |
180 | ezWnd->px = ezParent->px + x + ezParent->ScrollX;
181 | ezWnd->py = ezParent->py + y + ezParent->ScrollY;
182 |
183 | ezWnd->ScrollX = 0;
184 | ezWnd->ScrollY = 0;
185 |
186 | ezWnd->FirstChild = NULL;
187 | ezWnd->LastEZWnd = NULL;
188 | ezWnd->NextEZWnd = NULL;
189 |
190 | ezWnd->hParent = ezParent->hParent;
191 | ezWnd->IsTopWindow = FALSE;//并不是
192 |
193 |
194 | ezWnd->FocusState = 0;
195 | ezWnd->MouseMsgRecv = 1;
196 | ezWnd->ShowState = 1;
197 |
198 | ezWnd->MouseOn = FALSE;
199 |
200 | ezWnd->Update = 1;//刚开始,肯定没有更新过。
201 |
202 | ezWnd->Transparent = 255;//不透明
203 |
204 | ezWnd->ezParent = ezParent;
205 | ezWnd->ezRootParent = ezParent->ezRootParent;
206 | ezWnd->ezWndProc = ezWndProc;
207 |
208 | //在EZ父窗口最后追加这个新的子窗口。
209 | EZAddChild(ezParent, ezWnd);
210 |
211 | //ezWnd->DrawOnNC = 0;
212 | fhdc = GetDC(hParent = ezParent->hParent);
213 | ezWnd->hdc = GetMemDC(fhdc, Width, Height);
214 | // ezWnd->hdcCopy = GetMemDC(fhdc, Width, Height);
215 | ReleaseDC(hParent, fhdc);
216 |
217 | ezWnd->bOpaque = 0;
218 |
219 | ezWnd->IsWinWnd = 0;
220 | ezWnd->hChild = 0;
221 |
222 |
223 | ezWnd->IsStyleWindow = FALSE;
224 |
225 |
226 | ezWnd->ezID = 0;
227 |
228 | EZSendMessage(ezWnd, EZWM_CREATE, 0, 0);//发送创建消息
229 |
230 | //只发送一个移动消息
231 | EZSendMessage(ezWnd, EZWM_SIZE, (WPARAM)NULL, (LPARAM)MAKELPARAM(Width, Height));
232 | return ezWnd;
233 |
234 | }
235 |
236 | BOOL EZAddChild(EZWND ezParent, EZWND ezChild)
237 | {
238 | EZWND ezChildLast;
239 | //将子窗口追加在ezParent的子窗口链表最后
240 | if (!IsEZWindow(ezParent->FirstChild))
241 | {
242 | ezParent->FirstChild = ezChild;
243 | return TRUE;
244 | }
245 |
246 | //子窗口链表第一个不为空
247 | ezChildLast = ezParent->FirstChild;
248 |
249 | while (1)//循环到链表最后
250 | {
251 | if (!IsEZWindow(ezChildLast->NextEZWnd))
252 | {
253 | ezChild->LastEZWnd = ezChildLast;
254 | ezChildLast->NextEZWnd = ezChild;
255 | return TRUE;
256 | }
257 | ezChildLast = ezChildLast->NextEZWnd;//向下移动
258 | }
259 |
260 | }
261 |
262 |
263 | EZWND CreateEZStyleWindow(EZWND ezParent, TCHAR Title[], DWORD EZStyle, int x, int y, int Width, int Height)
264 | {
265 | EZWND ezWnd;
266 | ezWnd = 0;
267 | //解析属性,检测是否冲突,然后创建窗口。
268 | if (CHK_ALT_STYLE(EZStyle, EZS_CHILD))
269 | {
270 | //子窗口
271 | switch (EZStyle & MKDW(00000000, 00000000, 00000000, 11111111))
272 | {
273 | case EZS_STATIC:
274 | ezWnd = CreateEZWindowEx(ezParent, EZStyle, x, y, Width, Height, EZStyle_StaticProc);
275 |
276 | break;
277 | case EZS_BUTTON:
278 | ezWnd = CreateEZWindowEx(ezParent, EZStyle, x, y, Width, Height, EZStyle_ButtonProc);
279 | break;
280 | case EZS_CHILD_HSCROLL:
281 | case EZS_CHILD_VSCROLL:
282 | ezWnd = CreateEZWindowEx(ezParent, EZStyle, x, y, Width, Height, EZStyle_ScrollChildProc);
283 | break;
284 | case EZS_EDIT:
285 | ezWnd = CreateEZWindowEx(ezParent, EZStyle, x, y, Width, Height, EZStyle_EditProc);
286 | break;
287 | }
288 |
289 | }
290 | else
291 | {
292 | //主窗口
293 |
294 | }
295 |
296 |
297 | ((pEZSE)ezWnd->Extend)->hFont = NULL;
298 | ezWnd->Extend->Title = 0;
299 | EZSendMessage(ezWnd, EZWM_SETTEXT, Title, lstrlen(Title));
300 |
301 |
302 | ((pEZSE)ezWnd->Extend)->BackGroundColor = RGB(255, 255, 255);
303 |
304 | ((pEZSE)ezWnd->Extend)->ForeGroundColor = RGB(0, 0, 0);
305 |
306 | ((pEZSE)ezWnd->Extend)->MouseHold = FALSE;
307 |
308 |
309 | ((pEZSE)ezWnd->Extend)->IsFontUserControl = -1;
310 |
311 |
312 | //最后再设置一遍,防止之前被防野数据机制清零。
313 | ezWnd->IsStyleWindow = TRUE;
314 | ezWnd->EZStyle = EZStyle;
315 |
316 | return ezWnd;
317 | }
318 |
319 |
320 | EZWND CreateEZStyleParentWindow(TCHAR Title[], DWORD EZStyle, int x, int y, int Width, int Height, BOOL bAdjust, EZWNDPROC ezWndProc)
321 | {
322 | EZWND ezParent = 0, ezWnd = 0;
323 | //解析属性,检测是否冲突,然后创建窗口。
324 | if (CHK_ALT_STYLE(EZStyle, EZS_CHILD))
325 | {
326 |
327 | }
328 | else
329 | {
330 | //主窗口
331 | //子窗口
332 | DWORD WinStyle = WS_VISIBLE | WS_DLGFRAME | WS_POPUP | WS_THICKFRAME;
333 | switch (EZStyle & MKDW(00000000, 00000000, 00000000, 11111111))
334 | {
335 |
336 |
337 | case EZS_OVERLAPPEDWINDOW:
338 | WinStyle |= WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
339 | case EZS_OVERLAPPED:
340 |
341 |
342 | ezParent = CreateEZParentWindowEx(EZStyle, x, y, Width, bAdjust ? Height + EZWND_CAP_HEIGHT : Height,
343 | WinStyle, EZStyle_OverlappedWndProc, 0, 0);
344 | ezParent->Extend->hExtend[0] = ezWnd = CreateEZWindow(ezParent, 0, EZWND_CAP_HEIGHT, Width, bAdjust ? Height : Height - EZWND_CAP_HEIGHT, ezWndProc);
345 |
346 | break;
347 | }
348 |
349 | }
350 |
351 |
352 | ((pEZSE)ezParent->Extend)->hFont = NULL;
353 | ezParent->Extend->Title = 0;
354 | EZSendMessage(ezParent, EZWM_SETTEXT, Title, lstrlen(Title));
355 |
356 |
357 | ((pEZSE)ezParent->Extend)->BackGroundColor = RGB(255, 255, 255);
358 |
359 | ((pEZSE)ezParent->Extend)->ForeGroundColor = RGB(0, 0, 0);
360 |
361 | ((pEZSE)ezParent->Extend)->MouseHold = FALSE;
362 |
363 |
364 | ((pEZSE)ezParent->Extend)->IsFontUserControl = -1;
365 |
366 |
367 | //最后再设置一遍,防止之前被防野数据机制清零。
368 | ezParent->IsStyleWindow = TRUE;
369 | ezParent->EZStyle = EZStyle;
370 |
371 | EZRepaint(ezParent, 0);
372 |
373 | return ezWnd;
374 | }
375 |
376 | //销毁窗口函数
377 | BOOL DestroyEZWindow(EZWND ezWnd)
378 | {
379 |
380 | if (ezWnd->IsTopWindow)
381 | {
382 | DestroyWindow(ezWnd->hParent);//这就行了,销毁会在这里完成。这也没什么好说的,不用管链表,清理就是了。
383 | return TRUE;
384 | }
385 |
386 |
387 |
388 | //先保存信息,倒推,消除所有子孙窗口
389 | if (IsEZWindow(ezWnd->FirstChild))
390 | {
391 | DestroyEZWindowWithNext(ezWnd->FirstChild);
392 | }
393 |
394 |
395 | //把你自己清理了
396 | EZSendMessage(ezWnd, EZWM_DESTROY, (WPARAM)NULL, (LPARAM)NULL);//发送销毁信息
397 |
398 | DeleteMemDC(ezWnd->hdc);//清理DC
399 | //DeleteMemDC(ezWnd->hdcCopy);//清理DC
400 |
401 | if (ezWnd->ezRootParent->TopWndExtend->MouseOnWnd == ezWnd)
402 | {
403 | ezWnd->ezRootParent->TopWndExtend->MouseOnWnd = NULL;
404 | }
405 | if (ezWnd->ezRootParent->TopWndExtend->FocusWindow == ezWnd)
406 | {
407 | ezWnd->ezRootParent->TopWndExtend->FocusWindow = NULL;
408 | }
409 | if (ezWnd->ezRootParent->TopWndExtend->CptMouseWindow == ezWnd)
410 | {
411 | ezWnd->ezRootParent->TopWndExtend->CptMouseWindow = NULL;
412 | }
413 |
414 |
415 | if (ezWnd->IsTopWindow)
416 | {
417 | DeleteMemDC(ezWnd->TopWndExtend->hdcTop);
418 | free(ezWnd->TopWndExtend);
419 | }
420 |
421 |
422 | if (ezWnd->IsStyleWindow)
423 | {
424 | free(ezWnd->Extend);
425 | }
426 | //维护一下链表?
427 | if (ezWnd->LastEZWnd)
428 | {
429 | //有上一个
430 | if (ezWnd->NextEZWnd)
431 | {
432 | //还有下一个。
433 | ezWnd->LastEZWnd->NextEZWnd = ezWnd->NextEZWnd;
434 | ezWnd->NextEZWnd->LastEZWnd = ezWnd->LastEZWnd;
435 | //链接好咯
436 | }
437 | else
438 | {
439 | //下一个是空的
440 | ezWnd->LastEZWnd->NextEZWnd = NULL;
441 | }
442 | }
443 | else
444 | {
445 | //没有上一个?你是顶层窗口?还是第一个?
446 | if (!(ezWnd->IsTopWindow))
447 | {
448 | //不是顶层啊,你是某个链的第一个
449 | if (ezWnd->NextEZWnd)
450 | {
451 | //还有下一个
452 | ezWnd->ezParent->FirstChild = ezWnd->NextEZWnd;
453 | ezWnd->NextEZWnd->LastEZWnd = NULL;
454 | }
455 | else
456 | {
457 | //你没下面一个了,你父窗口没儿子了。
458 | ezWnd->ezParent->FirstChild = NULL;
459 | }
460 | }
461 | }
462 |
463 |
464 | if ((ezWnd->ezParent->EZStyle != 0) && (!(ezWnd->ezParent->EZStyle & EZS_CHILD)) && ezWnd->ezParent->IsTopWindow)
465 | {
466 | //父窗口是样式父窗口,绑定删除
467 | if (ezWnd->ezParent->FirstChild)
468 | {
469 |
470 | ezWnd->ezParent->FirstChild = 0;//让父窗口误以为自己没有子窗口,就不会递归删除进入死循环了
471 | DestroyWindow(ezWnd->ezParent->hParent);
472 | }
473 | }
474 |
475 | free(ezWnd);
476 | ezWnd = NULL;
477 | return TRUE;
478 |
479 | }
480 |
481 | BOOL DestroyEZWindowWithNext(EZWND ezWnd)
482 | {
483 | EZWND ezChildLast;
484 |
485 | //回滚,准备清理并列窗口
486 | if (IsEZWindow(ezWnd->NextEZWnd))
487 | {
488 | ezChildLast = ezWnd->NextEZWnd;
489 |
490 | //循环到链表最后
491 | while (1)
492 | {
493 | if (!IsEZWindow(ezChildLast->NextEZWnd))
494 | {
495 | break;//最后,跳出。
496 | }
497 | ezChildLast = ezChildLast->NextEZWnd;
498 | }
499 |
500 |
501 | //再循环滚回链表最前(一边滚一边删)
502 |
503 | //为了数据,先回滚,然后通过向下的指针找回去,删了
504 | while (IsEZWindow(ezChildLast->LastEZWnd))//还没到头
505 | {
506 |
507 | ezChildLast = ezChildLast->LastEZWnd;//回滚
508 |
509 | //这时,ezChildLast->NextEZWnd就是最后一个。DestroyEZWindow会删了该窗口和这个窗口的子窗口。
510 | DestroyEZWindow(ezChildLast->NextEZWnd);//删了
511 | }
512 | //滚动到头了,DestroyEZWindow会删了该窗口和这个窗口的子窗口。
513 | DestroyEZWindow(ezChildLast);
514 | return TRUE;
515 |
516 | }
517 | else
518 | {//你就是最后一个并列窗口。
519 | DestroyEZWindow(ezWnd);//删了
520 | }
521 | return TRUE;
522 |
523 | }
524 |
525 |
526 |
527 | //窗口设置函数
528 | BOOL MoveEZWindow(EZWND ezWnd, int x, int y, int Width, int Height, BOOL repaint)
529 | {
530 | HDC fhdc;//临时DC
531 |
532 |
533 | if (ezWnd->IsTopWindow)
534 | {
535 | MoveWindow(ezWnd->hParent, x, y, Width, Height, FALSE);
536 | //剩下的工作里面会完成的
537 | //TODO:真的所有工作都会完成?仔细检查
538 |
539 | return TRUE;
540 | }
541 | else
542 | {
543 | ezWnd->x = x;
544 | ezWnd->y = y;
545 | ezWnd->Width = Width;
546 | ezWnd->Height = Height;
547 | ezWnd->px = ezWnd->ezParent->px + x + ezWnd->ezParent->ScrollX;
548 | ezWnd->py = ezWnd->ezParent->py + y + ezWnd->ezParent->ScrollY;
549 | //枚举所有子窗口并重设px,py
550 | EZResetChildPxPy(ezWnd);
551 | }
552 |
553 |
554 |
555 | //暂时清理DC,然后重新获得一个。
556 | /*DeleteMemDC(ezWnd->hdc);
557 | DeleteMemDC(ezWnd->hdcCopy);
558 |
559 |
560 | ezWnd->hdc = GetMemDC(fhdc, Width, Height);
561 | ezWnd->hdcCopy = GetMemDC(fhdc, Width, Height);
562 |
563 | if (ezWnd->IsTopWindow)
564 | {
565 | DeleteMemDC(ezWnd->TopWndExtend->hdcTop);
566 | ezWnd->TopWndExtend->hdcTop = GetMemDC(fhdc, Width, Height);
567 | }
568 |
569 | ReleaseDC(ezWnd->hParent, fhdc);*/
570 | fhdc = GetDC(ezWnd->hParent);
571 | AdjustMemDC(ezWnd->hdc, fhdc, Width, Height);
572 | // AdjustMemDC(ezWnd->hdcCopy, fhdc, Width, Height);
573 |
574 | ReleaseDC(ezWnd->hParent, fhdc);
575 | //ReleaseDC(ezWnd->hParent, fhdc);
576 |
577 | EZSendMessage(ezWnd, EZWM_SIZE, (WPARAM)NULL, (LPARAM)MAKELPARAM(Width, Height));
578 |
579 | if (repaint)
580 | {
581 | if (ezWnd->ezParent)
582 | {
583 | EZRepaint(ezWnd->ezParent, NULL);
584 | }
585 | else
586 | {
587 | EZRepaint(ezWnd, NULL);
588 | }
589 | }
590 |
591 | return TRUE;
592 | }
593 |
594 | BOOL ScrollEZWindow(EZWND ezWnd, int x, int y, BOOL bAdd)//bAdd为TRUE,则累加。否则重置
595 | {
596 | if (bAdd)
597 | {
598 | ezWnd->ScrollX += x;
599 | ezWnd->ScrollY += y;
600 | }
601 | else
602 | {
603 | ezWnd->ScrollX = x;
604 | ezWnd->ScrollY = y;
605 | }
606 | EZResetChildPxPy(ezWnd);
607 |
608 | EZRepaint(ezWnd, 0);
609 | return 0;
610 | }
611 | BOOL EZResetChildPxPy(EZWND ezWnd)
612 | {
613 | if (IsEZWindow(ezWnd->FirstChild))
614 | {
615 | for (EZWND EZChild = ezWnd->FirstChild; EZChild; EZChild = EZChild->NextEZWnd)
616 | {
617 | EZChild->px = ezWnd->px + EZChild->x + ezWnd->ScrollX;
618 | EZChild->py = ezWnd->py + EZChild->y + ezWnd->ScrollY;
619 | EZResetChildPxPy(EZChild);
620 | }
621 | }
622 | return 0;
623 | }
624 |
625 | BOOL SetEZWndTransparent(EZWND ezWnd, int Transparent)//设置EZ窗口透明度
626 | {
627 | ezWnd->Transparent = Transparent;
628 | return TRUE;
629 | }
630 |
631 | BOOL EZCaptureMouse(EZWND ezWnd)
632 | {
633 | //向顶层父窗口提交要捕获“老鼠”的窗口的句柄。
634 | if (ezWnd->ezRootParent->TopWndExtend->CptMouseWindow)
635 | {
636 | EZSendMessage(ezWnd->ezRootParent->TopWndExtend->CptMouseWindow, EZWM_RELEASEMOUSE, 0, 0);
637 |
638 | }
639 | ezWnd->ezRootParent->TopWndExtend->CptMouseWindow = ezWnd;
640 | EZSendMessage(ezWnd->ezRootParent->TopWndExtend->CptMouseWindow, EZWM_CAPTUREMOUSE, 0, 0);
641 | SetCapture(ezWnd->hParent);
642 | return TRUE;
643 | }
644 |
645 | BOOL EZReleaseMouse(EZWND ezWnd)
646 | {
647 | //向顶层父窗口提交释放“老鼠”申请。
648 |
649 | ReleaseCapture();
650 |
651 | //下面两这句不需要,在Window窗口处理WM_CAPTURECHANGE之间已经处理好了
652 | //EZSendMessage(ezWnd->ezRootParent->CptMouseWindow, EZWM_RELEASEMOUSE, 0, 0);
653 | //ezWnd->ezRootParent->CptMouseWindow = NULL;
654 |
655 | return TRUE;
656 | }
657 |
658 | BOOL SetMouseMsgRecvMode(EZWND ezWnd, int Mode)
659 | {
660 | ezWnd->MouseMsgRecv = Mode;
661 | return TRUE;
662 | }
663 |
664 | BOOL SetShowState(EZWND ezWnd, int State)
665 | {
666 | ezWnd->ShowState = State;
667 | return TRUE;
668 | }
669 |
670 |
671 |
672 |
673 |
674 | //与窗口绘制有关的函数
675 | BOOL EZRedraw(EZWND ezWnd)//重绘到内存dc,不更新。
676 | {
677 | //这里,我们需要先确定需要重绘的范围
678 |
679 | /*
680 | 在整个大窗口体系下
681 | 任何和该窗口有范围重复的窗口
682 | 全!部!需!要!重绘!!!!
683 |
684 | 所以,我们要向所有窗口,包括子窗口广播消息。任何有重复的窗口,全部需要重绘到内存
685 | 然后进行叠加处理。
686 |
687 | 不需要重绘到Windows父窗口。
688 |
689 | */
690 |
691 | if (!IsEZWindow(ezWnd))
692 | {
693 | return FALSE;
694 | }
695 | RECT rect;
696 |
697 |
698 | EZWND WndNow = ezWnd;
699 |
700 |
701 | //看看父窗口有没有ShowState为2的
702 | while (WndNow)
703 | {
704 | if (WndNow->ShowState == 2)
705 | {
706 | return 0;
707 | }
708 | //向上推,直到父窗口
709 | WndNow = WndNow->ezParent;
710 | }
711 |
712 | rect.left = ezWnd->px;
713 | rect.right = ezWnd->px + ezWnd->Width;
714 | rect.top = ezWnd->py;
715 | rect.bottom = ezWnd->py + ezWnd->Height;
716 |
717 |
718 |
719 | BroadcastProc(ezWnd, SEZWM_REDRAW, (WPARAM)NULL, (LPARAM)NULL);
720 | RedrawBroadcast(ezWnd, 0, 0, ezWnd->px, ezWnd->py, rect);
721 |
722 |
723 | BitBlt(ezWnd->ezRootParent->TopWndExtend->hdcTop,
724 | ezWnd->px,
725 | ezWnd->py,
726 | ezWnd->Width, ezWnd->Height,
727 | ezWnd->hdc,
728 | 0,
729 | 0, SRCCOPY);
730 |
731 | return TRUE;
732 | }
733 |
734 | BOOL RedrawBroadcast(EZWND ezWnd, WPARAM wp, LPARAM lp, int cx, int cy, RECT RectSrc)
735 | {
736 |
737 | if (!IsEZWindow(ezWnd))
738 | {
739 | return FALSE;
740 | }
741 |
742 | if (IsEZWindow(ezWnd->FirstChild))
743 | {
744 |
745 | EZWND LastChild;
746 |
747 |
748 |
749 | for (LastChild = ezWnd->FirstChild; LastChild; LastChild = LastChild->NextEZWnd)
750 | {
751 | //正序,所以,先处理自己。
752 | RECT RectDst, RectAns;
753 |
754 | {
755 | RectDst.left = cx + LastChild->x + LastChild->ezParent->ScrollX;
756 | RectDst.right = RectDst.left + LastChild->Width;
757 | RectDst.top = cy + LastChild->y + LastChild->ezParent->ScrollY;
758 | RectDst.bottom = RectDst.top + LastChild->Height;
759 | }
760 |
761 | if (!((IntersectRect(&RectAns, &RectSrc, &RectDst) == 0) || (LastChild->ShowState == 2)))
762 | //临时处理
763 | //if (LastChild->ShowState == 1)
764 | {
765 | /*HRGN hRgn, OldRgn;*/
766 |
767 | BroadcastProc(LastChild, SEZWM_REDRAW, wp, lp);//处理自己
768 |
769 |
770 |
771 | /*hRgn = CreateRectRgn(
772 | RectAns.left - (cx + LastChild->x + LastChild->ezParent->ScrollX),
773 | RectAns.top - (cy + LastChild->y + LastChild->ezParent->ScrollY),
774 | RectAns.right - (cx + LastChild->x + LastChild->ezParent->ScrollX),
775 | RectAns.bottom - (cy + LastChild->y + LastChild->ezParent->ScrollY));*/
776 |
777 | /*OldRgn = SelectObject(LastChild->hdc, hRgn);*/
778 |
779 |
780 |
781 | RedrawBroadcast(LastChild, wp, lp, cx + LastChild->x + LastChild->ezParent->ScrollX, cy + LastChild->y + LastChild->ezParent->ScrollY, RectAns);//给自己的子窗口发送该消息 /* DeleteObject(SelectObject(LastChild->hdc, OldRgn));*/
782 |
783 |
784 | BroadcastProc(LastChild, SEZWM_COPYDC, wp, lp);//处理自己
785 |
786 | }
787 |
788 |
789 | //向下滚
790 |
791 | }
792 |
793 | }
794 | return TRUE;
795 | }
796 |
797 | BOOL EZUpdate(EZWND ezWnd, HDC hdc)//将DC更新到窗体,不重绘。第二个参数是DC,如不提供,函数将自动获取。
798 | {
799 | //找到你的“祖宗”、
800 |
801 | EZWND WndNow = ezWnd;
802 |
803 | if (!IsEZWindow(ezWnd))
804 | {
805 | return FALSE;
806 | }
807 |
808 | //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
809 |
810 | ////EZBroadcastToAllChild(ezWnd, TRUE, SEZWM_COPYDC, (WPARAM)NULL, (LPARAM)NULL);,
811 |
812 |
813 | if (!hdc)//没DC
814 | {
815 |
816 | /*if (ezWnd->ezRootParent->DrawOnNC)
817 | {
818 | hdc = GetWindowDC(ezWnd->hParent);
819 | }
820 | else
821 | {*/
822 | hdc = GetDC(ezWnd->hParent);
823 | /* }*/
824 |
825 | //BitBlt(hdcg, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->hdc, Countx, County, SRCCOPY);
826 | BitBlt(hdc, ezWnd->px, ezWnd->py, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
827 | ReleaseDC(ezWnd->hParent, hdc);
828 | hdc = NULL;
829 | }
830 | else
831 | {
832 | //BitBlt(hdc, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->hdc, Countx, County, SRCCOPY);
833 | BitBlt(hdc, ezWnd->px, ezWnd->py, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
834 | }
835 |
836 | BitBlt(ezWnd->ezRootParent->TopWndExtend->hdcTop,
837 | ezWnd->px - ezWnd->ScrollX,
838 | ezWnd->py - ezWnd->ScrollY,
839 | ezWnd->Width, ezWnd->Height,
840 | ezWnd->hdc,
841 | 0,
842 | 0, SRCCOPY);
843 |
844 | /*
845 | RECT rect;
846 | rect.left = Countx;
847 | rect.right = Countx + ezWnd->Width;
848 | rect.top = County;
849 | rect.bottom = County + ezWnd->Height;
850 |
851 | InvalidateRect(ezWnd->hParent, &rect, 0);
852 | */
853 | return 0;
854 | }
855 |
856 | BOOL EZRepaint(EZWND ezWnd, HDC hdc)
857 | {
858 | if (!ezWnd)
859 | {
860 | return FALSE;
861 | }
862 | if (ezWnd->ShowState == 2)
863 | {
864 | return TRUE;
865 | }
866 |
867 | RECT rect;
868 |
869 | EZWND WndNow = ezWnd;
870 |
871 | while (WndNow)
872 | {
873 | if (WndNow->ShowState == 2)
874 | {
875 | return 0;
876 | }
877 | //向上推,直到父窗口
878 | WndNow = WndNow->ezParent;
879 | }
880 |
881 | rect.left = ezWnd->px;
882 | rect.right = ezWnd->px + ezWnd->Width;
883 | rect.top = ezWnd->py;
884 | rect.bottom = ezWnd->py + ezWnd->Height;
885 |
886 | BroadcastProc(ezWnd->ezRootParent, SEZWM_REDRAW, (WPARAM)NULL, (LPARAM)NULL);
887 | BOOL bFound = 0;
888 | RedrawBroadcast(ezWnd->ezRootParent, 0, 0, 0, 0, rect);
889 | BroadcastProc(ezWnd->ezRootParent, SEZWM_COPYDC, (WPARAM)NULL, (LPARAM)NULL);
890 |
891 | EZSendMessage(ezWnd->ezRootParent, EZWM_MAPDC, &rect, ezWnd);
892 |
893 | if (hdc)
894 | {
895 | // BitBlt(hdc, ezWnd->px - ezWnd->ScrollX, ezWnd->py - ezWnd->ScrollY, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
896 | BitBlt(hdc, 0, 0, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
897 | }
898 | else//没DC
899 | {
900 | /*if (ezWnd->ezRootParent->DrawOnNC)
901 | {
902 | hdc = GetWindowDC(ezWnd->hParent);
903 | }
904 | else
905 | {*/
906 | hdc = GetDC(ezWnd->hParent);
907 | /*}
908 | */
909 |
910 | //
911 |
912 | // if (EZSendMessage(ezWnd, EZWM_MAPDC, hdc, MAKELPARAM(ezWnd->px - ezWnd->ScrollX, ezWnd->py - ezWnd->ScrollY)) == 0)
913 | {
914 | //BitBlt(hdc, ezWnd->px, ezWnd->py, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
915 | StretchBlt(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
916 | ezWnd->ezRootParent->hdc, ezWnd->px, ezWnd->py, ezWnd->Width, ezWnd->Height, SRCCOPY);
917 | }
918 |
919 | ReleaseDC(ezWnd->hParent, hdc);
920 | }
921 |
922 |
923 | // if (EZSendMessage(ezWnd, EZWM_MAPDC, ezWnd->ezRootParent->TopWndExtend->hdcTop, MAKELPARAM(ezWnd->px - ezWnd->ScrollX, ezWnd->py - ezWnd->ScrollY)) == 0)
924 | {
925 | //BitBlt(ezWnd->ezRootParent->TopWndExtend->hdcTop, ezWnd->px, ezWnd->py, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
926 | StretchBlt(ezWnd->ezRootParent->TopWndExtend->hdcTop, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
927 | ezWnd->ezRootParent->hdc, ezWnd->px, ezWnd->py, ezWnd->Width, ezWnd->Height, SRCCOPY);
928 | }
929 |
930 | EZSendMessage(ezWnd, EZWM_REDRAWFINISH, 0, 0);//自由映射时间到
931 | return 0;
932 | }
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 | ////与窗口绘制有关的函数
941 | //BOOL EZRedraw(EZWND ezWnd)//重绘到内存dc,不更新。
942 | //{
943 | // //这里,我们需要先确定需要重绘的范围
944 | //
945 | // /*
946 | // 在整个大窗口体系下
947 | // 任何和该窗口有范围重复的窗口
948 | // 全!部!需!要!重绘!!!!
949 | //
950 | // 所以,我们要向所有窗口,包括子窗口广播消息。任何有重复的窗口,全部需要重绘到内存
951 | // 然后进行叠加处理。
952 | //
953 | // 不需要重绘到Windows父窗口。
954 | //
955 | // */
956 | //
957 | // if (!IsEZWindow(ezWnd))
958 | // {
959 | // return FALSE;
960 | // }
961 | // RECT rect;
962 | //
963 | // int Countx = 0, County = 0;
964 | //
965 | // EZWND WndNow = ezWnd;
966 | //
967 | //
968 | // //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
969 | // while (!WndNow->IsTopWindow)
970 | // {
971 | // //向上推,直到父窗口
972 | // Countx += WndNow->x + WndNow->ScrollX;
973 | // County += WndNow->y + WndNow->ScrollY;
974 | // WndNow = WndNow->ezParent;
975 | //
976 | // }
977 | //
978 | // rect.left = Countx;
979 | // rect.right = Countx + ezWnd->Width;
980 | // rect.top = County;
981 | // rect.bottom = County + ezWnd->Height;
982 | //
983 | //
984 | // //BroadcastProc(ezWnd->ezRootParent, SEZWM_REDRAW, (WPARAM)NULL, (LPARAM)NULL);
985 | // //RedrawBroadcast(ezWnd->ezRootParent, 0, 0, 0, 0, rect);
986 | // BroadcastProc(ezWnd, SEZWM_REDRAW, (WPARAM)NULL, (LPARAM)NULL);
987 | // RedrawBroadcast(ezWnd, 0, 0, 0, 0, rect);
988 | //
989 | // /*BitBlt(ezWnd->ezRootParent->TopWndExtend->hdcTop,
990 | // Countx,
991 | // County,
992 | // ezWnd->Width, ezWnd->Height,
993 | // ezWnd->ezRootParent->hdc,
994 | // Countx,
995 | // County, SRCCOPY);*/
996 | //
997 | //
998 | //
999 | // BitBlt(ezWnd->ezRootParent->TopWndExtend->hdcTop,
1000 | // Countx - ezWnd->ScrollX,
1001 | // County - ezWnd->ScrollY,
1002 | // ezWnd->Width, ezWnd->Height,
1003 | // ezWnd->hdc,
1004 | // 0,
1005 | // 0, SRCCOPY);
1006 | //
1007 | // // BroadcastProc(ezWnd->ezRootParent, SEZWM_COPYDC, (WPARAM)NULL, (LPARAM)NULL);
1008 | //
1009 | //
1010 | // return TRUE;
1011 | //}
1012 | //
1013 | //BOOL RedrawBroadcast(EZWND ezWnd, WPARAM wp, LPARAM lp, int cx, int cy, RECT RectSrc)
1014 | //{
1015 | //
1016 | // if (!IsEZWindow(ezWnd))
1017 | // {
1018 | // return FALSE;
1019 | // }
1020 | //
1021 | // if (IsEZWindow(ezWnd->FirstChild))
1022 | // {
1023 | //
1024 | // EZWND LastChild;
1025 | //
1026 | // LastChild = (ezWnd)->FirstChild;
1027 | //
1028 | // while (1)
1029 | // {
1030 | // //正序,所以,先处理自己。
1031 | // RECT RectDst, RectAns;
1032 | //
1033 | // {
1034 | // RectDst.left = cx + LastChild->x;
1035 | // RectDst.right = RectDst.left + LastChild->Width;
1036 | // RectDst.top = cy + LastChild->y;
1037 | // RectDst.bottom = RectDst.top + LastChild->Height;
1038 | // }
1039 | //
1040 | // if ((IntersectRect(&RectAns, &RectSrc, &RectDst) != 0) && (LastChild->ShowState != 2))
1041 | // {
1042 | // BroadcastProc(LastChild, SEZWM_REDRAW, wp, lp);//处理自己
1043 | //
1044 | // RedrawBroadcast(LastChild, wp, lp, cx + LastChild->x + LastChild->ScrollX, cy + LastChild->y + LastChild->ScrollY, RectSrc);//给自己的子窗口发送该消息
1045 | //
1046 | // BroadcastProc(LastChild, SEZWM_COPYDC, wp, lp);//处理自己
1047 | // }
1048 | //
1049 | // if (!IsEZWindow(LastChild->NextEZWnd))//没有下一个
1050 | // {
1051 | // break;//没有下一个了
1052 | // }
1053 | //
1054 | // LastChild = LastChild->NextEZWnd;//向下滚
1055 | //
1056 | // }
1057 | //
1058 | // }
1059 | // return TRUE;
1060 | //}
1061 | //
1062 | //BOOL EZUpdate(EZWND ezWnd, HDC hdc)//将DC更新到窗体,不重绘。第二个参数是DC,如不提供,函数将自动获取。
1063 | //{
1064 | // //找到你的“祖宗”、
1065 | //
1066 | // int Countx = 0, County = 0;
1067 | //
1068 | // EZWND WndNow = ezWnd;
1069 | //
1070 | // if (!IsEZWindow(ezWnd))
1071 | // {
1072 | // return FALSE;
1073 | // }
1074 | //
1075 | // //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
1076 | // while (!WndNow->IsTopWindow)
1077 | // {
1078 | // //向上推,直到父窗口
1079 | // Countx += WndNow->x + WndNow->ScrollX;
1080 | // County += WndNow->y + WndNow->ScrollY;
1081 | // WndNow = WndNow->ezParent;
1082 | // }
1083 | //
1084 | // ////EZBroadcastToAllChild(ezWnd, TRUE, SEZWM_COPYDC, (WPARAM)NULL, (LPARAM)NULL);
1085 | //
1086 | // /*
1087 | // if (!hdc)//没DC
1088 | // {
1089 | // HDC hdcg;
1090 | // hdcg = GetDC(EZGetTopParentWindow(ezWnd)->hParent);
1091 | // //BitBlt(hdcg, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->hdc, Countx, County, SRCCOPY);
1092 | // BitBlt(hdcg, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->TopWndExtend->hdcTop, Countx, County, SRCCOPY);
1093 | // ReleaseDC(EZGetTopParentWindow(ezWnd)->hParent, hdcg);
1094 | // }
1095 | // else
1096 | // {
1097 | // //BitBlt(hdc, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->hdc, Countx, County, SRCCOPY);
1098 | // BitBlt(hdc, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->TopWndExtend->hdcTop, Countx, County, SRCCOPY);
1099 | // }
1100 | //
1101 | // */
1102 | //
1103 | //
1104 | // if (!hdc)//没DC
1105 | // {
1106 | //
1107 | // hdc = GetDC(EZGetTopParentWindow(ezWnd)->hParent);
1108 | // //BitBlt(hdcg, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->hdc, Countx, County, SRCCOPY);
1109 | // BitBlt(hdc, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
1110 | // ReleaseDC(EZGetTopParentWindow(ezWnd)->hParent, hdc);
1111 | // hdc = NULL;
1112 | // }
1113 | // else
1114 | // {
1115 | // //BitBlt(hdc, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->ezRootParent->hdc, Countx, County, SRCCOPY);
1116 | // BitBlt(hdc, Countx, County, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
1117 | // }
1118 | //
1119 | // //RECT rect;
1120 | // //rect.left = Countx;
1121 | // //rect.right = Countx + ezWnd->Width;
1122 | // //rect.top = County;
1123 | // //rect.bottom = County + ezWnd->Height;
1124 | //
1125 | // //InvalidateRect(ezWnd->hParent, &rect, 0);
1126 | // return 0;
1127 | //}
1128 |
1129 |
1130 | //计时器函数
1131 | int SetEZTimer(EZWND ezWnd, int iTimeSpace)
1132 | {
1133 | //申请计时器,在顶部窗口的计时器中找到一个空位,写入信息,返回分配的ID。
1134 | int i;
1135 | for (i = 0; i < MAX_EZ_TIMER; i++)
1136 | {
1137 | if (ezWnd->ezRootParent->TopWndExtend->Timer[i].ezWnd == NULL)
1138 | {
1139 | //写入信息
1140 | ezWnd->ezRootParent->TopWndExtend->Timer[i].ezWnd = ezWnd;
1141 |
1142 | //int IDGet = SetTimer(NULL, 0, iTimeSpace, ezInsideTimerProc);
1143 | //KillTimer(0, IDGet);
1144 |
1145 | ezWnd->ezRootParent->TopWndExtend->Timer[i].WinTimerID = SetTimer(ezWnd->hParent, i + EZTIMER_BASE, iTimeSpace, ezInsideTimerProc);
1146 |
1147 | return i;
1148 | }
1149 | }
1150 | return -1;
1151 |
1152 | }
1153 |
1154 | BOOL KillEZTimer(EZWND ezWnd, int TimerID)
1155 | {
1156 | //删除信息
1157 | if (ezWnd->ezRootParent->TopWndExtend->Timer[TimerID].WinTimerID == -1)return -1;
1158 | if (ezWnd->ezRootParent->TopWndExtend->Timer[TimerID].ezWnd != NULL)
1159 | {
1160 | KillTimer(ezWnd->hParent, ezWnd->ezRootParent->TopWndExtend->Timer[TimerID].WinTimerID);
1161 | ezWnd->ezRootParent->TopWndExtend->Timer[TimerID].ezWnd = NULL;
1162 | ezWnd->ezRootParent->TopWndExtend->Timer[TimerID].WinTimerID = 0;
1163 | return 0;
1164 | }
1165 | else
1166 | {
1167 | return -1;
1168 | }
1169 | }
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 | //光标函数
1177 | BOOL EZCreateCaret(EZWND ezWnd, HBITMAP hBitmap, int nWidth, int nHeight)
1178 | {
1179 | return CreateCaret(ezWnd->hParent, hBitmap, nWidth, nHeight);
1180 | }
1181 |
1182 | BOOL EZSetCaretPos(EZWND ezWnd, int x, int y)
1183 | {
1184 | //TODO:检测是否超出窗口显示边界。
1185 | return SetCaretPos(ezWnd->px + x, ezWnd->py + y);
1186 | }
1187 |
1188 | BOOL EZShowCaret(EZWND ezWnd)
1189 | {
1190 | return ShowCaret(ezWnd->hParent);
1191 | }
1192 |
1193 | BOOL EZHideCaret(EZWND ezWnd)
1194 | {
1195 | return HideCaret(ezWnd->hParent);
1196 | }
1197 |
1198 | BOOL EZDestroyCaret()
1199 | {
1200 | DestroyCaret();
1201 | }
1202 |
1203 | //弹出对话框函数
1204 |
1205 | typedef struct tagDlgMaskHookExtend
1206 | {
1207 | BOOL bCenter;
1208 | pEZSE OldExtend;
1209 | EZWNDPROC OldProc;
1210 | EZWND Mask, Dialog;
1211 |
1212 | }DlgMaskHookExtend;
1213 |
1214 |
1215 | EZWND EZDialogBox(EZWND ezParent, int x, int y, int w, int h, DWORD Style, COLORREF MaskClr, EZWNDPROC ezWndProc)
1216 | {
1217 | EZWND Mask;
1218 | EZWND Dialog;
1219 | BOOL bMask, bCenter;
1220 | bMask = Style & EZDLG_MASK;
1221 | bCenter = Style & EZDLG_CENTER;
1222 |
1223 | //我们需要拦截一些消息,比如父窗口大小改变之类的
1224 | DlgMaskHookExtend* DlgMskHkExtend;
1225 | DlgMskHkExtend = malloc(sizeof(DlgMaskHookExtend));
1226 | DlgMskHkExtend->OldExtend = ezParent->Extend;
1227 | DlgMskHkExtend->OldProc = ezParent->ezWndProc;
1228 | DlgMskHkExtend->bCenter = bCenter;
1229 | ezParent->Extend = DlgMskHkExtend;
1230 | ezParent->ezWndProc = EZDlgHookProc;
1231 | DlgMskHkExtend->Mask = 0;
1232 | if (ezParent)
1233 | {
1234 |
1235 | Mask = CreateEZWindow(ezParent, 0, 0, ezParent->Width, ezParent->Height, EZDialogBoxMask);
1236 | DlgMskHkExtend->Mask = Mask;
1237 | EZSendMessage(Mask, EZWM_USER_NOTIFY, 0, MaskClr);
1238 | if (bMask)
1239 | {
1240 | EZSendMessage(Mask, EZWM_USER_NOTIFY, 1, 1);//打开(or打开ing)Mask
1241 | }
1242 | if (bCenter)
1243 | {
1244 | x = (ezParent->Width - w) / 2;
1245 | y = (ezParent->Height - h) / 2;
1246 |
1247 | }
1248 | Dialog = CreateEZWindow(ezParent, x, y, w, h, ezWndProc);
1249 | DlgMskHkExtend->Dialog = Dialog;
1250 | if (bMask)
1251 | {
1252 | EZSendMessage(Mask, EZWM_USER_NOTIFY, 2, Dialog);//设置Dialog
1253 | }
1254 | }
1255 | EZRepaint(ezParent, 0);
1256 | }
1257 |
1258 |
1259 | BOOL EZEndDialog(EZWND ezWnd)
1260 | {
1261 |
1262 | EZWND ezParent = ezWnd->ezParent;
1263 |
1264 | //注意,传入的是对话框句柄
1265 | //首先还原父窗口的Extend和WndProc,接下来标记Mask渐变,(完成后自删除)鼠标消息透明,并删除生成的Dialog
1266 | DlgMaskHookExtend* NewExt = ezParent->Extend;
1267 |
1268 | ezParent->Extend = NewExt->OldExtend;
1269 | ezParent->ezWndProc = NewExt->OldProc;
1270 | if (NewExt->Mask)
1271 | {
1272 |
1273 | EZSendMessage(NewExt->Mask, EZWM_USER_NOTIFY, 1, 0);//关闭Mask
1274 | NewExt->Mask->MouseMsgRecv = 2;
1275 | }
1276 | DestroyEZWindow(ezWnd);
1277 | free(NewExt);
1278 | //EZRepaint(ezParent->ezRootParent, 0);
1279 | InvalidateRect(ezParent->hParent, 0, 1);
1280 | return 0;
1281 | }
1282 |
1283 |
1284 | EZWNDPROC EZDlgHookProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
1285 | {
1286 | int iRet;
1287 | DlgMaskHookExtend* NewExt = ezWnd->Extend;
1288 |
1289 | if (message == EZWM_DESTROY)
1290 | {
1291 | //这个时候,子窗口应该删干净了。Mask的内存也该释放完了
1292 |
1293 | ezWnd->Extend = NewExt->OldExtend;//恢复成原来的Extend
1294 | //发送给原来的窗口过程
1295 | ezWnd->ezWndProc = NewExt->OldProc;
1296 | free(NewExt);
1297 | return EZSendMessage(ezWnd, message, wParam, lParam);
1298 | }
1299 | if (message == EZWM_SIZE)
1300 | {
1301 | //处理一下
1302 | MoveEZWindow(NewExt->Mask, 0, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0);
1303 | if (NewExt->bCenter)
1304 | {
1305 | MoveEZWindow(NewExt->Dialog,
1306 | (GET_X_LPARAM(lParam) - NewExt->Dialog->Width) >> 1,
1307 | (GET_Y_LPARAM(lParam) - NewExt->Dialog->Height) >> 1, NewExt->Dialog->Width, NewExt->Dialog->Height, 0);
1308 | }
1309 | //EZRepaint(ezWnd, 0);
1310 |
1311 | }
1312 |
1313 | ezWnd->Extend = NewExt->OldExtend;//恢复成原来的Extend
1314 | //发送给原来的窗口过程
1315 | //如果说这条消息引发了别的消息,而窗口过程钩子没有卸下来,引发的消息还会传到这里,但是这时候Extend已经是卸下来的状态了,就会gg。考虑到EZWM_SIZE很少会引发自身被size(那不就是死循环了吗),所以这里暂时还原窗口过程
1316 | ezWnd->ezWndProc = NewExt->OldProc;
1317 | iRet = NewExt->OldProc(ezWnd, message, wParam, lParam);
1318 | //还原
1319 | ezWnd->ezWndProc = EZDlgHookProc;
1320 | ezWnd->Extend = NewExt;
1321 | return iRet;
1322 | }
1323 |
1324 | EZWNDPROC EZDialogBoxMask(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
1325 | {
1326 | struct tagDialogBoxMaskInfo {
1327 | int MaskOpen;
1328 | int TimerID;
1329 | BOOL MouseHold;
1330 | EZWND Dialog;
1331 | HBRUSH hBrush;
1332 | } *DlgMaskInfo = 0;
1333 |
1334 | if (message != EZWM_CREATE)
1335 | {
1336 | DlgMaskInfo = ezWnd->Extend;
1337 | }
1338 | switch (message)
1339 | {
1340 | case EZWM_CREATE:
1341 | DlgMaskInfo = ezWnd->Extend = malloc(sizeof(struct tagDialogBoxMaskInfo));
1342 | DlgMaskInfo->hBrush = CreateSolidBrush(RGB(0, 0, 0));
1343 | DlgMaskInfo->MaskOpen = 0;
1344 | DlgMaskInfo->TimerID = -1;
1345 | DlgMaskInfo->Dialog = 0;
1346 | ezWnd->Transparent = 0;
1347 | DlgMaskInfo->MouseHold = 0;
1348 | return 0;
1349 |
1350 | case EZWM_USER_NOTIFY:
1351 | if (wParam == 0)//设置颜色
1352 | {
1353 | DeleteObject(DlgMaskInfo->hBrush);
1354 | DlgMaskInfo->hBrush = CreateSolidBrush(lParam);
1355 | EZRepaint(ezWnd, 0);
1356 | return 0;
1357 | }
1358 | if (wParam == 1)
1359 | {
1360 | //有关Mask开关
1361 | // DlgMaskInfo->MaskOpen = lParam;
1362 | if (lParam)//打开Mask
1363 | {
1364 | if (DlgMaskInfo->MaskOpen == 0)
1365 | {
1366 | DlgMaskInfo->MaskOpen = 1;
1367 | if (DlgMaskInfo->TimerID == -1)
1368 | {
1369 | DlgMaskInfo->TimerID = SetEZTimer(ezWnd, 40);
1370 | }
1371 |
1372 | }
1373 | }
1374 | else//关闭Mask
1375 | {
1376 | if (DlgMaskInfo->MaskOpen == 1)
1377 | {
1378 | DlgMaskInfo->MaskOpen = 0;
1379 | if (DlgMaskInfo->TimerID == -1)
1380 | {
1381 | DlgMaskInfo->TimerID = SetEZTimer(ezWnd, 40);
1382 | }
1383 |
1384 | }
1385 | }
1386 | return 0;
1387 | }
1388 | if (wParam == 2)
1389 | {
1390 | DlgMaskInfo->Dialog = lParam;
1391 | }
1392 | case EZWM_LBUTTONDOWN:
1393 | DlgMaskInfo->MouseHold = 1;
1394 | EZCaptureMouse(ezWnd);
1395 | return 0;
1396 | case EZWM_LBUTTONUP:
1397 | if (DlgMaskInfo->MouseHold == 1)
1398 | {
1399 | EZReleaseMouse(ezWnd);
1400 | DlgMaskInfo->MouseHold = 0;
1401 | if (DlgMaskInfo->Dialog)
1402 | {
1403 | EZSendMessage(DlgMaskInfo->Dialog, EZWM_COMMAND, 0, ezWnd);
1404 | }
1405 | }
1406 |
1407 | return 0;
1408 | case EZWM_TIMER:
1409 | if (DlgMaskInfo->MaskOpen)
1410 | {
1411 | if (ezWnd->Transparent + 16 >= 64)
1412 | {
1413 | ezWnd->Transparent = 64;
1414 | KillEZTimer(ezWnd, DlgMaskInfo->TimerID);
1415 | DlgMaskInfo->TimerID = -1;
1416 | }
1417 | else
1418 | {
1419 | ezWnd->Transparent += 16;
1420 | }
1421 | }
1422 | else
1423 | {
1424 | //正在关闭ing
1425 | if (ezWnd->Transparent - 16 <= 0)
1426 | {
1427 | ezWnd->Transparent = 0;
1428 | KillEZTimer(ezWnd, DlgMaskInfo->TimerID);
1429 | DlgMaskInfo->TimerID = -1;
1430 | EZRepaint(ezWnd->ezParent, 0);
1431 | //自删除
1432 |
1433 | DestroyEZWindow(ezWnd);
1434 | return 0;//避免调用EZRepaint
1435 | }
1436 | else
1437 | {
1438 | ezWnd->Transparent -= 16;
1439 | }
1440 | }
1441 |
1442 | EZRepaint(ezWnd->ezParent, 0);
1443 | //临时操作
1444 | /* if (DlgMaskInfo->Dialog)
1445 | {
1446 | EZUpdate(DlgMaskInfo->Dialog, 0);
1447 | }*/
1448 |
1449 | return 0;
1450 |
1451 | case EZWM_TRANSDRAW:
1452 | SelectObject(wParam, DlgMaskInfo->hBrush);
1453 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, PATCOPY);
1454 | return 0;
1455 |
1456 | case EZWM_DESTROY:
1457 | DeleteObject(DlgMaskInfo->hBrush);
1458 |
1459 | if (DlgMaskInfo->TimerID != -1)
1460 | {
1461 | KillEZTimer(ezWnd, DlgMaskInfo->TimerID);
1462 | DlgMaskInfo->TimerID = -1;
1463 | }
1464 |
1465 | free(DlgMaskInfo);
1466 |
1467 | return 0;
1468 | }
1469 | return 0;
1470 | }
1471 |
1472 | //内部函数
1473 | LRESULT CALLBACK EZParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
1474 | {
1475 | HDC hdc;
1476 | PAINTSTRUCT ps;
1477 | TRACKMOUSEEVENT tme;
1478 |
1479 | EZWND ezWnd;
1480 |
1481 | if (message != WM_CREATE)
1482 | {
1483 | ezWnd = ((EZWND)GetWindowLongPtr(hwnd, 0));
1484 | if (ezWnd == NULL)
1485 | {
1486 | return DefWindowProc(hwnd, message, wParam, lParam);
1487 | }
1488 | }
1489 | else
1490 | {
1491 | ezWnd = NULL;
1492 | }
1493 | switch (message)
1494 | {
1495 | case WM_CREATE:
1496 | {
1497 | ezWnd = (EZWND)(((LPCREATESTRUCT)lParam)->lpCreateParams);
1498 | SetWindowLongPtr(hwnd, 0, (LONG_PTR)ezWnd);
1499 | ezWnd->hParent = hwnd;//设置Win父窗口
1500 |
1501 | //HDC fhdc;
1502 | //其实,本应该用这个变量.但是?hdc变量现在不正闲着吗???干脆就用那个吧,省内存
1503 | //ezWnd->DrawOnNC = 0;
1504 |
1505 | hdc = GetDC(hwnd);
1506 | ezWnd->hdc = GetMemDC(hdc, ezWnd->Width, ezWnd->Height);
1507 | // ezWnd->hdcCopy = GetMemDC(hdc, ezWnd->Width, ezWnd->Height);
1508 | ezWnd->TopWndExtend->hdcTop = GetMemDC(hdc, ezWnd->Width, ezWnd->Height);
1509 | ezWnd->bOpaque = 0;
1510 |
1511 | ReleaseDC(hwnd, hdc);
1512 |
1513 | EZSendMessage(ezWnd, EZWM_CREATE, 0, 0);//发送创建消息
1514 |
1515 | return 0;
1516 |
1517 | }
1518 |
1519 | case WM_MOVE:
1520 | {
1521 | ezWnd->x = GET_X_LPARAM(lParam);
1522 | ezWnd->y = GET_Y_LPARAM(lParam);
1523 | return 0;
1524 | }
1525 |
1526 | case WM_SIZE:
1527 | {
1528 | /*if (ezWnd->DrawOnNC)
1529 | {
1530 | RECT rect;
1531 | GetWindowRect(hwnd, &rect);
1532 | ezWnd->Width = rect.right - rect.left;
1533 | ezWnd->Height = rect.bottom - rect.top;
1534 | }
1535 | else*/
1536 | {
1537 | ezWnd->Width = GET_X_LPARAM(lParam);
1538 | ezWnd->Height = GET_Y_LPARAM(lParam);
1539 | }
1540 |
1541 |
1542 | //DeleteMemDC(ezWnd->hdc);
1543 | //DeleteMemDC(ezWnd->hdcCopy);
1544 | //DeleteMemDC(ezWnd->TopWndExtend->hdcTop);
1545 |
1546 | //HDC fhdc;
1547 | //其实,本应该用这个变量.但是?hdc变量现在不正闲着吗???干脆就用那个吧,省内存
1548 |
1549 | // hdc = GetDC(hwnd);
1550 | /*ezWnd->hdc = GetMemDC(hdc, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1551 | ezWnd->hdcCopy = GetMemDC(hdc, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1552 | ezWnd->TopWndExtend->hdcTop = GetMemDC(hdc, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));*/
1553 |
1554 | //ReleaseDC(hwnd, hdc);
1555 | hdc = GetDC(hwnd);
1556 | AdjustMemDC(ezWnd->hdc, hdc, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1557 | // AdjustMemDC(ezWnd->hdcCopy, hdc, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1558 | AdjustMemDC(ezWnd->TopWndExtend->hdcTop, hdc, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1559 | ReleaseDC(hwnd, hdc);
1560 | EZSendMessage(ezWnd, EZWM_SIZE, wParam, lParam);
1561 |
1562 | EZRepaint(ezWnd, NULL);
1563 |
1564 | return 0;
1565 |
1566 | }
1567 |
1568 | case WM_LBUTTONDOWN:
1569 | {
1570 | if (IsEZWindow(ezWnd->TopWndExtend->CptMouseWindow))
1571 | {
1572 | //从这个窗口向上滚,找到这个窗口的坐标
1573 | EZWND WndNow = ezWnd->TopWndExtend->CptMouseWindow;
1574 |
1575 | int Countx = 0, County = 0;
1576 | //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
1577 | while (!WndNow->IsTopWindow)
1578 | {
1579 | //向上推,直到父窗口
1580 | Countx += WndNow->x + WndNow->ScrollX;
1581 | County += WndNow->y + WndNow->ScrollY;
1582 | WndNow = WndNow->ezParent;
1583 | }
1584 | ezInsideWndProc(ezWnd->TopWndExtend->CptMouseWindow, EZWM_LBUTTONDOWN, wParam,
1585 | MAKELPARAM(LOWORD(lParam) - Countx, HIWORD(lParam) - County));
1586 | return 0;
1587 | }
1588 | ezInsideWndProc(ezWnd, EZWM_LBUTTONDOWN, wParam,
1589 | MAKELPARAM(LOWORD(lParam) - ezWnd->ScrollX, HIWORD(lParam) - ezWnd->ScrollY));
1590 | return 0;
1591 |
1592 | }
1593 |
1594 | case WM_LBUTTONUP:
1595 | {
1596 | if (IsEZWindow(ezWnd->TopWndExtend->CptMouseWindow))
1597 | {
1598 | //从这个窗口向上滚,找到这个窗口的坐标
1599 | EZWND WndNow = ezWnd->TopWndExtend->CptMouseWindow;
1600 |
1601 | int Countx = 0, County = 0;
1602 | //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
1603 | while (!WndNow->IsTopWindow)
1604 | {
1605 | //向上推,直到父窗口
1606 | Countx += WndNow->x + WndNow->ScrollX;
1607 | County += WndNow->y + WndNow->ScrollY;
1608 | WndNow = WndNow->ezParent;
1609 | }
1610 | ezInsideWndProc(ezWnd->TopWndExtend->CptMouseWindow, EZWM_LBUTTONUP, wParam,
1611 | MAKELPARAM(LOWORD(lParam) - Countx, HIWORD(lParam) - County));
1612 | return 0;
1613 | }
1614 | ezInsideWndProc(ezWnd, EZWM_LBUTTONUP, wParam,
1615 | MAKELPARAM(LOWORD(lParam) - ezWnd->ScrollX, HIWORD(lParam) - ezWnd->ScrollY));
1616 | return 0;
1617 | }
1618 |
1619 | case WM_RBUTTONDOWN:
1620 | {
1621 | if (IsEZWindow(ezWnd->TopWndExtend->CptMouseWindow))
1622 | {
1623 | //从这个窗口向上滚,找到这个窗口的坐标
1624 | EZWND WndNow = ezWnd->TopWndExtend->CptMouseWindow;
1625 |
1626 | int Countx = 0, County = 0;
1627 | //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
1628 | while (!WndNow->IsTopWindow)
1629 | {
1630 | //向上推,直到父窗口
1631 | Countx += WndNow->x + WndNow->ScrollX;
1632 | County += WndNow->y + WndNow->ScrollY;
1633 | WndNow = WndNow->ezParent;
1634 | }
1635 | ezInsideWndProc(ezWnd->TopWndExtend->CptMouseWindow, EZWM_RBUTTONDOWN, wParam,
1636 | MAKELPARAM(LOWORD(lParam) - Countx, HIWORD(lParam) - County));
1637 | return 0;
1638 | }
1639 | ezInsideWndProc(ezWnd, EZWM_RBUTTONDOWN, wParam,
1640 | MAKELPARAM(LOWORD(lParam) - ezWnd->ScrollX, HIWORD(lParam) - ezWnd->ScrollY));
1641 | return 0;
1642 |
1643 | }
1644 |
1645 | case WM_RBUTTONUP:
1646 | {
1647 | if (IsEZWindow(ezWnd->TopWndExtend->CptMouseWindow))
1648 | {
1649 | //从这个窗口向上滚,找到这个窗口的坐标
1650 | EZWND WndNow = ezWnd->TopWndExtend->CptMouseWindow;
1651 |
1652 | int Countx = 0, County = 0;
1653 | //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
1654 | while (!WndNow->IsTopWindow)
1655 | {
1656 | //向上推,直到父窗口
1657 | Countx += WndNow->x + WndNow->ScrollX;
1658 | County += WndNow->y + WndNow->ScrollY;
1659 | WndNow = WndNow->ezParent;
1660 | }
1661 | ezInsideWndProc(ezWnd->TopWndExtend->CptMouseWindow, EZWM_RBUTTONUP, wParam,
1662 | MAKELPARAM(LOWORD(lParam) - Countx, HIWORD(lParam) - County));
1663 | return 0;
1664 | }
1665 | ezInsideWndProc(ezWnd, EZWM_RBUTTONUP, wParam,
1666 | MAKELPARAM(LOWORD(lParam) - ezWnd->ScrollX, HIWORD(lParam) - ezWnd->ScrollY));
1667 | return 0;
1668 |
1669 | }
1670 |
1671 | case WM_MOUSEMOVE:
1672 | {
1673 | //老鼠在跑来跑去。
1674 | if (ezWnd->MouseOn == FALSE)
1675 | {
1676 | //刚刚进来
1677 |
1678 | //可以进行监测了。
1679 | tme.cbSize = sizeof(TRACKMOUSEEVENT);
1680 | tme.dwFlags = TME_LEAVE;
1681 | tme.dwHoverTime = 0;
1682 | tme.hwndTrack = hwnd;
1683 | TrackMouseEvent(&tme);
1684 | }
1685 | if (IsEZWindow(ezWnd->TopWndExtend->CptMouseWindow))
1686 | {
1687 | //从这个窗口向上滚,找到这个窗口的坐标
1688 | EZWND WndNow = ezWnd->TopWndExtend->CptMouseWindow;
1689 |
1690 | int Countx = 0, County = 0;
1691 | //只需要把这个窗口(不需要全屏BitBlt),得到相对父窗口的位置
1692 | while (!WndNow->IsTopWindow)
1693 | {
1694 | //向上推,直到父窗口
1695 | Countx += WndNow->x + WndNow->ScrollX;
1696 | County += WndNow->y + WndNow->ScrollY;
1697 | WndNow = WndNow->ezParent;
1698 | }
1699 | ezInsideWndProc(ezWnd->TopWndExtend->CptMouseWindow, EZWM_MOUSEMOVE, wParam,
1700 | MAKELPARAM(LOWORD(lParam) - Countx, HIWORD(lParam) - County));
1701 | return 0;
1702 | }
1703 | ezInsideWndProc(ezWnd, EZWM_MOUSEMOVE, wParam,
1704 | MAKELPARAM(LOWORD(lParam) - ezWnd->ScrollX, HIWORD(lParam) - ezWnd->ScrollY));
1705 | return 0;
1706 |
1707 | }
1708 |
1709 | case WM_CAPTURECHANGED:
1710 | {
1711 | //EZReleaseMouse(((EZWND)GetWindowLongPtr(hwnd, 0))->CptMouseWindow);
1712 | //上面这个不行,因为这个函数还会重复调用ReleaseCapture.
1713 |
1714 | //把上面这个函数里面的内容拷下来改一改就可以了
1715 |
1716 |
1717 | if (ezWnd->TopWndExtend->CptMouseWindow)
1718 | {
1719 | EZSendMessage(ezWnd->TopWndExtend->CptMouseWindow, EZWM_RELEASEMOUSE, 0, 0);
1720 | ezWnd->TopWndExtend->CptMouseWindow = NULL;
1721 |
1722 | }
1723 |
1724 |
1725 | return 0;
1726 | }
1727 |
1728 | case WM_MOUSELEAVE:
1729 | {
1730 |
1731 | //呀,老鼠跑了~~~ 广播一下,让每个子窗口看看是不是从自己那里溜出去的。
1732 | //先检查自己。
1733 | if (ezWnd->TopWndExtend->MouseOnWnd)
1734 | {
1735 | ezWnd->TopWndExtend->MouseOnWnd->MouseOn = FALSE;
1736 | EZSendMessage(ezWnd->TopWndExtend->MouseOnWnd, EZWM_MOUSELEAVE, 0, 0);
1737 | ezWnd->TopWndExtend->MouseOnWnd = NULL;
1738 | }
1739 |
1740 |
1741 | //BroadcastProc(ezWnd, SEZWM_MOUSELEAVE, (WPARAM)NULL, (LPARAM)NULL);
1742 | //EZBroadcastToAllChild(ezWnd, TRUE, SEZWM_MOUSELEAVE, (WPARAM)NULL, (LPARAM)NULL);
1743 |
1744 | //发送一个消息说明鼠标是整个从窗口出去了.....
1745 | //EZSendMessage(ezWnd, EZWM_MOUSELEAVE, (WPARAM)1, (LPARAM)NULL);
1746 | return 0;
1747 | }
1748 |
1749 | case WM_NCHITTEST:
1750 | {
1751 | int iHT;
1752 | iHT = EZSendMessage(ezWnd, EZWM_WINNCHITTEST, wParam, lParam);//只有主窗口才能收到 EZWM_WINNCHITTEST 消息
1753 | if (iHT == 0)
1754 | {
1755 | break;
1756 | }
1757 | if (iHT > 0)
1758 | {
1759 | return iHT;
1760 | }
1761 | if (iHT < 0)
1762 | {
1763 | return iHT + 1;
1764 | }
1765 |
1766 | }
1767 |
1768 |
1769 | case WM_ERASEBKGND:
1770 | {
1771 | //直接无视(我管你呢,反正正常的话,有ERASE就有PAINT)
1772 | return 1;
1773 | }
1774 |
1775 | case WM_NCPAINT:
1776 | {
1777 | //if (ezWnd->DrawOnNC)
1778 | //{
1779 | // hdc = GetWindowDC(hwnd);//GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW | DCX_INTERSECTRGN);
1780 | // BitBlt(hdc, 0, 0, ezWnd->Width, ezWnd->Height, ezWnd->TopWndExtend->hdcTop, 0,0, SRCCOPY);
1781 |
1782 | // ReleaseDC(hwnd, hdc);
1783 | // return 0;
1784 | //}
1785 | //else
1786 | //{
1787 | // break;
1788 | //}
1789 |
1790 | if (!EZSendMessage(ezWnd, EZWM_WINNCDRAW, wParam, lParam))
1791 | {
1792 | //为0,默认
1793 | break;
1794 | }
1795 | return 0;
1796 | }
1797 |
1798 | case WM_PAINT:
1799 | {
1800 |
1801 | //重绘区域无效啦!!!
1802 |
1803 | /*if (ezWnd->DrawOnNC)
1804 | {
1805 |
1806 | break;
1807 | }
1808 | else
1809 | {*/
1810 | hdc = BeginPaint(hwnd, &ps);
1811 |
1812 |
1813 | // 这里用无效矩形进行了优化
1814 | BitBlt(hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top, ezWnd->TopWndExtend->hdcTop, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);
1815 |
1816 |
1817 | EndPaint(hwnd, &ps);
1818 |
1819 | //好了,现在有效了。设置一下。
1820 | ezWnd->Update = 0;
1821 | return 0;
1822 | /*}*/
1823 |
1824 | }
1825 |
1826 | case WM_GETMINMAXINFO:
1827 | {
1828 | if (EZSendMessage(ezWnd, EZWM_GETMINMAXINFO, wParam, lParam))
1829 | {
1830 | return 0;
1831 | }
1832 | //返回值为0,交给默认
1833 | break;
1834 | }
1835 |
1836 | case WM_NCCALCSIZE:
1837 | {
1838 | int iRet = EZSendMessage(ezWnd, EZWM_WINNCCALCSIZE, wParam, lParam);
1839 | if (iRet == 0)
1840 | {
1841 | break;
1842 | }
1843 | else
1844 | {
1845 | return iRet - 1;
1846 | }
1847 | }
1848 |
1849 | case WM_ACTIVATE:
1850 | {
1851 | //return EZSendMessage(ezWnd, EZWM_ACTIVATE, wParam, lParam);
1852 | break;
1853 | }
1854 |
1855 | case WM_ACTIVATEAPP:
1856 | {
1857 | //return EZSendMessage(ezWnd, EZWM_ACTIVATEAPP, wParam, lParam);
1858 | break;
1859 | }
1860 |
1861 | case WM_NCACTIVATE:
1862 | {
1863 |
1864 | //MSDN - The DefWindowProc function draws the title bar or icon title in its active colors when the wParam parameter is TRUE and in its inactive colors when wParam is FALSE.
1865 | //绘制总归让人家绘制吧。。。返回值我也不想处理了于是就写成了这样
1866 |
1867 | int iRet = DefWindowProc(hwnd, message, wParam, lParam);
1868 | EZSendMessage(ezWnd, EZWM_WINNCACTIVATE, wParam, lParam);
1869 | return iRet;
1870 |
1871 | }
1872 |
1873 | case WM_CLOSE:
1874 | if (EZSendMessage(ezWnd, EZWM_CLOSE, 0, 0) != EZDO_NOT_CLOSE)
1875 | {
1876 | break;
1877 | }
1878 | return 0;
1879 |
1880 | case WM_DESTROY:
1881 | {
1882 | //先保存信息,倒推,消除所有子孙窗口
1883 | if (IsEZWindow(ezWnd->FirstChild))
1884 | {
1885 | EZWND FirstChildBuf = ezWnd->FirstChild;
1886 | ezWnd->FirstChild = 0;
1887 | DestroyEZWindowWithNext(FirstChildBuf);
1888 | }
1889 | //把你自己清理了
1890 | EZSendMessage(ezWnd, EZWM_DESTROY, (WPARAM)NULL, (LPARAM)NULL);//发送销毁信息
1891 | DeleteMemDC(ezWnd->hdc);//清理DC
1892 | // DeleteMemDC(ezWnd->hdcCopy);//清理DC
1893 | DeleteMemDC(ezWnd->TopWndExtend->hdcTop);
1894 |
1895 | free(ezWnd->TopWndExtend);
1896 | //问题是这样的:当Windows开始执行摧毁窗口时,这里会递归往下删除。而客户区子窗口发现父窗口是一个样式窗口后,就又要求父窗口删除且仅删除自己,
1897 | if (ezWnd->IsStyleWindow)
1898 | {
1899 | free(ezWnd->Extend);
1900 | }
1901 |
1902 | free(ezWnd);
1903 | SetWindowLongPtr(hwnd, 0, NULL);
1904 |
1905 | break;
1906 | }
1907 |
1908 | case WM_SETFOCUS:
1909 | //不需要处理,有窗口接收到单击后会自行处理。
1910 | return 0;
1911 |
1912 | case WM_KILLFOCUS:
1913 | //通知焦点窗口,失去焦点。
1914 | if (IsEZWindow(ezWnd->TopWndExtend->FocusWindow))
1915 | {
1916 | ezWnd->ezRootParent->TopWndExtend->FocusWindow->FocusState = 0;
1917 |
1918 | EZWND Buf = ezWnd->ezRootParent->TopWndExtend->FocusWindow;
1919 | ezWnd->ezRootParent->TopWndExtend->FocusWindow = NULL;
1920 |
1921 | EZSendMessage(Buf, EZWM_KILLFOCUS, 0, 0);
1922 |
1923 | }
1924 | return 0;
1925 |
1926 | case WM_CHAR:
1927 | case WM_KEYDOWN:
1928 | case WM_KEYUP:
1929 | if (ezWnd->TopWndExtend->FocusWindow != NULL)
1930 | {
1931 | switch (message)
1932 | {
1933 | case WM_CHAR:
1934 | EZSendMessage(ezWnd->TopWndExtend->FocusWindow, EZWM_CHAR, wParam, lParam);
1935 | return 0;
1936 | case WM_KEYDOWN:
1937 | EZSendMessage(ezWnd->TopWndExtend->FocusWindow, EZWM_KEYDOWN, wParam, lParam);
1938 | return 0;
1939 | case WM_KEYUP:
1940 | EZSendMessage(ezWnd->TopWndExtend->FocusWindow, EZWM_KEYUP, wParam, lParam);
1941 | return 0;
1942 | }
1943 |
1944 | }
1945 | return 0;
1946 |
1947 | }
1948 |
1949 | return DefWindowProc(hwnd, message, wParam, lParam);
1950 |
1951 | }
1952 |
1953 | VOID CALLBACK ezInsideTimerProc(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime)
1954 | {
1955 |
1956 | //在列表里找到对应的ezWnd,并转发EZWM_TIMER消息
1957 |
1958 | pTWE TopExtend = ((EZWND)GetWindowLongPtr(hwnd, 0))->TopWndExtend;
1959 |
1960 | EZSendMessage(TopExtend->Timer[iTimerID - EZTIMER_BASE].ezWnd, EZWM_TIMER, iTimerID - EZTIMER_BASE, 0);
1961 |
1962 | return;
1963 | }
1964 |
1965 | int ezInsideWndProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
1966 | {
1967 | //这里!修改函数,链表枚举方向应该反过来,先找到最后,然后返回来一个个检查。(保证和绘制的枚举顺序相同)
1968 | EZWND ezChildLast;
1969 |
1970 | ezChildLast = ezWnd->FirstChild;
1971 |
1972 | if (IsEZWindow(ezChildLast))
1973 | {
1974 |
1975 | while (ezChildLast->NextEZWnd)
1976 | {
1977 | ezChildLast = ezChildLast->NextEZWnd;
1978 | }
1979 |
1980 | //滚动到链表顶部,检查是否在子窗口内
1981 | //**************************************************
1982 | while (ezChildLast)
1983 | {
1984 | //检查是否在子窗口内,注意屏幕移动
1985 | //if (PtInEZWnd(ezChildLast, GET_X_LPARAM(lParam) - ezChildLast->ScrollX, GET_Y_LPARAM(lParam) - ezChildLast->ScrollY))
1986 | if ((ezChildLast->MouseMsgRecv != 2) && PtInEZWnd(ezChildLast, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
1987 | {
1988 | //可以了,在这个窗口
1989 | if (ezInsideWndProc(ezChildLast, message, wParam, MAKELPARAM(GET_X_LPARAM(lParam) - ezChildLast->x - ezChildLast->ScrollX, GET_Y_LPARAM(lParam) - ezChildLast->y - ezChildLast->ScrollY)) == TRANSPARENT)
1990 | {
1991 | //好吧,子窗口说他是透明的》。。。。。
1992 |
1993 | //先发送鼠标到来
1994 | //更改这里的时候,别忘了把下面相同的一起改了~~~~~
1995 | if (ezWnd->MouseOn == FALSE && message == EZWM_MOUSEMOVE)
1996 | {
1997 | if (ezWnd->ezRootParent->TopWndExtend->MouseOnWnd)
1998 | {
1999 | ezWnd->ezRootParent->TopWndExtend->MouseOnWnd->MouseOn = FALSE;//标记一下。
2000 | EZSendMessage(ezWnd->ezRootParent->TopWndExtend->MouseOnWnd, EZWM_MOUSELEAVE, 0, 0);
2001 | }
2002 | ezWnd->ezRootParent->TopWndExtend->MouseOnWnd = ezWnd;
2003 |
2004 | ezWnd->MouseOn = TRUE;//标记一下。
2005 | EZSendMessage(ezWnd, EZWM_MOUSECOME, (WPARAM)NULL, (LPARAM)NULL);//老鼠来了
2006 | }
2007 | else if (ezWnd->FocusState == 0 && message == EZWM_LBUTTONDOWN)//你没焦点,消息是左键
2008 | {
2009 | if (IsEZWindow(EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow))
2010 | {
2011 | EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow->FocusState = 0;//你没焦点了。
2012 | EZSendMessage(EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow, EZWM_KILLFOCUS, NULL, NULL);
2013 |
2014 | }
2015 | ezWnd->FocusState = 1;
2016 |
2017 | EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow = ezWnd;
2018 | EZSendMessage(ezWnd, EZWM_SETFOCUS, (WPARAM)NULL, (LPARAM)NULL);//你有焦点了!
2019 | }
2020 |
2021 | return EZSendMessage(ezWnd, message, wParam, lParam);
2022 | }
2023 | return 0;
2024 | }
2025 |
2026 | ezChildLast = ezChildLast->LastEZWnd;
2027 | }
2028 | //**************************************************
2029 |
2030 | //已经到最后了,那么,就是在主窗口。直接出去和外面的合并
2031 |
2032 | }
2033 |
2034 | {
2035 | //连个子窗口都没。。。那么,就在你这里了。
2036 |
2037 | //先发送鼠标到来消息
2038 | //更改这里的时候,别忘了把上面相同的一起改了~~~~~
2039 | if (message == EZWM_MOUSEMOVE && ezWnd->MouseOn == FALSE)
2040 | {
2041 | if (ezWnd->ezRootParent->TopWndExtend->MouseOnWnd)
2042 | {
2043 | ezWnd->ezRootParent->TopWndExtend->MouseOnWnd->MouseOn = FALSE;//标记一下。
2044 | EZSendMessage(ezWnd->ezRootParent->TopWndExtend->MouseOnWnd, EZWM_MOUSELEAVE, 0, 0);
2045 | }
2046 | ezWnd->ezRootParent->TopWndExtend->MouseOnWnd = ezWnd;
2047 | ezWnd->MouseOn = TRUE;//标记一下。
2048 | EZSendMessage(ezWnd, EZWM_MOUSECOME, (WPARAM)NULL, (LPARAM)NULL);//老鼠来了
2049 | }
2050 |
2051 | else if (ezWnd->FocusState == 0 && message == EZWM_LBUTTONDOWN)//你没焦点,消息是左键
2052 | {
2053 | if (IsEZWindow(EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow))
2054 | {
2055 | EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow->FocusState = 0;//你没焦点了。
2056 | EZSendMessage(EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow, EZWM_KILLFOCUS, NULL, NULL);
2057 | }
2058 | ezWnd->FocusState = 1;
2059 |
2060 | EZGetTopParentWindow(ezWnd)->TopWndExtend->FocusWindow = ezWnd;
2061 | EZSendMessage(ezWnd, EZWM_SETFOCUS, (WPARAM)NULL, (LPARAM)NULL);//你有焦点了!
2062 | }
2063 | return EZSendMessage(ezWnd, message, wParam, lParam);
2064 |
2065 | }
2066 | }
2067 |
2068 |
2069 |
2070 | BOOL EZBroadcastToAllChildFunc(EZWND ezWnd, BOOL sequence, int message, WPARAM wp, LPARAM lp)
2071 | {
2072 | //注意,这个函数是以深度优先的方式发送消息的。(我懒得再写一个广度优先的,如果以后我写了,删掉这一句话)
2073 | EZWND LastChild;
2074 |
2075 | LastChild = ezWnd->FirstChild;
2076 | //向回滚,如正序则直接处理,倒叙不处理。
2077 | for (;;)
2078 | {
2079 | if (sequence)//正
2080 | {
2081 | //正序,所以,先处理自己。
2082 | BroadcastProc(LastChild, message, wp, lp);//处理自己
2083 |
2084 | EZBroadcastToAllChild(LastChild, sequence, message, wp, lp);//给自己的子窗口发送该消息
2085 |
2086 | }
2087 |
2088 | if (!IsEZWindow(LastChild->NextEZWnd))//没有下一个
2089 | {
2090 | break;//没有下一个了
2091 | }
2092 |
2093 | LastChild = LastChild->NextEZWnd;//向下滚
2094 |
2095 | }
2096 |
2097 | //如果倒,那么再滚回去
2098 | if (!sequence)
2099 | {
2100 | for (;;)
2101 | {
2102 | //给自己的子窗口发送该消息
2103 | EZBroadcastToAllChild(LastChild, sequence, message, wp, lp);
2104 |
2105 | BroadcastProc(LastChild, message, wp, lp);//处理自己
2106 |
2107 | if (!IsEZWindow(LastChild->LastEZWnd))//到头了
2108 | {
2109 | break;
2110 | }
2111 |
2112 | LastChild = LastChild->LastEZWnd;//回滚
2113 |
2114 | }
2115 | }
2116 | return TRUE;
2117 | }
2118 |
2119 | BOOL BroadcastProc(EZWND ezWnd, int Param, WPARAM wP, LPARAM lP)
2120 | {
2121 | if (!IsEZWindow(ezWnd))
2122 | {
2123 | return FALSE;
2124 | }
2125 |
2126 | switch (Param)
2127 | {
2128 |
2129 |
2130 | case SEZWM_COPYDC:
2131 | {
2132 | EZSendMessage(ezWnd, EZWM_COVERCHILD, ezWnd->hdc, 0);
2133 | //看看是否是顶层EZ窗口。
2134 | if (!ezWnd->IsTopWindow)
2135 | {
2136 | //不是
2137 | BitBlt(ezWnd->ezParent->hdc,
2138 | ezWnd->x + ezWnd->ezParent->ScrollX,
2139 | ezWnd->y + ezWnd->ezParent->ScrollY,
2140 | ezWnd->Width, ezWnd->Height,
2141 | ezWnd->hdc,
2142 | 0, 0,
2143 | SRCCOPY);
2144 | /* BitBlt(ezWnd->ezParent->hdcCopy,
2145 | ezWnd->x + ezWnd->ezParent->ScrollX,
2146 | ezWnd->y + ezWnd->ezParent->ScrollY,
2147 | ezWnd->Width, ezWnd->Height,
2148 | ezWnd->hdc,
2149 | 0, 0,
2150 | SRCCOPY);*/
2151 | }
2152 |
2153 | return 0;
2154 | }
2155 | case SEZWM_REDRAW:
2156 | {
2157 |
2158 | int X_PSX;
2159 | int Y_PSY;
2160 |
2161 | RECT rectParent, rectPaint, rectIntersect;
2162 |
2163 | //判断是否是顶层窗口
2164 | if (ezWnd->bOpaque == FALSE)
2165 | {
2166 | if (ezWnd->IsTopWindow)
2167 | {
2168 | //画白布一块
2169 | PatBlt(ezWnd->hdc, 0, 0, ezWnd->Width, ezWnd->Height, WHITENESS);
2170 | //PatBlt(ezWnd->hdcWC, 0, 0, ezWnd->Width, ezWnd->Height, WHITENESS);
2171 | }
2172 | else
2173 | {
2174 | X_PSX = ezWnd->x + ezWnd->ezParent->ScrollX;
2175 | Y_PSY = ezWnd->y + ezWnd->ezParent->ScrollY;
2176 | //复制上级窗口的相应部分。
2177 |
2178 |
2179 | SetRect(&rectParent, 0, 0, ezWnd->ezParent->Width, ezWnd->ezParent->Height);
2180 | SetRect(&rectPaint, X_PSX, Y_PSY, X_PSX + ezWnd->Width, Y_PSY + ezWnd->Height);
2181 |
2182 | IntersectRect(&rectIntersect, &rectPaint, &rectParent);
2183 |
2184 | BitBlt(ezWnd->hdc,
2185 | rectIntersect.left - X_PSX,
2186 | rectIntersect.top - Y_PSY,
2187 | rectIntersect.right - rectIntersect.left,
2188 | rectIntersect.bottom - rectIntersect.top,
2189 | ezWnd->ezParent->hdc,
2190 | rectIntersect.left,
2191 | rectIntersect.top,
2192 | SRCCOPY);
2193 |
2194 | /*BitBlt(ezWnd->hdc, 0, 0,
2195 | max(ezWnd->Width, ezWnd->ezParent->Width - ezWnd->x), max(ezWnd->Height, ezWnd->ezParent->Height - ezWnd->y),
2196 | ezWnd->ezParent->hdc,
2197 | X_PSX,
2198 | Y_PSY,
2199 | SRCCOPY);*/
2200 | }
2201 | }
2202 |
2203 |
2204 | EZSendMessage(ezWnd, EZWM_TRANSDRAW, (WPARAM)(ezWnd->hdc), (LPARAM)NULL);
2205 |
2206 |
2207 | if (ezWnd->Transparent != 255)//如果不是255,混合。是255,那么,别混合了!
2208 | {
2209 | BLENDFUNCTION bf = { 0 };
2210 | /*bf.AlphaFormat = 0;
2211 | bf.BlendFlags = 0;
2212 | bf.BlendOp = AC_SRC_OVER;*/ // 这三个字段全是 0
2213 | bf.SourceConstantAlpha = 255 - ezWnd->Transparent;
2214 |
2215 | if (!ezWnd->IsTopWindow)
2216 | {
2217 | //RECT rectParent, rectPaint, rectIntersect;
2218 |
2219 | //IntersectRect(&rectIntersect, &rectPaint, &rectParent);
2220 |
2221 | AlphaBlend(ezWnd->hdc,
2222 | rectIntersect.left - X_PSX,
2223 | rectIntersect.top - Y_PSY,
2224 | rectIntersect.right - rectIntersect.left,
2225 | rectIntersect.bottom - rectIntersect.top,
2226 | ezWnd->ezParent->hdc,
2227 | rectIntersect.left,
2228 | rectIntersect.top,
2229 | rectIntersect.right - rectIntersect.left,
2230 | rectIntersect.bottom - rectIntersect.top,
2231 | bf);
2232 | //这个蠢货函数,不允许超出边界。我们只能手动确保没有超出边界。
2233 | /*int ab_Width, ab_Height;
2234 | ab_Width = min((ezWnd->Width), (ezWnd->ezParent->Width - (X_PSX)));
2235 | ab_Height = min((ezWnd->Height), (ezWnd->ezParent->Height - (Y_PSY)));
2236 |
2237 |
2238 |
2239 | AlphaBlend(ezWnd->hdc,
2240 | max(0, -X_PSX),
2241 | max(0, -Y_PSY),
2242 | ab_Width,
2243 | ab_Height,
2244 | ezWnd->ezParent->hdc,
2245 | max(X_PSX, 0),
2246 | max(Y_PSY, 0),
2247 | ab_Width,
2248 | ab_Height,
2249 | bf);*/
2250 |
2251 | }
2252 | else
2253 | {
2254 | //白色
2255 | //HDC hParentdc;
2256 | HDC hdcWhite = GetMemDC(ezWnd->hdc, ezWnd->Width, ezWnd->Height);
2257 |
2258 | PatBlt(hdcWhite, 0, 0, ezWnd->Width, ezWnd->Height, WHITENESS);
2259 |
2260 | AlphaBlend(ezWnd->hdc, 0, 0, ezWnd->Width, ezWnd->Height, hdcWhite, 0, 0, ezWnd->Width, ezWnd->Height, bf);
2261 |
2262 | DeleteMemDC(hdcWhite);
2263 | //ReleaseDC(ezWnd->hParent, hParentdc);
2264 | }
2265 | }
2266 |
2267 | //混合绘制现在以不透明的方式在DC上,现在从父窗口复制以255-透明度复制到hdcWC
2268 |
2269 | //发送普通绘制消息,绘制到DC。
2270 | EZSendMessage(ezWnd, EZWM_DRAW, (WPARAM)(ezWnd->hdc), (LPARAM)NULL);
2271 | //BitBlt(ezWnd->hdcCopy, 0, 0, ezWnd->Width, ezWnd->Height, ezWnd->hdc, 0, 0, SRCCOPY);
2272 |
2273 | /*if (!ezWnd->IsTopWindow)
2274 | {
2275 | BitBlt(ezWnd->ezParent->hdc,
2276 | ezWnd->x + ezWnd->ezParent->ScrollX,
2277 | ezWnd->y + ezWnd->ezParent->ScrollY,
2278 | ezWnd->Width, ezWnd->Height,
2279 | ezWnd->hdc, 0, 0, SRCCOPY);
2280 | }*/
2281 |
2282 |
2283 |
2284 | return 0;
2285 | }
2286 |
2287 |
2288 | }
2289 | }
2290 |
2291 | //int EZSendMessage(EZWND ezWnd, int message, WPARAM wP, LPARAM lP)
2292 | //{
2293 | // //if (IsEZWindow(ezWnd)/* && IsEZWindow((EZWND)(ezWnd->ezWndProc))*/)
2294 | // {
2295 | // //IsEZWindow函数可以通用的检查句柄是否有效
2296 | // return ezWnd->ezWndProc(ezWnd, message, wP, lP);
2297 | //
2298 | // }
2299 | //}
2300 |
2301 | int EZWndMessageLoop()
2302 | {
2303 | MSG msg;
2304 | while (GetMessage(&msg, NULL, 0, 0))
2305 | {
2306 | TranslateMessage(&msg);
2307 | DispatchMessage(&msg);
2308 | }
2309 | return msg.wParam;
2310 | }
2311 |
2312 |
2313 |
2314 | //判断函数
2315 | BOOL PtInEZWnd(EZWND ezWnd, int x, int y)
2316 | {
2317 | return (BOOL)((x >= ezWnd->x) && (x < (ezWnd->x + ezWnd->Width)) && (y >= ezWnd->y) && (y < (ezWnd->y + ezWnd->Height)));
2318 | }
2319 |
2320 | BOOL IsEZWindow(EZWND ezWnd)
2321 | {
2322 | return (BOOL)(ezWnd != NULL);
2323 | }
2324 |
2325 |
2326 | //*********************************************************************************************************
2327 | // 下面这些函数本不属于EZWindow,但EZWindow基于这些函数。这些函数也可以单独使用。
2328 | //*********************************************************************************************************
2329 |
2330 | HDC GetMemDC(HDC hdc, int cx, int cy)
2331 | {
2332 | HBITMAP hBitmap = CreateCompatibleBitmap(hdc, cx, cy);
2333 | HDC hdcMem = CreateCompatibleDC(hdc);
2334 | SelectObject(hdcMem, hBitmap);
2335 | DeleteObject(hBitmap);
2336 | return hdcMem;
2337 | }
2338 |
2339 |
2340 | BOOL DeleteMemDC(HDC hdc)
2341 | {
2342 | HBITMAP hBitmap = CreateCompatibleBitmap(hdc, 1, 1);
2343 | DeleteObject(SelectObject(hdc, hBitmap));
2344 | DeleteDC(hdc);
2345 | DeleteObject(hBitmap);
2346 | return TRUE;
2347 | }
2348 |
2349 | BOOL AdjustMemDC(HDC hdc, HDC hdcCpb, int cx, int cy)
2350 | {
2351 | DeleteObject(SelectObject(hdc, CreateCompatibleBitmap(hdcCpb, cx, cy)));
2352 | }
2353 |
2354 | //*********************************************************************************************************
2355 | // EZWindow风格扩展头文件 以及宏定义
2356 | //*********************************************************************************************************
2357 |
2358 |
2359 |
2360 |
2361 | EZWNDPROC EZStyle_ButtonProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
2362 | {
2363 | RECT rect;
2364 | HBRUSH hBrush;
2365 | HPEN hPen;
2366 | switch (message)
2367 | {
2368 | case EZWM_CREATE:
2369 | SetEZWndTransparent(ezWnd, 30);
2370 | return 0;
2371 |
2372 | case EZWM_DRAW:
2373 | rect.left = 0;
2374 | rect.top = 0;
2375 | rect.right = ezWnd->Width;
2376 | rect.bottom = ezWnd->Height;
2377 | SetTextColor(wParam, (COLORREF)(((ezWnd->Extend))->ForeGroundColor));
2378 |
2379 | SetBkMode(wParam, TRANSPARENT);
2380 | if (((pEZSE)ezWnd->Extend)->hFont)
2381 | {
2382 | SelectObject(wParam, ((pEZSE)ezWnd->Extend)->hFont);
2383 | }
2384 |
2385 | if (CHK_ALT_STYLE(ezWnd->EZStyle, EZS_BORDER))
2386 | {
2387 | hPen = CreatePen(PS_SOLID, 1, ezWnd->Extend->ForeGroundColor);
2388 | SelectPen(wParam, hPen);
2389 | SelectBrush(wParam, GetStockObject(NULL_BRUSH));
2390 | Rectangle(wParam, 0, 0, ezWnd->Width, ezWnd->Height);
2391 | }
2392 | DrawText(wParam, ((pEZSE)(ezWnd->Extend))->Title, -1, &rect, (ezWnd->Extend->TextAlign == 0) ? (DT_CENTER | DT_VCENTER | DT_SINGLELINE) : (ezWnd->Extend->TextAlign));
2393 |
2394 | return 0;
2395 | case EZWM_TRANSDRAW:
2396 | hBrush = CreateSolidBrush((COLORREF)(((ezWnd->Extend))->BackGroundColor));
2397 | SelectObject(wParam, hBrush);
2398 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, PATCOPY);
2399 |
2400 | DeleteObject(hBrush);
2401 | return 0;
2402 | case EZWM_LBUTTONDOWN:
2403 | if ((((ezWnd->Extend))->MouseHold) == FALSE)
2404 | {
2405 | EZCaptureMouse(ezWnd);
2406 |
2407 | (((ezWnd->Extend))->MouseHold) = TRUE;
2408 | SetEZWndTransparent(ezWnd, 90);
2409 | EZRepaint(ezWnd, NULL);
2410 | }
2411 |
2412 | return 0;
2413 | case EZWM_LBUTTONUP:
2414 | SetEZWndTransparent(ezWnd, 60);
2415 | EZRepaint(ezWnd, NULL);
2416 | if ((((ezWnd->Extend))->MouseHold) == TRUE)
2417 | {
2418 | EZReleaseMouse(ezWnd);
2419 | if ((LOWORD(lParam) > 0) && (LOWORD(lParam) < ezWnd->Width) && (HIWORD(lParam) > 0) && (HIWORD(lParam) < ezWnd->Height))
2420 | {
2421 |
2422 | (((ezWnd->Extend))->MouseHold) = FALSE;
2423 | //按钮被单击了!
2424 |
2425 | //判断按钮类型
2426 | if (CHK_STYLE(ezWnd->EZStyle & MKDW(11111111, 00000000, 00000000, 00000000), EZBS_PUSHBUTTON))
2427 | {
2428 | //发送控制消息。
2429 | EZSendMessage(ezWnd->ezParent, EZWM_COMMAND, 0, ezWnd);
2430 | }
2431 | else if (CHK_STYLE(ezWnd->EZStyle & MKDW(11111111, 00000000, 00000000, 00000000), EZBS_RADIOBUTTON))
2432 | {
2433 | //没说是AUTO哦,要听父窗口的话。
2434 | }
2435 | }
2436 |
2437 | }
2438 | return 0;
2439 | case EZWM_MOUSECOME:
2440 | SetEZWndTransparent(ezWnd, 60);
2441 | EZRepaint(ezWnd, NULL);
2442 | return 0;
2443 |
2444 | case EZWM_RELEASEMOUSE:
2445 | (((ezWnd->Extend))->MouseHold) = FALSE;
2446 | return 0;
2447 |
2448 | case EZWM_MOUSELEAVE:
2449 | SetEZWndTransparent(ezWnd, 30);
2450 | EZRepaint(ezWnd, NULL);
2451 | return 0;
2452 |
2453 | }
2454 | return EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
2455 | }
2456 |
2457 |
2458 | EZWNDPROC EZStyle_StaticProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
2459 | {
2460 | RECT rect;
2461 | HBRUSH hBrush;
2462 | HPEN hPen;
2463 | switch (message)
2464 | {
2465 | case EZWM_CREATE:
2466 | return 0;
2467 | case EZWM_DRAW:
2468 |
2469 |
2470 |
2471 | rect.left = 0;
2472 | rect.top = 0;
2473 | rect.right = ezWnd->Width;
2474 | rect.bottom = ezWnd->Height;
2475 | SetTextColor(wParam, (COLORREF)(((ezWnd->Extend))->ForeGroundColor));
2476 |
2477 | SetBkMode(wParam, TRANSPARENT);
2478 | if (((pEZSE)ezWnd->Extend)->hFont)
2479 | {
2480 | SelectObject(wParam, ((pEZSE)ezWnd->Extend)->hFont);
2481 | }
2482 | DrawText(wParam, ezWnd->Extend->Title, -1, &rect, (ezWnd->Extend->TextAlign == 0) ? (DT_WORDBREAK | DT_EDITCONTROL | DT_NOCLIP) : (ezWnd->Extend->TextAlign));
2483 |
2484 | return 0;
2485 | case EZWM_TRANSDRAW:
2486 | hPen = CreatePen(PS_INSIDEFRAME, 1, (COLORREF)(((ezWnd->Extend))->ForeGroundColor));
2487 | SelectObject(wParam, hPen);
2488 |
2489 |
2490 | hBrush = CreateSolidBrush((COLORREF)(((ezWnd->Extend))->BackGroundColor));
2491 | SelectObject(wParam, hBrush);
2492 | if (CHK_ALT_STYLE(ezWnd->EZStyle, EZS_BORDER))
2493 | {
2494 | Rectangle(wParam, 0, 0, ezWnd->Width, ezWnd->Height);
2495 | }
2496 | else
2497 | {
2498 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, PATCOPY);
2499 | }
2500 | DeleteObject(hBrush);
2501 |
2502 | DeleteObject(hPen);
2503 | return 0;
2504 | }
2505 | return EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
2506 | }
2507 |
2508 |
2509 | EZWNDPROC EZStyle_ScrollChildProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
2510 | {
2511 |
2512 | double BarLen;
2513 | switch (message)
2514 | {
2515 | case EZWM_CREATE:
2516 | //创建3个子窗口
2517 | //向上(左?)滚动 -- 扩展0号控件
2518 | //向下(右?)滚动 -- 扩展1号控件
2519 | //拖动条 -- 扩展2号控件
2520 |
2521 | ezWnd->Extend->hExtend[0] = CreateEZWindow(ezWnd, 0, 0, 0, 0, EZStyle_Scroll_BtnProc);
2522 | ezWnd->Extend->hExtend[0]->ezID = 0;
2523 |
2524 | ezWnd->Extend->hExtend[1] = CreateEZWindow(ezWnd, 0, 0, 0, 0, EZStyle_Scroll_BtnProc);
2525 | ezWnd->Extend->hExtend[1]->ezID = 1;
2526 |
2527 | ezWnd->Extend->hExtend[2] = CreateEZWindow(ezWnd, 0, 0, 0, 0, EZStyle_Scroll_BarProc);
2528 | ezWnd->Extend->hExtend[2]->ezID = 2;
2529 |
2530 |
2531 | //为了让子窗口可以更方便的判断应该横向还是纵向绘制
2532 | //用两个按钮的Style进行标识
2533 |
2534 | if ((ezWnd->EZStyle & MKDW(00000000, 00000000, 00000000, 11111111)) == EZS_CHILD_VSCROLL)
2535 | {
2536 | //EZS_CHILD_VSCROLL,竖直
2537 | ezWnd->Extend->hExtend[0]->EZStyle = ezWnd->Extend->hExtend[1]->EZStyle = 0;
2538 | }
2539 | else
2540 | {
2541 | //EZS_CHILD_HSCROLL,水平
2542 | ezWnd->Extend->hExtend[0]->EZStyle = ezWnd->Extend->hExtend[1]->EZStyle = 1;
2543 | }
2544 |
2545 |
2546 | //初始化滚动范围,位置
2547 | //滚动最大范围 -- int扩展 0 号
2548 | //滚动位置上 -- int扩展 1 号
2549 | //滚动位置下 -- int扩展 2 号
2550 | ezWnd->Extend->iExtend[0] = 16;//默认16?2333,随便了。
2551 | ezWnd->Extend->iExtend[1] = 0;//默认0
2552 | ezWnd->Extend->iExtend[2] = 1;//默认1
2553 |
2554 | return 0;
2555 | case EZWM_SIZE:
2556 | {
2557 |
2558 | if ((ezWnd->EZStyle & MKDW(00000000, 00000000, 00000000, 11111111)) == EZS_CHILD_VSCROLL)
2559 | { //EZS_CHILD_VSCROLL,竖直
2560 |
2561 | //检测竖直方向长度是否大于3倍水平,不然也太不像话了。
2562 | if (!(ezWnd->Height >= ezWnd->Width * 3))
2563 | {
2564 | //滚吧
2565 | MoveEZWindow(ezWnd->Extend->hExtend[0], 0, 0, 0, 0, 0);
2566 | MoveEZWindow(ezWnd->Extend->hExtend[1], 0, 0, 0, 0, 0);
2567 | MoveEZWindow(ezWnd->Extend->hExtend[2], 0, 0, 0, 0, 0);
2568 | return 0;
2569 | }
2570 | //调整位置咯
2571 | MoveEZWindow(ezWnd->Extend->hExtend[0], 0, 0, ezWnd->Width, (ezWnd->Width * 17) / 15, 0);//上面那个按钮
2572 | MoveEZWindow(ezWnd->Extend->hExtend[1], 0, ezWnd->Height - (ezWnd->Width * 17) / 15, ezWnd->Width, (ezWnd->Width * 17) / 15, 0);//下面那个按钮
2573 |
2574 | //滚动条宽度为 MAX((总宽度 / 最大滚动范围),最小宽度)
2575 |
2576 | //总宽度是要扣去两边的按钮的哦
2577 | BarLen = ((ezWnd->Height - (ezWnd->Width) * 34.0 / 15.0) / (float)ezWnd->Extend->iExtend[0]);
2578 | MoveEZWindow(ezWnd->Extend->hExtend[2],
2579 | 0,
2580 | ceil(ezWnd->Width * 17.0 / 15.0 + (float)BarLen * (float)ezWnd->Extend->iExtend[1]),
2581 | ezWnd->Width,
2582 | BarLen * (float)(ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]),
2583 | 0);
2584 |
2585 | }
2586 | else
2587 | { //EZS_CHILD_HSCROLL,水平
2588 |
2589 | //检测水平方向长度是否大于3倍竖直,不然也太不像话了。
2590 | if (!(ezWnd->Width >= ezWnd->Height * 3))
2591 | {
2592 | //滚吧
2593 | MoveEZWindow(ezWnd->Extend->hExtend[0], 0, 0, 0, 0, 0);
2594 | MoveEZWindow(ezWnd->Extend->hExtend[1], 0, 0, 0, 0, 0);
2595 | MoveEZWindow(ezWnd->Extend->hExtend[2], 0, 0, 0, 0, 0);
2596 | return 0;
2597 | }
2598 | //调整位置咯
2599 | MoveEZWindow(ezWnd->Extend->hExtend[0], 0, 0, (ezWnd->Height * 17.0) / 15.0, ezWnd->Height, 0);//左边那个按钮
2600 | MoveEZWindow(ezWnd->Extend->hExtend[1], ezWnd->Width - (ezWnd->Height * 17.0) / 15.0, 0, (ezWnd->Height * 17.0) / 15.0, ezWnd->Height, 0);//右边那个按钮
2601 |
2602 |
2603 | BarLen = (((float)ezWnd->Width - (float)(ezWnd->Height) * 34.0 / 15.0) / ((float)(ezWnd->Extend->iExtend[0])));
2604 |
2605 | MoveEZWindow(ezWnd->Extend->hExtend[2],
2606 | ceil(ezWnd->Height * 17.0 / 15.0 + (float)BarLen * (float)ezWnd->Extend->iExtend[1]),
2607 | 0,
2608 | BarLen * (float)(ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]),
2609 | ezWnd->Height,
2610 | 0);
2611 |
2612 |
2613 | }
2614 | return 0;
2615 | }
2616 |
2617 | case EZWM_SETSCROLLRANGE:
2618 | ezWnd->Extend->iExtend[0] = wParam;
2619 | if (ezWnd->Extend->iExtend[2] > wParam)
2620 | {
2621 | ezWnd->Extend->iExtend[1] = 0;
2622 | ezWnd->Extend->iExtend[2] = 1;
2623 | }
2624 | if ((ezWnd->EZStyle & MKDW(00000000, 00000000, 00000000, 11111111)) == EZS_CHILD_VSCROLL)
2625 | { //EZS_CHILD_VSCROLL,竖直
2626 | BarLen = ((ezWnd->Height - (ezWnd->Width) * 34.0 / 15.0) / (float)ezWnd->Extend->iExtend[0]);
2627 | MoveEZWindow(ezWnd->Extend->hExtend[2],
2628 | 0,
2629 | ceil(ezWnd->Width * 17.0 / 15.0 + (float)BarLen * (float)ezWnd->Extend->iExtend[1]),
2630 | ezWnd->Width,
2631 | BarLen * (float)(ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]),
2632 | 0);
2633 | }
2634 | else
2635 | { //EZS_CHILD_HSCROLL,水平
2636 | BarLen = (((float)ezWnd->Width - (float)(ezWnd->Height) * 34.0 / 15.0) / ((float)(ezWnd->Extend->iExtend[0])));
2637 |
2638 | MoveEZWindow(ezWnd->Extend->hExtend[2],
2639 | ceil(ezWnd->Height * 17.0 / 15.0 + (float)BarLen * (float)ezWnd->Extend->iExtend[1]),
2640 | 0,
2641 | BarLen * (float)(ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]),
2642 | ezWnd->Height,
2643 | 0);
2644 | }
2645 |
2646 | return 0;
2647 |
2648 | case EZWM_SETSCROLLPOS:
2649 |
2650 | if (wParam < lParam)
2651 | {
2652 | ezWnd->Extend->iExtend[1] = wParam;
2653 | ezWnd->Extend->iExtend[2] = lParam;
2654 | if ((ezWnd->EZStyle & MKDW(00000000, 00000000, 00000000, 11111111)) == EZS_CHILD_VSCROLL)
2655 | { //EZS_CHILD_VSCROLL,竖直
2656 | BarLen = ((ezWnd->Height - (ezWnd->Width) * 34.0 / 15.0) / (float)ezWnd->Extend->iExtend[0]);
2657 | MoveEZWindow(ezWnd->Extend->hExtend[2],
2658 | 0,
2659 | ceil(ezWnd->Width * 17.0 / 15.0 + (float)BarLen * (float)ezWnd->Extend->iExtend[1]),
2660 | ezWnd->Width,
2661 | BarLen * (float)(ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]),
2662 | 0);
2663 | }
2664 | else
2665 | { //EZS_CHILD_HSCROLL,水平
2666 | BarLen = (((float)ezWnd->Width - (float)(ezWnd->Height) * 34.0 / 15.0) / ((float)(ezWnd->Extend->iExtend[0])));
2667 |
2668 | MoveEZWindow(ezWnd->Extend->hExtend[2],
2669 | ceil(ezWnd->Height * 17.0 / 15.0 + (float)BarLen * (float)ezWnd->Extend->iExtend[1]),
2670 | 0,
2671 | BarLen * (float)(ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]),
2672 | ezWnd->Height,
2673 | 0);
2674 | }
2675 | EZSendMessage(ezWnd->ezParent, EZWM_SCROLLPOSCHANGE, wParam, ezWnd);
2676 | }
2677 | EZRepaint(ezWnd, NULL);
2678 | return 0;
2679 |
2680 | case EZWM_COMMAND:
2681 | if (lParam == ezWnd->Extend->hExtend[0])
2682 | {
2683 | if (ezWnd->Extend->iExtend[1] - (int)(ezWnd->Extend->iExtend[0] / 10) >= 0)
2684 | {
2685 | EZSendMessage(ezWnd, EZWM_SETSCROLLPOS,
2686 | ezWnd->Extend->iExtend[1] - (int)(ezWnd->Extend->iExtend[0] / 10),
2687 | ezWnd->Extend->iExtend[2] - (int)(ezWnd->Extend->iExtend[0] / 10));
2688 | }
2689 | else
2690 | {
2691 | EZSendMessage(ezWnd, EZWM_SETSCROLLPOS,
2692 | 0,
2693 | ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]);
2694 | }
2695 | }
2696 | if (lParam == ezWnd->Extend->hExtend[1])
2697 | {
2698 | if (ezWnd->Extend->iExtend[2] + (int)(ezWnd->Extend->iExtend[0] / 10) <= ezWnd->Extend->iExtend[0])
2699 | {
2700 | EZSendMessage(ezWnd, EZWM_SETSCROLLPOS,
2701 | ezWnd->Extend->iExtend[1] + (int)(ezWnd->Extend->iExtend[0] / 10),
2702 | ezWnd->Extend->iExtend[2] + (int)(ezWnd->Extend->iExtend[0] / 10));
2703 | }
2704 | else
2705 | {
2706 | EZSendMessage(ezWnd, EZWM_SETSCROLLPOS,
2707 | ezWnd->Extend->iExtend[0] - (ezWnd->Extend->iExtend[2] - ezWnd->Extend->iExtend[1]),
2708 | ezWnd->Extend->iExtend[0]);
2709 | }
2710 | }
2711 | if (lParam == ezWnd->Extend->hExtend[2])
2712 | {
2713 | int iMove;
2714 | if ((ezWnd->EZStyle & MKDW(00000000, 00000000, 00000000, 11111111)) == EZS_CHILD_VSCROLL)
2715 | { //EZS_CHILD_VSCROLL,竖直
2716 | BarLen = (((float)ezWnd->Height - (float)(ezWnd->Width) * 34.0 / 15.0) / (float)ezWnd->Extend->iExtend[0]);
2717 | iMove = ceil((float)GET_Y_LPARAM(wParam) / BarLen);//参数通过wParam传送过来
2718 | }
2719 | else
2720 | {
2721 | BarLen = (((float)ezWnd->Width - (float)(ezWnd->Height) * 34.0 / 15.0) / ((float)(ezWnd->Extend->iExtend[0])));
2722 | iMove = ceil((float)GET_X_LPARAM(wParam) / BarLen);//参数通过wParam传送过来
2723 | }
2724 | if (-iMove > ezWnd->Extend->iExtend[1])
2725 | {
2726 | iMove = -ezWnd->Extend->iExtend[1];
2727 | }
2728 | if (iMove + ezWnd->Extend->iExtend[2] > ezWnd->Extend->iExtend[0])
2729 | {
2730 | iMove = ezWnd->Extend->iExtend[0] - ezWnd->Extend->iExtend[2];
2731 | }
2732 |
2733 | EZSendMessage(ezWnd, EZWM_SETSCROLLPOS, ezWnd->Extend->iExtend[1] + iMove, ezWnd->Extend->iExtend[2] + iMove);
2734 |
2735 | }
2736 | return 0;
2737 | }
2738 | return EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
2739 | }
2740 |
2741 | EZWNDPROC EZStyle_Scroll_BtnProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
2742 | {
2743 | HBRUSH hBrush;
2744 | HPEN hPen;
2745 | POINT pt[7];
2746 | switch (message)
2747 | {
2748 | case EZWM_CREATE:
2749 | //这个窗口嘛,只是普通创建出来的,可惜我们也想用扩展,那自己申请啊~
2750 | ezWnd->Extend = malloc(sizeof(EZSE));
2751 |
2752 | ((pEZSE)ezWnd->Extend)->BackGroundColor = RGB(70, 70, 70);
2753 | ((pEZSE)ezWnd->Extend)->ForeGroundColor = RGB(70, 70, 70);
2754 |
2755 | ((pEZSE)ezWnd->Extend)->MouseHold = FALSE;
2756 |
2757 | ((pEZSE)ezWnd->Extend)->hFont = NULL;
2758 | ((pEZSE)ezWnd->Extend)->IsFontUserControl = -1;
2759 |
2760 | ezWnd->Extend->Title = NULL;//这样清理的时候就会跳过清理了,免着free一个野指针。
2761 |
2762 | //MD,不是样式窗口(假冒的)
2763 | ezWnd->IsStyleWindow = FALSE;
2764 | ezWnd->EZStyle = NULL;
2765 |
2766 | ezWnd->Extend->iExtend[0] = 0;
2767 | //设置透明度
2768 | SetEZWndTransparent(ezWnd, 20);
2769 | EZRepaint(ezWnd, NULL);
2770 | return 0;
2771 |
2772 |
2773 |
2774 |
2775 | case EZWM_LBUTTONDOWN:
2776 | if ((((ezWnd->Extend))->MouseHold) == FALSE)
2777 | {
2778 | EZCaptureMouse(ezWnd);
2779 |
2780 | (((ezWnd->Extend))->MouseHold) = TRUE;
2781 | SetEZWndTransparent(ezWnd, 200);
2782 | EZRepaint(ezWnd, NULL);
2783 | EZSendMessage(ezWnd->ezParent, EZWM_COMMAND, 0, ezWnd);
2784 | ezWnd->TimerID[0] = SetEZTimer(ezWnd, 80);
2785 | }
2786 |
2787 | return 0;
2788 | case EZWM_LBUTTONUP:
2789 | SetEZWndTransparent(ezWnd, 40);
2790 | EZRepaint(ezWnd, NULL);
2791 | if ((((ezWnd->Extend))->MouseHold) == TRUE)
2792 | {
2793 | EZReleaseMouse(ezWnd);
2794 | KillEZTimer(ezWnd, ezWnd->TimerID[0]);
2795 | ezWnd->Extend->iExtend[0] = 0;
2796 | }
2797 | return 0;
2798 | case EZWM_MOUSECOME:
2799 | SetEZWndTransparent(ezWnd, 40);
2800 | EZRepaint(ezWnd, NULL);
2801 | return 0;
2802 |
2803 | case EZWM_RELEASEMOUSE:
2804 | (((ezWnd->Extend))->MouseHold) = FALSE;
2805 | return 0;
2806 |
2807 | case EZWM_MOUSELEAVE:
2808 | if ((((ezWnd->Extend))->MouseHold) == TRUE)
2809 | {
2810 | ezWnd->Extend->MouseHold = FALSE;
2811 | KillEZTimer(ezWnd, ezWnd->TimerID[0]);
2812 | ezWnd->Extend->iExtend[0] = 0;
2813 | }
2814 |
2815 | SetEZWndTransparent(ezWnd, 20);
2816 | EZRepaint(ezWnd, NULL);
2817 | return 0;
2818 |
2819 |
2820 | //case EZWM_LBUTTONDOWN:
2821 | // if ((((ezWnd->Extend))->MouseHold) == FALSE)
2822 | // {
2823 | // EZCaptureMouse(ezWnd);
2824 | // (((ezWnd->Extend))->MouseHold) = TRUE;
2825 | // //ezWnd->TimerID[0] = SetTimer(NULL, 0, 100, ScrollBtnTimerProc);
2826 | // //这里!设置定时器!
2827 |
2828 | // EZSendMessage(ezWnd->ezParent, EZWM_COMMAND, 0, ezWnd);
2829 | // ezWnd->TimerID[0] = SetEZTimer(ezWnd, 80);
2830 |
2831 | // SetEZWndTransparent(ezWnd, 200);
2832 | // EZRepaint(ezWnd, NULL);
2833 | // }
2834 | // return 0;
2835 |
2836 | //case EZWM_LBUTTONUP:
2837 | // if ((((ezWnd->Extend))->MouseHold) == TRUE)
2838 | // {
2839 | //
2840 | // (((ezWnd->Extend))->MouseHold) = FALSE;
2841 | // //这里!取消定时器!
2842 | // KillEZTimer(ezWnd, ezWnd->TimerID[0]);
2843 | // ezWnd->Extend->iExtend[0] = 0;
2844 |
2845 | // SetEZWndTransparent(ezWnd, 40);
2846 | // EZReleaseMouse(ezWnd);
2847 | // EZRepaint(ezWnd, NULL);
2848 | // }
2849 | // return 0;
2850 |
2851 | //case EZWM_MOUSECOME:
2852 | // SetEZWndTransparent(ezWnd, 40);
2853 | // EZRepaint(ezWnd, NULL);
2854 | // return 0;
2855 |
2856 | //case EZWM_MOUSELEAVE:
2857 | // if ((((ezWnd->Extend))->MouseHold) == TRUE)
2858 | // {
2859 | // ezWnd->Extend->MouseHold = FALSE;
2860 | // KillEZTimer(ezWnd, ezWnd->TimerID[0]);
2861 | // ezWnd->Extend->iExtend[0] = 0;
2862 | // }
2863 | // SetEZWndTransparent(ezWnd, 20);
2864 | // EZRepaint(ezWnd, NULL);
2865 | // return 0;
2866 |
2867 | case EZWM_DRAW:
2868 | //绘制箭头
2869 | //就地define.
2870 | #define SRLBTN_ARR_W 3
2871 | #define SRLBTN_ARR_H 2
2872 |
2873 | //准备画笔,画刷。
2874 | hPen = NULL;
2875 | hBrush = NULL;
2876 | if ((((ezWnd->Extend))->MouseHold) == TRUE)
2877 | {
2878 | SelectObject(wParam, GetStockObject(WHITE_PEN));
2879 | SelectObject(wParam, GetStockObject(WHITE_BRUSH));
2880 | }
2881 | else
2882 | {
2883 | SelectObject(wParam, hPen = CreatePen(PS_SOLID, 1, ezWnd->Extend->ForeGroundColor));
2884 | SelectObject(wParam, hBrush = CreateSolidBrush(ezWnd->Extend->ForeGroundColor));
2885 | }
2886 |
2887 | if (ezWnd->EZStyle == 0)
2888 | {
2889 | //竖直
2890 | pt[0].x = ezWnd->Width / 2;
2891 | pt[1].x = ezWnd->Width / 2 + SRLBTN_ARR_W;
2892 | pt[2].x = ezWnd->Width / 2 + SRLBTN_ARR_W;
2893 | pt[3].x = ezWnd->Width / 2;
2894 | pt[4].x = ezWnd->Width / 2 - SRLBTN_ARR_W;
2895 | pt[5].x = ezWnd->Width / 2 - SRLBTN_ARR_W;
2896 | pt[6].x = ezWnd->Width / 2;
2897 | if (ezWnd->ezID == 0)
2898 | {
2899 |
2900 | pt[0].y = ezWnd->Height / 2 - SRLBTN_ARR_H;
2901 |
2902 | pt[1].y = ezWnd->Height / 2 - SRLBTN_ARR_H + SRLBTN_ARR_W;
2903 |
2904 | pt[2].y = ezWnd->Height / 2 + SRLBTN_ARR_W;
2905 |
2906 | pt[3].y = ezWnd->Height / 2;
2907 |
2908 | pt[4].y = ezWnd->Height / 2 + SRLBTN_ARR_W;
2909 |
2910 | pt[5].y = ezWnd->Height / 2 - SRLBTN_ARR_H + SRLBTN_ARR_W;
2911 |
2912 | pt[6].y = ezWnd->Height / 2 - SRLBTN_ARR_H;
2913 | }
2914 | else
2915 | {
2916 |
2917 | pt[0].y = ezWnd->Height / 2 + SRLBTN_ARR_H;
2918 |
2919 | pt[1].y = ezWnd->Height / 2 + SRLBTN_ARR_H - SRLBTN_ARR_W;
2920 |
2921 | pt[2].y = ezWnd->Height / 2 - SRLBTN_ARR_W;
2922 |
2923 | pt[3].y = ezWnd->Height / 2;
2924 |
2925 | pt[4].y = ezWnd->Height / 2 - SRLBTN_ARR_W;
2926 |
2927 | pt[5].y = ezWnd->Height / 2 + SRLBTN_ARR_H - SRLBTN_ARR_W;
2928 |
2929 | pt[6].y = ezWnd->Height / 2 + SRLBTN_ARR_H;
2930 | }
2931 |
2932 |
2933 | }
2934 | else
2935 | {
2936 | //水平
2937 |
2938 | pt[0].y = ezWnd->Height / 2;
2939 | pt[1].y = ezWnd->Height / 2 + SRLBTN_ARR_W;
2940 | pt[2].y = ezWnd->Height / 2 + SRLBTN_ARR_W;
2941 | pt[3].y = ezWnd->Height / 2;
2942 | pt[4].y = ezWnd->Height / 2 - SRLBTN_ARR_W;
2943 | pt[5].y = ezWnd->Height / 2 - SRLBTN_ARR_W;
2944 | pt[6].y = ezWnd->Height / 2;
2945 | if (ezWnd->ezID == 0)
2946 | {
2947 |
2948 | pt[0].x = ezWnd->Width / 2 - SRLBTN_ARR_H;
2949 |
2950 | pt[1].x = ezWnd->Width / 2 - SRLBTN_ARR_H + SRLBTN_ARR_W;
2951 |
2952 | pt[2].x = ezWnd->Width / 2 + SRLBTN_ARR_W;
2953 |
2954 | pt[3].x = ezWnd->Width / 2;
2955 |
2956 | pt[4].x = ezWnd->Width / 2 + SRLBTN_ARR_W;
2957 |
2958 | pt[5].x = ezWnd->Width / 2 - SRLBTN_ARR_H + SRLBTN_ARR_W;
2959 |
2960 | pt[6].x = ezWnd->Width / 2 - SRLBTN_ARR_H;
2961 | }
2962 | else
2963 | {
2964 |
2965 | pt[0].x = ezWnd->Width / 2 + SRLBTN_ARR_H;
2966 |
2967 | pt[1].x = ezWnd->Width / 2 + SRLBTN_ARR_H - SRLBTN_ARR_W;
2968 |
2969 | pt[2].x = ezWnd->Width / 2 - SRLBTN_ARR_W;
2970 |
2971 | pt[3].x = ezWnd->Width / 2;
2972 |
2973 | pt[4].x = ezWnd->Width / 2 - SRLBTN_ARR_W;
2974 |
2975 | pt[5].x = ezWnd->Width / 2 + SRLBTN_ARR_H - SRLBTN_ARR_W;
2976 |
2977 | pt[6].x = ezWnd->Width / 2 + SRLBTN_ARR_H;
2978 | }
2979 |
2980 | }
2981 |
2982 | Polygon((HDC)wParam, &pt, 6);
2983 |
2984 |
2985 | if ((((ezWnd->Extend))->MouseHold) == FALSE)
2986 | {
2987 | DeleteObject(hPen);
2988 | DeleteObject(hBrush);
2989 | }
2990 | return 0;
2991 |
2992 | case EZWM_TRANSDRAW:
2993 | //绘制透明背景
2994 | SelectObject(wParam, hBrush = CreateSolidBrush(ezWnd->Extend->BackGroundColor));
2995 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, PATCOPY);
2996 | DeleteObject(hBrush);
2997 | return 0;
2998 |
2999 | case EZWM_TIMER:
3000 | //添加处理
3001 | if (ezWnd->Extend->iExtend[0] < 3)
3002 | {
3003 | ezWnd->Extend->iExtend[0]++;
3004 | }
3005 | else
3006 | {
3007 | EZSendMessage(ezWnd->ezParent, EZWM_COMMAND, 0, ezWnd);
3008 | }
3009 |
3010 | return 0;
3011 |
3012 | case EZWM_DESTROY:
3013 | free(ezWnd->Extend);
3014 | return 0;
3015 |
3016 | }
3017 | return EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
3018 | }
3019 |
3020 | EZWNDPROC EZStyle_Scroll_BarProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
3021 | {
3022 | HBRUSH hBrush;
3023 | switch (message)
3024 | {
3025 | case EZWM_CREATE:
3026 | //我们也想用扩展!!!
3027 | ezWnd->Extend = malloc(sizeof(EZSE));
3028 |
3029 | //不用
3030 | //((pEZSE)ezWnd->Extend)->BackGroundColor = RGB(70, 70, 70);
3031 | //((pEZSE)ezWnd->Extend)->ForeGroundColor = RGB(70, 70, 70);
3032 |
3033 | ((pEZSE)ezWnd->Extend)->MouseHold = FALSE;
3034 |
3035 | ((pEZSE)ezWnd->Extend)->hFont = NULL;
3036 | ((pEZSE)ezWnd->Extend)->IsFontUserControl = -1;
3037 |
3038 | ezWnd->Extend->Title = NULL;//这样清理的时候就会跳过清理了,免着free一个野指针。
3039 |
3040 | //MD,不是样式窗口(假冒的)
3041 | ezWnd->IsStyleWindow = FALSE;
3042 | ezWnd->EZStyle = NULL;
3043 |
3044 |
3045 |
3046 | SetEZWndTransparent(ezWnd, 50);
3047 | return 0;
3048 |
3049 | case EZWM_TRANSDRAW:
3050 | hBrush = CreateSolidBrush(RGB(36, 36, 36));
3051 |
3052 | SelectObject(wParam, hBrush);
3053 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, PATCOPY);
3054 |
3055 | DeleteObject(hBrush);
3056 | return 0;
3057 | case EZWM_LBUTTONDOWN:
3058 | if (ezWnd->Extend->MouseHold == FALSE)
3059 | {
3060 | ezWnd->Extend->MouseHold = TRUE;
3061 |
3062 | EZCaptureMouse(ezWnd);
3063 |
3064 | //记录鼠标按下的位置
3065 | ezWnd->Extend->iExtend[0] = GET_X_LPARAM(lParam);
3066 | ezWnd->Extend->iExtend[1] = GET_Y_LPARAM(lParam);
3067 |
3068 | SetEZWndTransparent(ezWnd, 180);
3069 | EZRepaint(ezWnd, NULL);
3070 | }
3071 | return 0;
3072 | case EZWM_LBUTTONUP:
3073 | if (ezWnd->Extend->MouseHold == TRUE)
3074 | {
3075 | ezWnd->Extend->MouseHold = FALSE;
3076 | EZReleaseMouse(ezWnd);
3077 | SetEZWndTransparent(ezWnd, 95);
3078 | EZRepaint(ezWnd, NULL);
3079 | }
3080 |
3081 | case EZWM_MOUSEMOVE:
3082 | if (ezWnd->Extend->MouseHold == TRUE)
3083 | {
3084 | //别忘了,这是一个滚动条.
3085 | //将鼠标移动的情况告诉父窗口
3086 | EZSendMessage(ezWnd->ezParent, EZWM_COMMAND,
3087 | MAKELPARAM(GET_X_LPARAM(lParam) - ezWnd->Extend->iExtend[0], GET_Y_LPARAM(lParam) - ezWnd->Extend->iExtend[1]),
3088 | ezWnd);
3089 | EZRepaint(ezWnd, NULL);
3090 | }
3091 | return 0;
3092 | case EZWM_MOUSECOME:
3093 | SetEZWndTransparent(ezWnd, 95);
3094 | EZRepaint(ezWnd, NULL);
3095 | return 0;
3096 | case EZWM_MOUSELEAVE:
3097 | /*if (ezWnd->Extend->MouseHold == TRUE)
3098 | {
3099 | EZReleaseMouse(ezWnd);
3100 | }*/
3101 |
3102 | SetEZWndTransparent(ezWnd, 50);
3103 | EZRepaint(ezWnd, NULL);
3104 | return 0;
3105 | case EZWM_RELEASEMOUSE:
3106 | (((ezWnd->Extend))->MouseHold) = FALSE;
3107 | return 0;
3108 |
3109 | case EZWM_DESTROY:
3110 | free(ezWnd->Extend);
3111 | return 0;
3112 | }
3113 | }
3114 |
3115 |
3116 |
3117 | EZWNDPROC EZStyle_DefaultProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
3118 | {
3119 | switch (message)
3120 | {
3121 | case EZWM_SETCOLOR:
3122 | {
3123 | if (ezWnd->Extend)
3124 | {
3125 | ezWnd->Extend->BackGroundColor = (COLORREF)wParam;
3126 | ezWnd->Extend->ForeGroundColor = (COLORREF)lParam;
3127 |
3128 | EZRepaint(ezWnd, NULL);
3129 |
3130 | }
3131 | }
3132 | return 0;
3133 | case EZWM_SETFONT:
3134 | {
3135 |
3136 | if (((pEZSE)ezWnd->Extend)->hFont)
3137 | {
3138 | switch (((pEZSE)ezWnd->Extend)->IsFontUserControl)
3139 | {
3140 | case 1:
3141 | case 2:
3142 | DeleteObject(((pEZSE)ezWnd->Extend)->hFont);
3143 | break;
3144 | }
3145 | ((pEZSE)ezWnd->Extend)->hFont = NULL;
3146 | }
3147 |
3148 | if (wParam)
3149 | {
3150 | //用户提交了HFONT,用户负责释放。
3151 | ((pEZSE)ezWnd->Extend)->hFont = (HFONT)wParam;
3152 | ((pEZSE)ezWnd->Extend)->IsFontUserControl = 0;
3153 | }
3154 | else if (lParam)
3155 | {
3156 | //用户提交了LOGFONT,我们创建并销毁。
3157 | ((pEZSE)ezWnd->Extend)->hFont = CreateFontIndirect(lParam);
3158 | ((pEZSE)ezWnd->Extend)->IsFontUserControl = 1;
3159 | }
3160 | else
3161 | {
3162 | //都为空,使用默认字体。
3163 | LOGFONT lf;
3164 | lf.lfHeight = 19;
3165 | lf.lfWidth = 0;
3166 | lf.lfEscapement = 0;
3167 | lf.lfOrientation = 0;
3168 | lf.lfWeight = 0;//1
3169 | lf.lfItalic = 0;//1
3170 | lf.lfUnderline = 0;//1
3171 | lf.lfStrikeOut = 0;//1
3172 | lf.lfCharSet = DEFAULT_CHARSET;
3173 | lf.lfOutPrecision = 0;
3174 | lf.lfClipPrecision = 0;
3175 | lf.lfQuality = 0;
3176 | lf.lfPitchAndFamily = 0;
3177 | lstrcpy(lf.lfFaceName, TEXT("微软雅黑"));
3178 | ((pEZSE)ezWnd->Extend)->hFont = CreateFontIndirect(&lf);
3179 | ((pEZSE)ezWnd->Extend)->IsFontUserControl = 2;
3180 | }
3181 | return 0;
3182 | }
3183 |
3184 | case EZWM_SETTEXT:
3185 | {
3186 | int TitleLen;
3187 | if (lParam == 0)
3188 | {
3189 | TitleLen = lstrlen(wParam);
3190 | }
3191 | else
3192 | {
3193 | TitleLen = lParam;
3194 | }
3195 |
3196 | if ((TitleLen) > MAX_TEXT - 2)
3197 | {
3198 | return FALSE;
3199 | }
3200 | if (ezWnd->Extend)
3201 | {
3202 | if (((pEZSE)(ezWnd->Extend))->Title)
3203 | {
3204 | free(((pEZSE)(ezWnd->Extend))->Title);
3205 | }
3206 | #ifdef UNICODE
3207 | ((pEZSE)ezWnd->Extend)->Title = malloc(TitleLen * 2 + 4);
3208 | ezWnd->Extend->TitleLen = TitleLen;
3209 | lstrcpyn(((pEZSE)ezWnd->Extend)->Title, wParam, TitleLen + 1);
3210 | ((pEZSE)ezWnd->Extend)->Title[TitleLen * 2 + 2] = '\0';
3211 | ((pEZSE)ezWnd->Extend)->Title[TitleLen * 2 + 3] = '\0';
3212 | #else
3213 | ((pEZSE)ezWnd->Extend)->Title = (PBYTE)malloc(TitleLen + 2);
3214 | strcpy_s((char*)((pEZSE)ezWnd->Extend)->Title, TitleLen + 2, wParam);
3215 | ((pEZSE)ezWnd->Extend)->Title[TitleLen] = '\0';
3216 | ((pEZSE)ezWnd->Extend)->Title[TitleLen + 1] = '\0';
3217 | #endif
3218 |
3219 | return TRUE;
3220 |
3221 | }
3222 |
3223 | }
3224 | break;
3225 | case EZWM_DESTROY:
3226 | {
3227 | //清理系列内容
3228 | if (ezWnd->Extend)
3229 | {
3230 | //清理字体
3231 | if (((pEZSE)ezWnd->Extend)->hFont)
3232 | {
3233 | switch (((pEZSE)ezWnd->Extend)->IsFontUserControl)
3234 | {
3235 | case 1:
3236 | case 2:
3237 | DeleteObject(((pEZSE)ezWnd->Extend)->hFont);
3238 | break;
3239 | }
3240 | ((pEZSE)ezWnd->Extend)->hFont = NULL;
3241 | }
3242 |
3243 | //清理标题
3244 | if (((pEZSE)ezWnd->Extend)->Title)
3245 | {
3246 | free(((pEZSE)(ezWnd->Extend))->Title);
3247 | }
3248 | }
3249 | return 0;
3250 | }
3251 |
3252 | case EZWM_SETTEXTALIGN:
3253 | {
3254 | ezWnd->Extend->TextAlign = wParam;
3255 | return 0;
3256 | }
3257 |
3258 | }
3259 | return 0;
3260 | }
3261 |
3262 |
3263 |
3264 |
3265 | EZWNDPROC EZStyle_EditProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
3266 | {
3267 | int iMove, LastMove;
3268 | int iMaxLen;
3269 | int LineCount;
3270 | int xCount, yCount;
3271 | SIZE size;
3272 | TCHAR* Text;
3273 |
3274 | switch (message)
3275 | {
3276 | case EZWM_CREATE:
3277 | //创建子窗口。
3278 | //0号扩展放主编辑窗口
3279 | //1号扩展放竖直滚动条
3280 | //2号水平滚动条
3281 | ezWnd->Extend->iExtend[0] = 0;
3282 | ezWnd->Extend->iExtend[1] = 0;
3283 | ezWnd->Extend->iExtend[2] = 0;
3284 | ezWnd->Extend->hExtend[0] = CreateEZWindow(ezWnd, 0, 0, 0, 0, EZStyle_Edit_InputProc);//主编辑窗口
3285 | ezWnd->Extend->hExtend[1] = CreateEZStyleWindow(ezWnd, TEXT(""), EZS_CHILD | EZS_CHILD_VSCROLL, 0, 0, 0, 0);
3286 | ezWnd->Extend->hExtend[2] = CreateEZStyleWindow(ezWnd, TEXT(""), EZS_CHILD | EZS_CHILD_HSCROLL, 0, 0, 0, 0);
3287 |
3288 | ezWnd->Extend->iExtend[3] = -1;//无限制
3289 | ezWnd->Extend->BackGroundColor = RGB(255, 255, 255);
3290 | SetEZWndTransparent(ezWnd, 0);
3291 |
3292 | return 0;
3293 |
3294 | case EZWM_SETMAXTEXT:
3295 | ezWnd->Extend->iExtend[3] = wParam;
3296 | return 0;
3297 |
3298 | case EZWM_SIZE:
3299 | {
3300 | MoveEZWindow(ezWnd->Extend->hExtend[0],
3301 | 0, 0,
3302 | CHK_ALT_STYLE(ezWnd->EZStyle, EZS_VSCROLL) ? ezWnd->Width - 15 : ezWnd->Width,
3303 | CHK_ALT_STYLE(ezWnd->EZStyle, EZS_HSCROLL) ? ezWnd->Height - 15 : ezWnd->Height,
3304 | 0);
3305 | MoveEZWindow(ezWnd->Extend->hExtend[1],//竖直,V
3306 | ezWnd->Width - 15, 0,
3307 | CHK_ALT_STYLE(ezWnd->EZStyle, EZS_VSCROLL) ? (15) : (0),
3308 | CHK_ALT_STYLE(ezWnd->EZStyle, EZS_HSCROLL) ? (ezWnd->Height - 15) : (ezWnd->Height)
3309 | , 0);
3310 | MoveEZWindow(ezWnd->Extend->hExtend[2],//水平,H
3311 | 0, ezWnd->Height - 15,
3312 | CHK_ALT_STYLE(ezWnd->EZStyle, EZS_VSCROLL) ? (ezWnd->Width - 15) : (ezWnd->Width),
3313 | CHK_ALT_STYLE(ezWnd->EZStyle, EZS_HSCROLL) ? (15) : (0)
3314 | , 0);
3315 | return 0;
3316 | }
3317 |
3318 | case EZWM_SETFONT:
3319 | //嘿嘿,骚操作。直接递交给默认处理。
3320 | EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
3321 |
3322 |
3323 | //并入下面SETTEXT的部分
3324 | case EZWM_SETTEXT:
3325 | //截下来,计算好大小,然后再提交给默认处理
3326 | {
3327 |
3328 | if (message == EZWM_SETTEXT)
3329 | {
3330 | Text = (TCHAR*)wParam;
3331 | if (lParam == 0)
3332 | {
3333 | iMaxLen = lstrlen(Text);
3334 | }
3335 | else
3336 | {
3337 | iMaxLen = lParam;
3338 | }
3339 |
3340 | }
3341 | else
3342 | {//EZWM_SETFONT
3343 | Text = ezWnd->Extend->Title;
3344 | iMaxLen = ezWnd->Extend->TitleLen;
3345 | }
3346 |
3347 | LastMove = 0;
3348 | xCount = yCount = 0;
3349 | LineCount = 0;
3350 |
3351 | if (ezWnd->Extend->hFont)
3352 | {
3353 | SelectObject(ezWnd->hdc, ezWnd->Extend->hFont);
3354 | }
3355 |
3356 |
3357 | TEXTMETRIC tm;
3358 | GetTextMetrics(ezWnd->hdc, &tm);
3359 |
3360 | for (iMove = 0; iMove <= iMaxLen;)
3361 | {
3362 |
3363 | if (Text[iMove] == '\0')
3364 | {
3365 | //绘制当前行,并退出。
3366 | GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3367 | yCount += tm.tmHeight;
3368 | xCount = max(xCount, size.cx);
3369 | LineCount++;
3370 |
3371 | break;
3372 | }
3373 | else if (Text[iMove] == '\r' && Text[iMove + 1] == '\n')
3374 | {
3375 | //windows换行标记,绘制当前行,重新开始。
3376 | GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3377 | yCount += tm.tmHeight;
3378 | xCount = max(xCount, size.cx);
3379 | LineCount++;
3380 |
3381 | LastMove = iMove + 2;
3382 | iMove++;
3383 |
3384 | }
3385 | else if (Text[iMove] == '\n')
3386 | {
3387 | //Linux换行标记,绘制当前行。
3388 | GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3389 | yCount += tm.tmHeight;
3390 | xCount = max(xCount, size.cx);
3391 | LineCount++;
3392 |
3393 | LastMove = iMove + 1;
3394 | }
3395 | iMove++;//放在for里面我怕我搞混....放到这里就不会了
3396 | }
3397 |
3398 | //设置滚动 MoveEZWindow(ezWnd->Extend->hExtend[3], 0, 0, max(ezWnd->Extend->hExtend[0]->Width, xCount), max(ezWnd->Extend->hExtend[0]->Height, yCount), 0);
3399 |
3400 |
3401 |
3402 |
3403 |
3404 | EZRepaint(ezWnd, 0);
3405 | EZSendMessage(ezWnd->Extend->hExtend[1], EZWM_SETSCROLLRANGE, max(ezWnd->Extend->hExtend[0]->Height, yCount), 0);
3406 | EZSendMessage(ezWnd->Extend->hExtend[2], EZWM_SETSCROLLRANGE, max(ezWnd->Extend->hExtend[0]->Width, xCount), 0);
3407 |
3408 |
3409 | if (ezWnd->Extend->iExtend[1] > ezWnd->Extend->hExtend[0]->Height)
3410 | {
3411 | EZSendMessage(ezWnd->Extend->hExtend[1], EZWM_SETSCROLLPOS, ezWnd->Extend->iExtend[1] - ezWnd->Extend->hExtend[0]->Height,
3412 | ezWnd->Extend->iExtend[1]);
3413 | }
3414 | else
3415 | {
3416 | EZSendMessage(ezWnd->Extend->hExtend[1], EZWM_SETSCROLLPOS, 0,
3417 | ezWnd->Extend->hExtend[0]->Height);
3418 | }
3419 |
3420 | if (ezWnd->Extend->iExtend[0] > ezWnd->Extend->hExtend[0]->Width)
3421 | {
3422 | EZSendMessage(ezWnd->Extend->hExtend[2], EZWM_SETSCROLLPOS, ezWnd->Extend->iExtend[0] - ezWnd->Extend->hExtend[0]->Width,
3423 | ezWnd->Extend->iExtend[0]);
3424 | }
3425 | else
3426 | {
3427 | EZSendMessage(ezWnd->Extend->hExtend[2], EZWM_SETSCROLLPOS, 0,
3428 | ezWnd->Extend->hExtend[0]->Width);
3429 | }
3430 |
3431 |
3432 | MoveEZWindow(ezWnd->Extend->hExtend[3], 0, 0, max(ezWnd->Extend->hExtend[0]->Width, xCount), max(ezWnd->Extend->hExtend[0]->Height, yCount), 0);
3433 |
3434 |
3435 | if (message == EZWM_SETFONT)
3436 | {
3437 | //已经给默认处理提交过了,在前面。
3438 | return 0;
3439 | }
3440 | //else,EZWM_SETTEXT,提交给默认处理。
3441 | break;
3442 | }
3443 | break;
3444 |
3445 | case EZWM_SCROLLPOSCHANGE:
3446 | //wParam就是偏移像素数
3447 | if (lParam == ezWnd->Extend->hExtend[1])//竖直
3448 | {
3449 | ezWnd->Extend->hExtend[0]->ScrollY = -(int)(wParam);
3450 | }
3451 | else if (lParam == ezWnd->Extend->hExtend[2])//水平
3452 | {
3453 | ezWnd->Extend->hExtend[0]->ScrollX = -((int)wParam);
3454 | }
3455 | EZRepaint(ezWnd, NULL);
3456 | return 0;
3457 | case EZWM_TRANSDRAW:
3458 | {
3459 | HBRUSH hBrush;
3460 | hBrush = CreateSolidBrush(ezWnd->Extend->BackGroundColor);
3461 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, PATCOPY);
3462 | DeleteObject(hBrush);
3463 | }
3464 | return 0;
3465 |
3466 | }
3467 | return EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
3468 | }
3469 |
3470 | EZWNDPROC EZStyle_Edit_InputProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
3471 | {
3472 |
3473 | switch (message)
3474 | {
3475 | case EZWM_CREATE:
3476 | //父窗口的扩展浪费了,干脆我们也一起用父窗口多余的扩展吧
3477 | ezWnd->ezParent->Extend->hExtend[3] = CreateEZWindow(ezWnd, 0, 0, 0, 0, EZStyle_Edit_InputChildProc);
3478 | return 0;
3479 | case EZWM_SIZE:
3480 | MoveEZWindow(ezWnd->ezParent->Extend->hExtend[3], 0, 0, ezWnd->Width, ezWnd->Height, 0);
3481 | return 0;
3482 | }
3483 | }
3484 |
3485 | EZWNDPROC EZStyle_Edit_InputChildProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
3486 | {
3487 | int iMove, LastMove;
3488 | int iMaxLen;
3489 | int xCount, yCount;
3490 | int CaretX, CaretY;
3491 | SIZE size;
3492 | TCHAR* Text;
3493 | TEXTMETRIC tm;
3494 | TCHAR TextBuffer[MAX_TEXT];
3495 | switch (message)
3496 | {
3497 | case EZWM_CREATE:
3498 | return 0;
3499 | case EZWM_LBUTTONDOWN:
3500 | {
3501 |
3502 | int LineCount;
3503 | Text = ezWnd->ezParent->ezParent->Extend->Title;
3504 | iMaxLen = ezWnd->ezParent->ezParent->Extend->TitleLen;
3505 |
3506 | LineCount = 0;
3507 | LastMove = 0;
3508 | xCount = yCount = 0;
3509 |
3510 |
3511 | BOOL IsFounded;
3512 | IsFounded = FALSE;
3513 | if (ezWnd->ezParent->ezParent->Extend->hFont)
3514 | {
3515 | SelectObject(ezWnd->hdc, ezWnd->ezParent->ezParent->Extend->hFont);
3516 | }
3517 | GetTextMetrics(ezWnd->hdc, &tm);
3518 |
3519 | for (iMove = 0; iMove <= iMaxLen;)
3520 | {
3521 | if (Text[iMove] == '\0')
3522 | {
3523 | //当前行,并退出。
3524 | //GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3525 | yCount += tm.tmHeight;
3526 | if (yCount >= GET_Y_LPARAM(lParam))
3527 | {
3528 | IsFounded = TRUE;
3529 | yCount -= tm.tmHeight;
3530 | break;
3531 | }
3532 | break;
3533 | }
3534 | else if (Text[iMove] == '\r' && Text[iMove + 1] == '\n')
3535 | {
3536 | //windows换行标记,重新开始。
3537 | //GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3538 | yCount += tm.tmHeight;
3539 | if (yCount >= GET_Y_LPARAM(lParam))
3540 | {
3541 | IsFounded = TRUE;
3542 | yCount -= tm.tmHeight;
3543 | break;
3544 | }
3545 | LineCount++;
3546 | LastMove = iMove + 2;
3547 | iMove++;
3548 |
3549 | }
3550 | else if (Text[iMove] == '\n')
3551 | {
3552 | //Linux换行标记
3553 | //GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3554 | yCount += tm.tmHeight;
3555 | if (yCount >= GET_Y_LPARAM(lParam))
3556 | {
3557 | IsFounded = TRUE;
3558 | yCount -= tm.tmHeight;
3559 | break;
3560 |
3561 | }
3562 | LineCount++;
3563 | LastMove = iMove + 1;
3564 | }
3565 | iMove++;//放在for里面我怕我搞混....放到这里就不会了
3566 | }
3567 |
3568 | if (IsFounded)
3569 | {
3570 | //就在当前行!
3571 |
3572 | CaretY = yCount;
3573 | IsFounded = FALSE;
3574 | int LastLen, CurrLen;
3575 | LastLen = CurrLen = 0;
3576 | for (iMove = LastMove; iMove <= iMaxLen;)
3577 | {
3578 |
3579 | if ((Text[iMove] == '\0') || (Text[iMove] == '\r' && Text[iMove + 1] == '\n') || (Text[iMove] == '\n'))
3580 | {
3581 | //没找到,在行末尾
3582 | ezWnd->ezParent->ezParent->Extend->iExtend[2] = iMove;
3583 | break;
3584 | }
3585 |
3586 | LastLen = CurrLen;
3587 | //GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3588 | int CharWidth;
3589 | GetCharWidth32(ezWnd->hdc, Text[iMove], Text[iMove], &CharWidth);
3590 | //CurrLen = size.cx;
3591 | CurrLen += CharWidth;
3592 |
3593 |
3594 | //得到旧位置和新位置的平均位置
3595 | if (GET_X_LPARAM(lParam) <= (LastLen + CurrLen) / 2)
3596 | {
3597 | //插入符号在这个字符往前推一个,也就是在LastCurr的位置
3598 | IsFounded = TRUE;
3599 | ezWnd->ezParent->ezParent->Extend->iExtend[2] = iMove;
3600 | break;
3601 |
3602 | }
3603 |
3604 | iMove++;//放在for里面我怕我搞混....放到这里就不会了
3605 | }
3606 |
3607 | if (IsFounded)
3608 | {
3609 | CaretX = LastLen;
3610 | }
3611 | else
3612 | {
3613 | CaretX = CurrLen;
3614 | }
3615 | }
3616 | else
3617 | {
3618 | //文档末尾
3619 | CaretY = yCount;
3620 | }
3621 |
3622 | ezWnd->ezParent->ezParent->Extend->iExtend[0] = CaretX;
3623 |
3624 | ezWnd->ezParent->ezParent->Extend->iExtend[1] = CaretY;
3625 |
3626 | EZHideCaret(ezWnd);
3627 | EZSetCaretPos(ezWnd, ezWnd->ezParent->ezParent->Extend->iExtend[0], ezWnd->ezParent->ezParent->Extend->iExtend[1]);
3628 | EZRepaint(ezWnd->ezParent->ezParent, NULL);
3629 | EZShowCaret(ezWnd);
3630 | }
3631 | return 0;
3632 | case EZWM_DRAW:
3633 | {
3634 | EZHideCaret(ezWnd);
3635 | //开始绘制,循环检查,找到\r\n,或\n,掐行,输出。
3636 |
3637 | Text = ezWnd->ezParent->ezParent->Extend->Title;
3638 | if (!Text)
3639 | {
3640 | return 0;
3641 | }
3642 | iMaxLen = ezWnd->ezParent->ezParent->Extend->TitleLen;
3643 | LastMove = 0;
3644 | xCount = yCount = 0;
3645 |
3646 | if (ezWnd->ezParent->ezParent->Extend->hFont)
3647 | {
3648 | SelectObject(wParam, ezWnd->ezParent->ezParent->Extend->hFont);
3649 | }
3650 | SetBkMode(wParam, TRANSPARENT);
3651 | SetTextColor(wParam, ezWnd->ezParent->ezParent->Extend->ForeGroundColor);
3652 | GetTextMetrics(wParam, &tm);
3653 | for (iMove = 0; iMove <= iMaxLen;)
3654 | {
3655 |
3656 | if (Text[iMove] == '\0')
3657 | {
3658 | //绘制当前行,并退出。
3659 | TextOut(wParam, 0, yCount, Text + LastMove, iMove - LastMove);
3660 | //GetTextExtentPoint32(wParam, Text + LastMove, iMove - LastMove, &size);
3661 |
3662 | yCount += tm.tmHeight;
3663 | //xCount = max(xCount, size.cx);
3664 |
3665 |
3666 |
3667 | break;
3668 | }
3669 | else if (Text[iMove] == '\r' && Text[iMove + 1] == '\n')
3670 | {
3671 | //windows换行标记,绘制当前行,重新开始。
3672 | TextOut(wParam, 0, yCount, Text + LastMove, iMove - LastMove);
3673 | //GetTextExtentPoint32(wParam, Text + LastMove, iMove - LastMove, &size);
3674 | yCount += tm.tmHeight;
3675 | //xCount = max(xCount, size.cx);
3676 |
3677 |
3678 | LastMove = iMove + 2;
3679 | iMove++;
3680 |
3681 | }
3682 | else if (Text[iMove] == '\n')
3683 | {
3684 | //Linux换行标记,绘制当前行。
3685 | TextOut(wParam, 0, yCount, Text + LastMove, iMove - LastMove);
3686 | //GetTextExtentPoint32(wParam, Text + LastMove, iMove - LastMove, &size);
3687 | yCount += tm.tmHeight;
3688 | //xCount = max(xCount, size.cx);
3689 |
3690 |
3691 | LastMove = iMove + 1;
3692 | }
3693 | iMove++;//放在for里面我怕我搞混....放到这里就不会了
3694 | }
3695 |
3696 | }
3697 | EZShowCaret(ezWnd);
3698 | //SetPixel(wParam, ezWnd->ezParent->ezParent->Extend->iExtend[0], ezWnd->ezParent->ezParent->Extend->iExtend[1], RGB(255, 0, 0));
3699 | return 0;
3700 |
3701 | case EZWM_CHAR:
3702 |
3703 | //这里!解决新加字符问题。
3704 | //每次有EZWM_CHAR,都是通过传递模拟SETTEXT实现修改的。但是SETTEXT可没有处理位移问题。比如当前输入了一个字符,超出了边界之类的问题
3705 | EZHideCaret(ezWnd);
3706 |
3707 | int pp_CaretPos = ezWnd->ezParent->ezParent->Extend->iExtend[2];
3708 | TCHAR* pTitle = ezWnd->ezParent->ezParent->Extend->Title;
3709 | if (wParam == '\b')
3710 | {
3711 | if (pp_CaretPos == 0)
3712 | {
3713 | EZShowCaret(ezWnd);
3714 | return 0;
3715 | }
3716 | if (pTitle[pp_CaretPos - 1] == '\n' && pTitle[pp_CaretPos - 2] == '\r')
3717 | {
3718 | EZSendMessage(ezWnd, EZWM_KEYDOWN, 37, 0);//模拟按键
3719 |
3720 | pp_CaretPos = ezWnd->ezParent->ezParent->Extend->iExtend[2];
3721 |
3722 | lstrcpyn(TextBuffer, pTitle, pp_CaretPos + 1);
3723 |
3724 | lstrcpyn(TextBuffer + pp_CaretPos,
3725 | pTitle + pp_CaretPos + 2,
3726 | ezWnd->ezParent->ezParent->Extend->TitleLen - pp_CaretPos - 1);
3727 | EZSendMessage(ezWnd->ezParent->ezParent, EZWM_SETTEXT, TextBuffer, 0);
3728 | pTitle = ezWnd->ezParent->ezParent->Extend->Title;
3729 |
3730 | EZRepaint(ezWnd->ezParent->ezParent, 0);
3731 |
3732 | }
3733 | else
3734 | {
3735 | pp_CaretPos = ezWnd->ezParent->ezParent->Extend->iExtend[2];
3736 |
3737 | lstrcpyn(TextBuffer, pTitle, pp_CaretPos + 1);
3738 |
3739 | lstrcpyn(TextBuffer + pp_CaretPos - 1,
3740 | pTitle + pp_CaretPos,
3741 | ezWnd->ezParent->ezParent->Extend->TitleLen - pp_CaretPos + 1);
3742 | EZSendMessage(ezWnd->ezParent->ezParent, EZWM_SETTEXT, TextBuffer, 0);
3743 | EZSendMessage(ezWnd, EZWM_KEYDOWN, 37, 0);//模拟按键
3744 | pp_CaretPos = ezWnd->ezParent->ezParent->Extend->iExtend[2];
3745 | EZRepaint(ezWnd->ezParent->ezParent, 0);
3746 | }
3747 |
3748 | EZShowCaret(ezWnd);
3749 | return 0;
3750 | }
3751 | if (wParam == '\r')
3752 | {
3753 | if (ezWnd->ezParent->ezParent->Extend->iExtend[3] != -1)
3754 | {
3755 | if (ezWnd->ezParent->ezParent->Extend->TitleLen + 2 > ezWnd->ezParent->ezParent->Extend->iExtend[3])
3756 | {
3757 | EZShowCaret(ezWnd);
3758 | return 0;
3759 | }
3760 | }
3761 | //换行符,插入\r\n
3762 | //支持多行?
3763 | if (CHK_ALT_STYLE(ezWnd->ezParent->ezParent->EZStyle, EZES_SINGLELINE))
3764 | {
3765 | EZSendMessage(ezWnd->ezParent->ezParent->ezParent, EZWM_COMMAND, 0, ezWnd->ezParent->ezParent);
3766 | EZShowCaret(ezWnd);
3767 | return 0;
3768 | }
3769 | lstrcpyn(TextBuffer, (TCHAR*)ezWnd->ezParent->ezParent->Extend->Title, pp_CaretPos + 1);
3770 |
3771 | TextBuffer[pp_CaretPos] = wParam;
3772 |
3773 | lstrcpyn(TextBuffer + pp_CaretPos + 1,
3774 | pTitle + pp_CaretPos,
3775 | ezWnd->ezParent->ezParent->Extend->TitleLen - pp_CaretPos + 1);
3776 | //ezWnd->ezParent->ezParent->Extend->iExtend[2]++;
3777 | EZSendMessage(ezWnd->ezParent->ezParent, EZWM_SETTEXT, TextBuffer, 0);
3778 | pTitle = ezWnd->ezParent->ezParent->Extend->Title;
3779 | EZSendMessage(ezWnd, EZWM_KEYDOWN, 39, 0);//模拟按键
3780 | pp_CaretPos = ezWnd->ezParent->ezParent->Extend->iExtend[2];
3781 | EZRepaint(ezWnd->ezParent->ezParent, 0);
3782 |
3783 | wParam = '\n';//出去之后自动插入
3784 | }
3785 |
3786 | if (ezWnd->ezParent->ezParent->Extend->iExtend[3] != -1)
3787 | {
3788 | if (ezWnd->ezParent->ezParent->Extend->TitleLen + 1 > ezWnd->ezParent->ezParent->Extend->iExtend[3])
3789 | {
3790 | EZShowCaret(ezWnd);
3791 | return 0;
3792 | }
3793 | }
3794 |
3795 | lstrcpyn(TextBuffer, (TCHAR*)ezWnd->ezParent->ezParent->Extend->Title, ezWnd->ezParent->ezParent->Extend->iExtend[2] + 1);
3796 |
3797 | TextBuffer[pp_CaretPos] = wParam;
3798 |
3799 | lstrcpyn(TextBuffer + pp_CaretPos + 1,
3800 | pTitle + pp_CaretPos,
3801 | ezWnd->ezParent->ezParent->Extend->TitleLen - pp_CaretPos + 1);
3802 | //ezWnd->ezParent->ezParent->Extend->iExtend[2]++;
3803 | EZSendMessage(ezWnd->ezParent->ezParent, EZWM_SETTEXT, TextBuffer, 0);
3804 | // pTitle = ezWnd->ezParent->ezParent->Extend->Title;
3805 | EZSendMessage(ezWnd, EZWM_KEYDOWN, 39, 0);//模拟按键
3806 | //pp_CaretPos = ezWnd->ezParent->ezParent->Extend->iExtend[2];
3807 | EZRepaint(ezWnd->ezParent->ezParent, 0);
3808 | EZShowCaret(ezWnd);
3809 | return 0;
3810 | case EZWM_KEYDOWN:
3811 |
3812 |
3813 | Text = ezWnd->ezParent->ezParent->Extend->Title;
3814 | iMaxLen = ezWnd->ezParent->ezParent->Extend->TitleLen;
3815 | LastMove = 0;
3816 | xCount = yCount = 0;
3817 | if (ezWnd->ezParent->ezParent->Extend->hFont)
3818 | {
3819 | SelectObject(ezWnd->hdc, ezWnd->ezParent->ezParent->Extend->hFont);
3820 | }
3821 |
3822 | GetTextMetrics(ezWnd->hdc, &tm);
3823 |
3824 | if (wParam == 37 || wParam == 39)
3825 | {
3826 | if (wParam == 37)
3827 | {
3828 | //左
3829 | //看看前面是不到头了,或是 '\n' 或 "\r\n"
3830 | if (ezWnd->ezParent->ezParent->Extend->iExtend[2] == 0)
3831 | {
3832 | //别动了,到头了,不需要任何操作
3833 | return 0;
3834 | }
3835 |
3836 | //是不是换行?
3837 | if (Text[ezWnd->ezParent->ezParent->Extend->iExtend[2] - 1] == '\n')
3838 | {
3839 | //是哪种换行?
3840 | if (Text[ezWnd->ezParent->ezParent->Extend->iExtend[2] - 2] == '\r')
3841 | {
3842 | ezWnd->ezParent->ezParent->Extend->iExtend[2]--;//额外-1
3843 | }
3844 | }
3845 | //无论是不是换行,都要-1.
3846 | ezWnd->ezParent->ezParent->Extend->iExtend[2]--;
3847 | }
3848 | else if (wParam == 39)
3849 | {
3850 | //右
3851 |
3852 | //看看后面是不是到尾了,或是'\n' 或 "\r\n"
3853 | if (ezWnd->ezParent->ezParent->Extend->iExtend[2] == ezWnd->ezParent->ezParent->Extend->TitleLen)
3854 | {
3855 | //别动了,到尾了,不需要任何操作
3856 | return 0;
3857 | }
3858 | //是不是换行?
3859 | if (Text[ezWnd->ezParent->ezParent->Extend->iExtend[2]] == '\r')
3860 | {
3861 | if (Text[ezWnd->ezParent->ezParent->Extend->iExtend[2] + 1] == '\n')
3862 | {
3863 | ezWnd->ezParent->ezParent->Extend->iExtend[2]++;//额外+1
3864 | }
3865 | }
3866 | ezWnd->ezParent->ezParent->Extend->iExtend[2]++;
3867 | }
3868 |
3869 | for (iMove = 0; iMove <= iMaxLen;)
3870 | {
3871 | if (iMove == ezWnd->ezParent->ezParent->Extend->iExtend[2])
3872 | {
3873 |
3874 | GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3875 | //yCount += size.cy;
3876 |
3877 | break;
3878 | }
3879 | if (Text[iMove] == '\0')
3880 | {
3881 | //绘制当前行,并退出。
3882 | //GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3883 | yCount += tm.tmHeight;
3884 |
3885 |
3886 | break;
3887 | }
3888 | else if (Text[iMove] == '\r' && Text[iMove + 1] == '\n')
3889 | {
3890 | //windows换行标记,绘制当前行,重新开始。
3891 | //GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3892 | yCount += tm.tmHeight;
3893 |
3894 | LastMove = iMove + 2;
3895 | iMove++;
3896 |
3897 | }
3898 | else if (Text[iMove] == '\n')
3899 | {
3900 | //Linux换行标记,绘制当前行。
3901 | //GetTextExtentPoint32(ezWnd->hdc, Text + LastMove, iMove - LastMove, &size);
3902 |
3903 | LastMove = iMove + 1;
3904 | yCount += tm.tmHeight;
3905 | }
3906 | iMove++;//放在for里面我怕我搞混....放到这里就不会了
3907 | }
3908 |
3909 | //if (ezWnd->FocusState == 1)
3910 | {
3911 | ezWnd->ezParent->ezParent->Extend->iExtend[0] = size.cx;
3912 | ezWnd->ezParent->ezParent->Extend->iExtend[1] = yCount;
3913 |
3914 |
3915 | EZHideCaret(ezWnd);
3916 |
3917 | if (ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX < 0)
3918 | {
3919 | ezWnd->ezParent->ScrollX -= (ezWnd->ezParent->ezParent->Extend->iExtend[0]);
3920 | }
3921 | if (ezWnd->ezParent->ezParent->Extend->iExtend[1] + ezWnd->ezParent->ScrollY < 0)
3922 | {
3923 | ezWnd->ezParent->ScrollY -= (ezWnd->ezParent->ezParent->Extend->iExtend[1]);
3924 | }
3925 |
3926 | if ((ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX > ezWnd->ezParent->Width) && wParam == 39)
3927 | {
3928 | ezWnd->ezParent->ScrollX -= (ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX - ezWnd->ezParent->Width);
3929 | EZSendMessage(ezWnd->ezParent->ezParent->Extend->hExtend[2],
3930 | EZWM_SETSCROLLPOS,
3931 | ezWnd->ezParent->ezParent->Extend->hExtend[2]->Extend->iExtend[1] - (ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX - ezWnd->ezParent->Width),
3932 | ezWnd->ezParent->ezParent->Extend->hExtend[2]->Extend->iExtend[2] - (ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX - ezWnd->ezParent->Width));
3933 | }
3934 | if (ezWnd->ezParent->ezParent->Extend->iExtend[1] + ezWnd->ezParent->ScrollY + tm.tmHeight > ezWnd->ezParent->Height)
3935 | {
3936 | ezWnd->ezParent->ScrollY -= (ezWnd->ezParent->ezParent->Extend->iExtend[1] + ezWnd->ezParent->ScrollY + tm.tmHeight - ezWnd->ezParent->Height);
3937 | //设置滚动条
3938 | /* EZSendMessage(ezWnd->ezParent->ezParent->Extend->hExtend[1], EZWM_SETSCROLLPOS, ezWnd->ezParent->ezParent->Extend->iExtend[1] - ezWnd->ezParent->ezParent->Extend->hExtend[0]->Height + tm.tmHeight,
3939 | ezWnd->ezParent->ezParent->Extend->iExtend[1] + tm.tmHeight);*/
3940 | }
3941 |
3942 |
3943 |
3944 | EZSetCaretPos(ezWnd, ezWnd->ezParent->ezParent->Extend->iExtend[0], ezWnd->ezParent->ezParent->Extend->iExtend[1]);
3945 |
3946 | EZRepaint(ezWnd->ezParent->ezParent, 0);
3947 | EZShowCaret(ezWnd);
3948 | }
3949 |
3950 |
3951 | }
3952 | else if (wParam == 38 || wParam == 40)
3953 | {
3954 | int iLineBeginCount;
3955 | int iLineCross;
3956 | iLineCross = 0;
3957 | iLineBeginCount = ezWnd->ezParent->ezParent->Extend->iExtend[2];
3958 |
3959 | if (wParam == 38)
3960 | {
3961 | //有没有上一行?
3962 | //往前递归,跨过一个换行符,到达第二个换行符
3963 |
3964 | //有种情况,那就是....这个就是换行符(现在在行尾。)需要我们手动检查并避免这种情况
3965 |
3966 | if (Text[iLineBeginCount] == '\n')
3967 | {
3968 |
3969 | if (Text[iLineBeginCount - 1] == '\r')
3970 | {
3971 | iLineBeginCount--;
3972 | }
3973 | iLineBeginCount--;
3974 | }
3975 |
3976 | for (; iLineBeginCount > 0; iLineBeginCount--)
3977 | {
3978 | if (Text[iLineBeginCount] == '\n')
3979 | {
3980 | if (iLineCross == 1)
3981 | {
3982 | //两个齐了!现在Text[iLineBeginCount]是 '\n',所以要加一
3983 | iLineBeginCount++;
3984 | iLineCross++;
3985 | break;
3986 | }
3987 |
3988 | if (Text[iLineBeginCount - 1] == '\r')
3989 | {
3990 | iLineBeginCount--;
3991 | }
3992 | iLineCross++;
3993 | }
3994 | }
3995 | if (iLineCross == 0)
3996 | {
3997 | //没有上一行
3998 | return 0;
3999 | }
4000 | CaretY = ezWnd->ezParent->ezParent->Extend->iExtend[1] - tm.tmHeight;
4001 |
4002 |
4003 | }
4004 | else if (wParam == 40)
4005 | {
4006 | //有没有下一行?
4007 | //往后递归,跨过一个换行符,到达第二行行首
4008 | int LineCrossRec;
4009 | for (; iLineBeginCount < iMaxLen; iLineBeginCount++)
4010 | {
4011 | if (Text[iLineBeginCount] == '\n')
4012 | {
4013 | iLineBeginCount++;
4014 | iLineCross++;
4015 | break;
4016 |
4017 | }
4018 | else if ((Text[iLineBeginCount] == '\r') && (Text[iLineBeginCount + 1] == '\n'))
4019 | {
4020 |
4021 | iLineBeginCount += 2;
4022 | iLineCross++;
4023 | break;
4024 | }
4025 | }
4026 | if (iLineCross == 0)
4027 | {
4028 | //没有下一行
4029 | return 0;
4030 | }
4031 | CaretY = ezWnd->ezParent->ezParent->Extend->iExtend[1] + tm.tmHeight;
4032 |
4033 | }
4034 |
4035 | //在新行中,找到与现在位置最近的位置。
4036 |
4037 | int iFindCount;
4038 |
4039 | int LastLen, CurrLen;
4040 | LastLen = CurrLen = 0;
4041 |
4042 |
4043 |
4044 |
4045 | BOOL IsFounded;
4046 | IsFounded = FALSE;
4047 |
4048 | for (iMove = iLineBeginCount; iMove <= iMaxLen;)
4049 | {
4050 |
4051 | LastLen = CurrLen;
4052 | GetTextExtentPoint32(ezWnd->hdc, Text + iLineBeginCount, iMove - iLineBeginCount, &size);
4053 | CurrLen = size.cx;
4054 |
4055 | //得到旧位置和新位置的平均位置
4056 | if (ezWnd->ezParent->ezParent->Extend->iExtend[0] <= (LastLen + CurrLen) / 2)
4057 | {
4058 | //插入符号在这个字符往前推一个,也就是在LastCurr的位置
4059 | IsFounded = TRUE;
4060 | //有一种情况是特殊的,那就是行首。在行首,两个值都为0.这样的话,iMove不应-1
4061 | if (iMove == iLineBeginCount)
4062 | {
4063 | ezWnd->ezParent->ezParent->Extend->iExtend[2] = iMove;
4064 | break;
4065 | }
4066 | ezWnd->ezParent->ezParent->Extend->iExtend[2] = iMove - 1;
4067 | break;
4068 |
4069 | }
4070 |
4071 | if ((Text[iMove] == '\0') || (Text[iMove] == '\r' && Text[iMove + 1] == '\n') || (Text[iMove] == '\n'))
4072 | {
4073 | //没找到,在行末尾
4074 | ezWnd->ezParent->ezParent->Extend->iExtend[2] = iMove;
4075 | break;
4076 | }
4077 |
4078 |
4079 | iMove++;//放在for里面我怕我搞混....放到这里就不会了
4080 | }
4081 |
4082 | GetTextExtentPoint32(ezWnd->hdc, Text + iLineBeginCount, iMove - iLineBeginCount, &size);
4083 | CurrLen = size.cx;
4084 | if (IsFounded)
4085 | {
4086 | CaretX = LastLen;
4087 | }
4088 | else
4089 | {
4090 | CaretX = CurrLen;
4091 | }
4092 |
4093 |
4094 |
4095 |
4096 |
4097 | ezWnd->ezParent->ezParent->Extend->iExtend[0] = CaretX;
4098 |
4099 | ezWnd->ezParent->ezParent->Extend->iExtend[1] = CaretY;
4100 |
4101 | if (ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX < 0)
4102 | {
4103 | ezWnd->ezParent->ScrollX -= (ezWnd->ezParent->ezParent->Extend->iExtend[0]);
4104 | }
4105 | if (ezWnd->ezParent->ezParent->Extend->iExtend[1] + ezWnd->ezParent->ScrollY < 0)
4106 | {
4107 | ezWnd->ezParent->ScrollY -= (ezWnd->ezParent->ezParent->Extend->iExtend[1]);
4108 | }
4109 |
4110 |
4111 | if (ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX > ezWnd->ezParent->Width)
4112 | {
4113 | ezWnd->ezParent->ScrollX -= (ezWnd->ezParent->ezParent->Extend->iExtend[0] + ezWnd->ezParent->ScrollX - ezWnd->ezParent->Width);
4114 | }
4115 | if (ezWnd->ezParent->ezParent->Extend->iExtend[1] + ezWnd->ezParent->ScrollY + tm.tmHeight > ezWnd->ezParent->Height)
4116 | {
4117 | ezWnd->ezParent->ScrollY -= (ezWnd->ezParent->ezParent->Extend->iExtend[1] + ezWnd->ezParent->ScrollY + tm.tmHeight - ezWnd->ezParent->Height);
4118 | //设置滚动条
4119 | /*EZSendMessage(ezWnd->ezParent->ezParent->Extend->hExtend[1], EZWM_SETSCROLLPOS, ezWnd->ezParent->ezParent->Extend->iExtend[1] - ezWnd->ezParent->ezParent->Extend->hExtend[0]->Height + tm.tmHeight,
4120 | ezWnd->ezParent->ezParent->Extend->iExtend[1]+ tm.tmHeight);*/
4121 | }
4122 |
4123 | //if (ezWnd->FocusState == 1)
4124 | {
4125 | //EZHideCaret(ezWnd);
4126 | EZSetCaretPos(ezWnd, ezWnd->ezParent->ezParent->Extend->iExtend[0], ezWnd->ezParent->ezParent->Extend->iExtend[1]);
4127 | //EZShowCaret(ezWnd);
4128 | }
4129 | EZRepaint(ezWnd->ezParent->ezParent, NULL);
4130 |
4131 |
4132 |
4133 |
4134 | }
4135 |
4136 |
4137 | return 0;
4138 |
4139 | case EZWM_SETFOCUS:
4140 |
4141 | if (ezWnd->ezParent->ezParent->Extend->hFont)
4142 | {
4143 | SelectObject(ezWnd->hdc, ezWnd->ezParent->ezParent->Extend->hFont);
4144 | }
4145 |
4146 | GetTextMetrics(ezWnd->hdc, &tm);
4147 |
4148 | EZCreateCaret(ezWnd, NULL, 2, tm.tmHeight);
4149 |
4150 | EZShowCaret(ezWnd);
4151 | return 0;
4152 |
4153 | case EZWM_KILLFOCUS:
4154 | if (CHK_ALT_STYLE(ezWnd->ezParent->ezParent->EZStyle, EZES_SINGLELINE))
4155 | {
4156 | EZSendMessage(ezWnd->ezParent->ezParent->ezParent, EZWM_COMMAND, 0, ezWnd->ezParent->ezParent);
4157 | }
4158 | EZHideCaret(ezWnd);
4159 | EZDestroyCaret();
4160 | EZRepaint(ezWnd->ezParent->ezParent, NULL);
4161 | return 0;
4162 |
4163 |
4164 | }
4165 |
4166 | }
4167 |
4168 | EZWNDPROC EZStyle_OverlappedWndProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
4169 | {
4170 | switch (message)
4171 | {
4172 | case EZWM_CREATE:
4173 | if ((ezWnd->EZStyle & MKDW(00000000, 00000000, 00000000, 11111111)) == EZS_OVERLAPPEDWINDOW)
4174 | {
4175 | //这里!!创建关闭,缩小,放大按钮!!!
4176 | int BtnLen = floor(EZWND_CAP_HEIGHT * 1.618);
4177 | ezWnd->Extend->hExtend[1] = CreateEZWindow(ezWnd, ezWnd->Width - BtnLen, 0, BtnLen, EZWND_CAP_HEIGHT, EZStyle_WndCloseProc);
4178 | ezWnd->Extend->hExtend[2] = CreateEZWindow(ezWnd, ezWnd->Width - (BtnLen << 1), 0, BtnLen, EZWND_CAP_HEIGHT, EZStyle_WndMaxProc);
4179 | ezWnd->Extend->hExtend[3] = CreateEZWindow(ezWnd, ezWnd->Width - BtnLen * 3, 0, BtnLen, EZWND_CAP_HEIGHT, EZStyle_WndMinProc);
4180 | //ezWnd->DrawOnNC = 1;
4181 | //MARGINS margins = { 0,10,0,0 };
4182 | //DwmExtendFrameIntoClientArea(ezWnd->hParent, &margins);
4183 | ////Sleep(0);
4184 | }
4185 | return 0;
4186 |
4187 | case EZWM_SETFONT:
4188 |
4189 | if (lParam)
4190 | {
4191 | int OldHeight = ((LOGFONT*)lParam)->lfHeight;
4192 | ((LOGFONT*)lParam)->lfHeight = EZWND_CAP_HEIGHT * 0.6;
4193 | EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
4194 | ((LOGFONT*)lParam)->lfHeight = OldHeight;
4195 | }
4196 | else
4197 | {
4198 | EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
4199 | }
4200 | return 0;
4201 | case EZWM_DRAW:
4202 |
4203 | {
4204 | TCHAR* pTitle;
4205 | pTitle = ((pEZSE)ezWnd->Extend)->Title;
4206 | if (((pEZSE)ezWnd->Extend)->hFont)
4207 | {
4208 | SelectObject(wParam, ((pEZSE)ezWnd->Extend)->hFont);
4209 | TextOut(wParam, 0, 0, pTitle, lstrlen(pTitle));
4210 | }
4211 | else
4212 | {
4213 | HFONT OldFont, hFont;
4214 | hFont = CreateFont(EZWND_CAP_HEIGHT * 0.6, 0, 0, 0, 550, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, TEXT("微软雅黑"));
4215 | OldFont = SelectObject(wParam, hFont);
4216 | TextOut(wParam, EZWND_CAP_HEIGHT >> 1, EZWND_CAP_HEIGHT * 0.2, pTitle, lstrlen(pTitle));
4217 | DeleteObject(SelectObject(wParam, OldFont));
4218 | }
4219 |
4220 | return 0;
4221 | }
4222 |
4223 |
4224 | case EZWM_WINNCDRAW:
4225 | case EZWM_WINNCACTIVATE:
4226 | {
4227 | HDC hdc = GetDC(ezWnd->hParent);
4228 | BitBlt(hdc, 0, 0, ezWnd->Width, ezWnd->Height, ezWnd->TopWndExtend->hdcTop, 0, 0, SRCCOPY);
4229 | ReleaseDC(ezWnd->hParent, hdc);
4230 | //这是我能想出来的最快的操作了
4231 | return 0;
4232 | }
4233 | //
4234 | //case EZWM_LBUTTONDOWN:
4235 | // SendMessage(ezWnd->hParent, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);//拖动窗口。
4236 | //// 这里开始!!!改成处理EZWM_NCHITTEST,添加EZWM_NCHITTEST的递归?
4237 | // return 0;
4238 |
4239 |
4240 | case EZWM_WINNCHITTEST:
4241 | {
4242 | ////检测范围。先问问默认的意见,如果默认说是客户区我们再看是不是标题栏
4243 | int iHTDef = DefWindowProc(ezWnd->hParent, WM_NCHITTEST, wParam, lParam);
4244 | if (iHTDef != HTCLIENT)
4245 | {
4246 | if (iHTDef <= 0)
4247 | {
4248 | iHTDef--;
4249 | }
4250 | return iHTDef;
4251 | }
4252 | RECT rect;
4253 | POINT pt;
4254 |
4255 |
4256 | SetRect(&rect, 0, 0, ezWnd->Width, EZWND_CAP_HEIGHT);
4257 | if ((ezWnd->EZStyle & 0xff) == EZS_OVERLAPPEDWINDOW)//那个0xff是MKDW(00000000,00000000,00000000,11111111)
4258 | {
4259 | rect.right -= 3 * floor(EZWND_CAP_HEIGHT * 1.618);
4260 | }
4261 | pt.x = GET_X_LPARAM(lParam);
4262 | pt.y = GET_Y_LPARAM(lParam);
4263 | ScreenToClient(ezWnd->hParent, &pt);
4264 | if (PtInRect(&rect, pt))
4265 | {
4266 | if (!IsZoomed(ezWnd->hParent))
4267 | {
4268 | if (pt.y <= 3)
4269 | {
4270 | if (pt.x <= 3)
4271 | {
4272 | return EZHTTOPLEFT;
4273 | }
4274 | return EZHTTOP;
4275 | }
4276 | }
4277 |
4278 | return EZHTCAPTION;
4279 | }
4280 | if ((ezWnd->EZStyle & 0xff) == EZS_OVERLAPPED)
4281 | {
4282 | return EZHTCLIENT;
4283 | }
4284 | return 0;
4285 | }
4286 |
4287 | case EZWM_SIZE:
4288 |
4289 | if (ezWnd->Extend->hExtend[0])
4290 | {
4291 | MoveEZWindow(ezWnd->Extend->hExtend[0], 0, EZWND_CAP_HEIGHT, ezWnd->Width, ezWnd->Height - EZWND_CAP_HEIGHT, 0);
4292 | }
4293 |
4294 | if ((ezWnd->EZStyle & MKDW(00000000, 00000000, 00000000, 11111111)) == EZS_OVERLAPPEDWINDOW)
4295 | {
4296 | int BtnLen = floor(EZWND_CAP_HEIGHT * 1.618);
4297 |
4298 | MoveEZWindow(ezWnd->Extend->hExtend[1], ezWnd->Width - BtnLen, 0, BtnLen, EZWND_CAP_HEIGHT, 0);
4299 | MoveEZWindow(ezWnd->Extend->hExtend[2], ezWnd->Width - (BtnLen << 1), 0, BtnLen, EZWND_CAP_HEIGHT, 0);
4300 | MoveEZWindow(ezWnd->Extend->hExtend[3], ezWnd->Width - BtnLen * 3, 0, BtnLen, EZWND_CAP_HEIGHT, 0);
4301 |
4302 | }
4303 | return 0;
4304 | case EZWM_GETMINMAXINFO:
4305 | {
4306 | PMINMAXINFO pMMInfo;
4307 | RECT rect;
4308 | SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
4309 |
4310 | pMMInfo = lParam;
4311 |
4312 |
4313 | AdjustWindowRect(&rect, GetWindowLong(ezWnd->hParent, GWL_STYLE), 0);
4314 |
4315 | pMMInfo->ptMaxPosition.x = rect.left;// -(xborder << 1);
4316 | pMMInfo->ptMaxPosition.y = rect.top;// -(yborder << 1);
4317 | pMMInfo->ptMaxSize.x = rect.right - rect.left;// +(xborder << 2);
4318 | pMMInfo->ptMaxSize.y = rect.bottom - rect.top;// +(yborder << 2);
4319 | return 1;
4320 | }
4321 |
4322 | //case EZWM_SETFOCUS:
4323 | //case EZWM_KILLFOCUS:
4324 | // EZRepaint(ezWnd, 0);
4325 | //这里!!!如果,是子窗口收到了呢?这样肯定不行。修改这里的EZWM_SETFOCUS EZWM_KILLFOCUS
4326 |
4327 | //return 0;
4328 |
4329 |
4330 | case EZWM_WINNCCALCSIZE:
4331 | {
4332 | if (wParam)
4333 | {
4334 |
4335 | if (IsZoomed(ezWnd->hParent))
4336 | {
4337 | return 0;
4338 | }
4339 | else
4340 | {
4341 |
4342 | NCCALCSIZE_PARAMS* NCCSParam;
4343 |
4344 | NCCSParam = (NCCALCSIZE_PARAMS*)lParam;
4345 | //RECT rect = { 0};
4346 |
4347 | AdjustWindowRect(&(NCCSParam->rgrc[0]), GetWindowLong(ezWnd->hParent, GWL_STYLE), 0);
4348 |
4349 | NCCSParam->rgrc[0].left += 4;
4350 | NCCSParam->rgrc[0].top += 1;//在标题栏上面留出一些,这里先少加一些
4351 | NCCSParam->rgrc[0].right -= 4;
4352 | NCCSParam->rgrc[0].bottom -= 4;
4353 |
4354 | return 0;
4355 | }
4356 |
4357 | }
4358 | // InvalidateRect(hwnd, 0, 0);
4359 | return 1;
4360 | }
4361 |
4362 | case EZWM_CLOSE:
4363 | return EZSendMessage(ezWnd->Extend->hExtend[0], EZWM_CLOSE, wParam, lParam);
4364 |
4365 |
4366 |
4367 | }
4368 | return EZStyle_DefaultProc(ezWnd, message, wParam, lParam);
4369 | }
4370 |
4371 |
4372 | EZWNDPROC EZStyle_WndMinProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
4373 | {
4374 | struct EZWndMinBtnInfo
4375 | {
4376 | BOOL MouseHold;
4377 | int IDTimer;
4378 | }*pInfo;
4379 |
4380 | switch (message)
4381 | {
4382 | case EZWM_CREATE:
4383 | ezWnd->Extend = malloc(sizeof(struct EZWndMinBtnInfo));
4384 | pInfo = ezWnd->Extend;
4385 | pInfo->IDTimer = -1;
4386 | pInfo->MouseHold = 0;
4387 | ezWnd->Transparent = 0;
4388 | return 0;
4389 | case EZWM_MOUSECOME:
4390 |
4391 | pInfo = ezWnd->Extend;
4392 | if (pInfo->IDTimer == -1)
4393 | {
4394 | pInfo->IDTimer = SetEZTimer(ezWnd, 32);
4395 | }
4396 |
4397 | return 0;
4398 |
4399 | case EZWM_MOUSELEAVE:
4400 | pInfo = ezWnd->Extend;
4401 | if (pInfo->IDTimer == -1)
4402 | {
4403 | pInfo->IDTimer = SetEZTimer(ezWnd, 32);
4404 | }
4405 | return 0;
4406 |
4407 | case EZWM_LBUTTONDOWN:
4408 | pInfo = ezWnd->Extend;
4409 | if (pInfo->MouseHold == 0)
4410 | {
4411 | pInfo->MouseHold = 1;
4412 | EZCaptureMouse(ezWnd);
4413 | }
4414 | return 0;
4415 |
4416 | case EZWM_LBUTTONUP:
4417 | pInfo = ezWnd->Extend;
4418 | if (pInfo->MouseHold == 0)
4419 | {
4420 | //无视
4421 | }
4422 | else
4423 | {
4424 | //发送控制信号
4425 | ShowWindow(ezWnd->hParent, SW_MINIMIZE);
4426 | pInfo->MouseHold = 0;
4427 | EZReleaseMouse(ezWnd);
4428 | }
4429 | return 0;
4430 | case EZWM_RELEASEMOUSE:
4431 | pInfo = ezWnd->Extend;
4432 | pInfo->MouseHold = FALSE;
4433 | return 0;
4434 | case EZWM_TIMER:
4435 | pInfo = ezWnd->Extend;
4436 | if (ezWnd->MouseOn)
4437 | {
4438 | //透明度减少
4439 |
4440 | if ((int)(ezWnd->Transparent) + 12 >= 48)
4441 | {
4442 | ezWnd->Transparent = 48;
4443 | KillEZTimer(ezWnd, pInfo->IDTimer);
4444 | pInfo->IDTimer = -1;
4445 | }
4446 | else
4447 | {
4448 | ezWnd->Transparent += 12;
4449 | }
4450 | }
4451 | else
4452 | {
4453 |
4454 | if ((int)(ezWnd->Transparent) - 6 <= 0)
4455 | {
4456 | ezWnd->Transparent = 0;
4457 | KillEZTimer(ezWnd, pInfo->IDTimer);
4458 | pInfo->IDTimer = -1;
4459 | }
4460 | else
4461 | {
4462 | ezWnd->Transparent -= 6;
4463 | }
4464 | }
4465 |
4466 | EZRepaint(ezWnd, 0);
4467 | return 0;
4468 |
4469 | case EZWM_TRANSDRAW:
4470 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, BLACKNESS);
4471 | return 0;
4472 |
4473 | case EZWM_DRAW:
4474 | MoveToEx(wParam, ezWnd->Width * (1 - 0.618), ezWnd->Height / 2, NULL);
4475 | LineTo(wParam, ezWnd->Width * 0.618, ezWnd->Height / 2);
4476 | return 0;
4477 | case EZWM_DESTROY:
4478 | free(ezWnd->Extend);
4479 | return 0;
4480 | }
4481 | }
4482 |
4483 | EZWNDPROC EZStyle_WndMaxProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
4484 | {
4485 | struct EZWndMaxBtnInfo
4486 | {
4487 | BOOL MouseHold;
4488 | int IDTimer;
4489 | }*pInfo;
4490 |
4491 | switch (message)
4492 | {
4493 | case EZWM_CREATE:
4494 | ezWnd->Extend = malloc(sizeof(struct EZWndMaxBtnInfo));
4495 | pInfo = ezWnd->Extend;
4496 | pInfo->IDTimer = -1;
4497 | pInfo->MouseHold = 0;
4498 | ezWnd->Transparent = 0;
4499 | return 0;
4500 | case EZWM_MOUSECOME:
4501 |
4502 | pInfo = ezWnd->Extend;
4503 | if (pInfo->IDTimer == -1)
4504 | {
4505 | pInfo->IDTimer = SetEZTimer(ezWnd, 32);
4506 | }
4507 |
4508 | return 0;
4509 |
4510 | case EZWM_MOUSELEAVE:
4511 | pInfo = ezWnd->Extend;
4512 | if (pInfo->IDTimer == -1)
4513 | {
4514 | pInfo->IDTimer = SetEZTimer(ezWnd, 32);
4515 | }
4516 | return 0;
4517 |
4518 | case EZWM_LBUTTONDOWN:
4519 | pInfo = ezWnd->Extend;
4520 | if (pInfo->MouseHold == 0)
4521 | {
4522 | pInfo->MouseHold = 1;
4523 | EZCaptureMouse(ezWnd);
4524 | }
4525 | return 0;
4526 |
4527 | case EZWM_LBUTTONUP:
4528 | pInfo = ezWnd->Extend;
4529 | if (pInfo->MouseHold == 0)
4530 | {
4531 | //无视
4532 | }
4533 | else
4534 | {
4535 | //发送控制信号
4536 | if (IsZoomed(ezWnd->hParent))
4537 | {
4538 | ShowWindow(ezWnd->hParent, SW_RESTORE);
4539 | }
4540 | else
4541 | {
4542 | ShowWindow(ezWnd->hParent, SW_MAXIMIZE);
4543 | }
4544 | pInfo->MouseHold = 0;
4545 | EZReleaseMouse(ezWnd);
4546 | }
4547 | return 0;
4548 | case EZWM_RELEASEMOUSE:
4549 | pInfo = ezWnd->Extend;
4550 | pInfo->MouseHold = FALSE;
4551 | return 0;
4552 | case EZWM_TIMER:
4553 | pInfo = ezWnd->Extend;
4554 | if (ezWnd->MouseOn)
4555 | {
4556 | //透明度减少
4557 |
4558 | if ((int)(ezWnd->Transparent) + 12 >= 48)
4559 | {
4560 | ezWnd->Transparent = 48;
4561 | KillEZTimer(ezWnd, pInfo->IDTimer);
4562 | pInfo->IDTimer = -1;
4563 | }
4564 | else
4565 | {
4566 | ezWnd->Transparent += 12;
4567 | }
4568 | }
4569 | else
4570 | {
4571 |
4572 | if ((int)(ezWnd->Transparent) - 6 <= 0)
4573 | {
4574 | ezWnd->Transparent = 0;
4575 | KillEZTimer(ezWnd, pInfo->IDTimer);
4576 | pInfo->IDTimer = -1;
4577 | }
4578 | else
4579 | {
4580 | ezWnd->Transparent -= 6;
4581 | }
4582 | }
4583 |
4584 | EZRepaint(ezWnd, 0);
4585 | return 0;
4586 |
4587 | case EZWM_TRANSDRAW:
4588 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, BLACKNESS);
4589 | return 0;
4590 |
4591 | case EZWM_DRAW:
4592 |
4593 | {
4594 | double Length = floor(ezWnd->Width * ((1 - 0.618) / 2));
4595 | int LeftPt, RightPt, TopPt, BottomPt;
4596 | LeftPt = floor((ezWnd->Width - Length) / 2);
4597 | RightPt = ceil((ezWnd->Width + Length) / 2);
4598 | TopPt = floor((ezWnd->Height - Length) / 2);
4599 | BottomPt = ceil((ezWnd->Height + Length) / 2);
4600 |
4601 | SelectObject(wParam, GetStockObject(NULL_BRUSH));
4602 | SelectObject(wParam, GetStockObject(BLACK_PEN));
4603 | Rectangle(wParam, LeftPt, TopPt, RightPt, BottomPt);
4604 |
4605 | return 0;
4606 | }
4607 |
4608 | case EZWM_DESTROY:
4609 | free(ezWnd->Extend);
4610 | return 0;
4611 | }
4612 | }
4613 |
4614 |
4615 | EZWNDPROC EZStyle_WndCloseProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
4616 | {
4617 | struct EZWndCloseBtnInfo
4618 | {
4619 | BOOL MouseHold;
4620 | int IDTimer;
4621 | HBRUSH hBrush;
4622 | HDC hMemDC;
4623 | }*pInfo;
4624 |
4625 | switch (message)
4626 | {
4627 | case EZWM_CREATE:
4628 | ezWnd->Extend = malloc(sizeof(struct EZWndCloseBtnInfo));
4629 | pInfo = ezWnd->Extend;
4630 | pInfo->hBrush = CreateSolidBrush(RGB(200, 0, 0));
4631 | pInfo->IDTimer = -1;
4632 | pInfo->MouseHold = 0;
4633 | pInfo->hMemDC = GetMemDC(ezWnd->hdc, ezWnd->Width * STRETCH, ezWnd->Height * STRETCH);
4634 | ezWnd->Transparent = 0;
4635 | return 0;
4636 | case EZWM_SIZE:
4637 | pInfo = ezWnd->Extend;
4638 |
4639 | DeleteMemDC(pInfo->hMemDC);
4640 | pInfo->hMemDC = GetMemDC(ezWnd->hdc, ezWnd->Width * STRETCH, ezWnd->Height * STRETCH);
4641 | return 0;
4642 | case EZWM_MOUSECOME:
4643 |
4644 | pInfo = ezWnd->Extend;
4645 | if (pInfo->IDTimer == -1)
4646 | {
4647 | pInfo->IDTimer = SetEZTimer(ezWnd, 32);
4648 | }
4649 |
4650 | return 0;
4651 |
4652 | case EZWM_MOUSELEAVE:
4653 | pInfo = ezWnd->Extend;
4654 | if (pInfo->IDTimer == -1)
4655 | {
4656 | pInfo->IDTimer = SetEZTimer(ezWnd, 32);
4657 | }
4658 | return 0;
4659 |
4660 | case EZWM_LBUTTONDOWN:
4661 | pInfo = ezWnd->Extend;
4662 | if (pInfo->MouseHold == 0)
4663 | {
4664 | pInfo->MouseHold = 1;
4665 | EZCaptureMouse(ezWnd);
4666 | }
4667 | return 0;
4668 |
4669 | case EZWM_LBUTTONUP:
4670 | pInfo = ezWnd->Extend;
4671 | if (pInfo->MouseHold == 0)
4672 | {
4673 | //无视
4674 | }
4675 | else
4676 | {
4677 | //发送控制信号
4678 | if (EZSendMessage(ezWnd->ezParent->Extend->hExtend[0], EZWM_CLOSE, 0, 0) == EZCLOSE_WINDOW)
4679 | {
4680 | DestroyEZWindow(ezWnd->ezParent);
4681 | }
4682 | pInfo->MouseHold = 0;
4683 | EZReleaseMouse(ezWnd);
4684 | }
4685 |
4686 | return 0;
4687 | case EZWM_RELEASEMOUSE:
4688 | pInfo = ezWnd->Extend;
4689 | pInfo->MouseHold = FALSE;
4690 | return 0;
4691 |
4692 | case EZWM_TIMER:
4693 | pInfo = ezWnd->Extend;
4694 | if (ezWnd->MouseOn)
4695 | {
4696 | if ((int)(ezWnd->Transparent) + 64 >= 255)
4697 | {
4698 | ezWnd->Transparent = 255;
4699 | KillEZTimer(ezWnd, pInfo->IDTimer);
4700 | pInfo->IDTimer = -1;
4701 | }
4702 | else
4703 | {
4704 | ezWnd->Transparent += 64;
4705 | }
4706 | }
4707 | else
4708 | {
4709 |
4710 | if ((int)(ezWnd->Transparent) - 32 <= 0)
4711 | {
4712 | ezWnd->Transparent = 0;
4713 | KillEZTimer(ezWnd, pInfo->IDTimer);
4714 | pInfo->IDTimer = -1;
4715 | }
4716 | else
4717 | {
4718 | ezWnd->Transparent -= 32;
4719 | }
4720 | }
4721 |
4722 | EZRepaint(ezWnd, 0);
4723 | return 0;
4724 |
4725 | case EZWM_TRANSDRAW:
4726 | pInfo = ezWnd->Extend;
4727 | SelectObject(wParam, pInfo->hBrush);
4728 | PatBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, PATCOPY);
4729 | return 0;
4730 | case EZWM_DRAW:
4731 | {
4732 | HPEN hOldPen;
4733 | //hPen = CreatePen(PS_SOLID, STRETCH, RGB(0, 0, 0));
4734 | pInfo = ezWnd->Extend;
4735 | SetStretchBltMode(wParam, HALFTONE);
4736 | SetStretchBltMode(pInfo->hMemDC, HALFTONE);
4737 | StretchBlt(pInfo->hMemDC, 0, 0, ezWnd->Width * STRETCH, ezWnd->Height * STRETCH, wParam, 0, 0, ezWnd->Width, ezWnd->Height, SRCCOPY);
4738 |
4739 | hOldPen = SelectObject(pInfo->hMemDC, CreatePen(PS_SOLID, STRETCH, RGB(ezWnd->Transparent, ezWnd->Transparent, ezWnd->Transparent)));
4740 |
4741 | int Length = floor(ezWnd->Width * (2 * 0.618 - 1));
4742 | int LeftPt, RightPt;
4743 | LeftPt = ceil(ezWnd->Width * STRETCH * (1 - 0.618));
4744 | RightPt = floor(ezWnd->Width * STRETCH * (0.618));
4745 | MoveToEx(pInfo->hMemDC, LeftPt, STRETCH * (ezWnd->Height - Length) / 2, 0);
4746 | LineTo(pInfo->hMemDC, RightPt, STRETCH * (ezWnd->Height + Length) / 2);
4747 |
4748 | MoveToEx(pInfo->hMemDC, RightPt, STRETCH * (ezWnd->Height - Length) / 2, 0);
4749 | LineTo(pInfo->hMemDC, LeftPt, STRETCH * (ezWnd->Height + Length) / 2);
4750 |
4751 | DeleteObject(SelectObject(pInfo->hMemDC, hOldPen));
4752 |
4753 | StretchBlt(wParam, 0, 0, ezWnd->Width, ezWnd->Height, pInfo->hMemDC, 0, 0, ezWnd->Width * STRETCH, ezWnd->Height * STRETCH, SRCCOPY);
4754 | return 0;
4755 | }
4756 |
4757 | case EZWM_DESTROY:
4758 | pInfo = ezWnd->Extend;
4759 | DeleteObject(pInfo->hBrush);
4760 | DeleteMemDC(pInfo->hMemDC);
4761 | free(ezWnd->Extend);
4762 | return 0;
4763 | }
4764 |
4765 |
4766 | }
4767 |
--------------------------------------------------------------------------------
/EasyWindow 4.0/EasyWindow.h:
--------------------------------------------------------------------------------
1 |
2 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 |
4 | * EasyWindow.h
5 |
6 | * EasyWindow 库源文件 版本 3.0 Copyright (c) 2017 y.h. All rights reserved.
7 |
8 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
9 |
10 |
11 | //*********************************************************************************************************
12 | // 头文件等预编译指令
13 | //*********************************************************************************************************
14 |
15 |
16 | #pragma once
17 |
18 | #pragma region HeadFiles
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #pragma endregion
25 |
26 |
27 | #pragma region LinkLibs
28 |
29 | #pragma comment(lib,"msimg32.lib")
30 |
31 | #pragma endregion
32 |
33 | //*********************************************************************************************************
34 | // 常量宏定义
35 | //*********************************************************************************************************
36 |
37 |
38 | #pragma region EasyWindowMessageDefines
39 | //下面是对EasyWindows消息的定义
40 |
41 | //常规消息
42 | #define EZWM_CREATE 1
43 | #define EZWM_DESTROY 2
44 | #define EZWM_SIZE 3
45 | #define EZWM_TIMER 4
46 |
47 | #define EZWM_ENABLE 5
48 | #define EZWM_DISABLE 6
49 |
50 | #define EZWM_SETFOCUS 7
51 | #define EZWM_KILLFOCUS 8
52 |
53 | #define EZWM_ACTIVATE 9
54 | #define EZWM_ACTIVATEAPP 10
55 | #define EZWM_WINNCACTIVATE 11//啊。。这个返回值啥用都没,被忽视了。只不过是个通知。注意,在收到这条消息之前已经调用过DefWndProc了
56 |
57 | #define EZWM_CLOSE 12
58 |
59 | #define EZCLOSE_WINDOW 0//响应EZWM_CLOSE时,用于声明关闭窗口
60 | #define EZDO_NOT_CLOSE 1//响应EZWM_CLOSE时,声明请勿关闭窗口
61 |
62 |
63 |
64 |
65 | //窗口大小消息
66 | #define EZWM_GETMINMAXINFO 13 //如果进行了处理,请返回非零值。
67 |
68 | #define EZWM_WINNCCALCSIZE 14//如果进行了处理,返回值是WM_NCCALCSIZE的返回值+1,没处理返回值为0
69 |
70 | //绘制有关消息
71 | #define EZWM_DRAW 101//绘制,不透明
72 | #define EZWM_TRANSDRAW 102//透明绘制,该次绘制将以透明形式覆盖。
73 | #define EZWM_COVERCHILD 103//覆盖子窗口绘制,如需透明自己搞(目前)
74 | #define EZWM_MAPDC 104//映射DC,wParam为一个RECT指针,指明了子窗口范围。修改该结构体即可,lparam是需要映射的子窗口。
75 | #define EZWM_REDRAWFINISH 105//该窗口重绘完成(可以自己把ezWnd->hdc复制到别的地方,用于同步窗口内容啊什么的)
76 |
77 |
78 | #define EZWM_WINNCDRAW 106//Windows父窗口非客户区要重绘
79 |
80 | //鼠标消息
81 | #define EZWM_LBUTTONDOWN 201
82 | #define EZWM_LBUTTONUP 202
83 | #define EZWM_RBUTTONDOWN 203
84 | #define EZWM_RBUTTONUP 204
85 | #define EZWM_MOUSEMOVE 205//这个消息如果WPARAM为1,(仅发送到EZ主窗口)说明从Win窗口出去了
86 | #define EZWM_MOUSECOME 206
87 | #define EZWM_MOUSELEAVE 207
88 |
89 | #define EZWM_WINNCHITTEST 208//讲道理我觉得这个...也可以放在鼠标?虽然这是一个非客户区消息。只有Win父窗口会收到这个消息
90 | #define EZWM_NCHITTEST 209//
91 |
92 |
93 | #define EZHTERROR (-3)
94 | #define EZHTTRANSPARENT (-2)
95 | #define EZHTNOWHERE -1
96 | #define EZHTCLIENT 1
97 | #define EZHTCAPTION 2
98 | #define EZHTSYSMENU 3
99 | #define EZHTGROWBOX 4
100 | #define EZHTSIZE HTGROWBOX
101 | #define EZHTMENU 5
102 | #define EZHTHSCROLL 6
103 | #define EZHTVSCROLL 7
104 | #define EZHTMINBUTTON 8
105 | #define EZHTMAXBUTTON 9
106 | #define EZHTLEFT 10
107 | #define EZHTRIGHT 11
108 | #define EZHTTOP 12
109 | #define EZHTTOPLEFT 13
110 | #define EZHTTOPRIGHT 14
111 | #define EZHTBOTTOM 15
112 | #define EZHTBOTTOMLEFT 16
113 | #define EZHTBOTTOMRIGHT 17
114 | #define EZHTBORDER 18
115 | #define EZHTREDUCE HTMINBUTTON
116 | #define EZHTZOOM HTMAXBUTTON
117 | #define EZHTSIZEFIRST HTLEFT
118 | #define EZHTSIZELAST HTBOTTOMRIGHT
119 | #if(WINVER >= 0x0400)
120 | #define EZHTOBJECT 19
121 | #define EZHTCLOSE 20
122 | #define EZHTHELP 21
123 | #endif
124 |
125 |
126 |
127 |
128 | #define EZWM_CAPTUREMOUSE 251
129 | #define EZWM_RELEASEMOUSE 252
130 |
131 | //键盘消息
132 | #define EZWM_CHAR 301
133 | #define EZWM_KEYDOWN 302
134 | #define EZWM_KEYUP 303
135 |
136 |
137 | //滚动条消息
138 | #define EZWM_VSCROLL 401
139 | #define EZWM_HSCROLL 402
140 |
141 |
142 | //各类设置消息
143 |
144 | #define EZWM_SETCOLOR 501//wParam是背景颜色,lParam是前景颜色。该消息会引起重绘。
145 | #define EZWM_SETFONT 502//设置字体,wParam和lParam二选一,都空则设置该风格默认字体。wParam是HFONT(用户申请释放),lParam是LOGFONT(EZWnd申请释放)。wParam优先
146 | #define EZWM_SETTEXT 503//设置文本,wParam是文本。lParam是长度,为0则自动获取长度
147 | #define EZWM_SETTEXTALIGN 504//文本对齐选项,wParam传递参数。临时设置为DrawText的绘制参数。后期将继续改进
148 | #define EZWM_SETMAXTEXT 505//设置最大文本长度,wParam是最大长度,-1没有限制。已经超过了不会进行处理。
149 |
150 | #define EZWM_SETSCROLLRANGE 506//设置滚动条范围,wParam是最大滚动范围。
151 | #define EZWM_SETSCROLLPOS 507//设置滚动条位置,wParam lParam,是上下滚动位置。wParam < lParam <= Max
152 |
153 |
154 |
155 | //控制消息
156 | #define EZWM_COMMAND 601//恩,含义不解释了。比Windows简单一些,lParam是句柄,wParam是通知的附加信息。
157 | #define EZWM_SCROLLPOSCHANGE 602//滚动条位置动了,wParam 是上滚动位置,lParam是句柄。
158 |
159 |
160 | //通知类消息
161 | #define EZWM_USER_NOTIFY 701//自由使用,自己弄得清楚通知形式就OK
162 | #define EZWM_WINWND_CHECKSTATE 702//要求Win窗口检查显示状态。
163 |
164 |
165 |
166 | //获取信息消息
167 | #define EZWM_GETTEXT 801//获得文本,wParam缓冲区,lParam最大计数
168 |
169 |
170 | //完全自定义消息
171 |
172 | #define EZWM_USER 1000
173 |
174 |
175 | //内置消息
176 | #define SEZWM_COPYDC 2001//将存储DC复制到父窗口。
177 | #define SEZWM_REDRAW 2002//重绘到内存DC
178 |
179 |
180 | #define SEZWM_KILLFOCUS 2005//有焦点的窗口失去焦点。wP排除检查。
181 |
182 |
183 | // #define SEZWM_CAPTURE 2005//有一个窗口申请捕获老鼠。已经捕获了的赶紧放掉!
184 |
185 | #pragma endregion
186 |
187 |
188 |
189 |
190 | #pragma region EZStyleDefines
191 |
192 | #define MKDW(a,b,c,d) 0b ## a ## b ## c ## d
193 |
194 | #define CHK_STYLE(Style,ChkStyle) (Style ^ ChkStyle)> 0 ? FALSE : TRUE
195 | #define CHK_ALT_STYLE(Style,AltStyle) (((Style) & (AltStyle)) > 0 ? (TRUE) : (FALSE))
196 |
197 | //*****可选择属性 - 定义
198 |
199 | // -|-
200 | #define EZS_CHILD MKDW(00000000,00000000,00000001,00000000)
201 | #define EZS_PARENT MKDW(00000000,00000000,00000000,00000000)
202 |
203 | // -|-
204 | #define EZS_BORDER MKDW(00000000,00000000,00000010,00000000)
205 | #define EZS_NO_BORDER MKDW(00000000,00000000,00000000,00000000)
206 |
207 | // -|-
208 | #define EZS_CAPTION MKDW(00000000,00000000,00000100,00000000)
209 | #define EZS_NO_CAPTION MKDW(00000000,00000000,00000000,00000000)
210 |
211 |
212 |
213 | // -|-
214 | #define EZS_MINIMIZEBOX MKDW(00000000,00000000,00001000,00000000)//最小化按钮
215 | #define EZS_NO_MINIMIZEBOX MKDW(00000000,00000000,00000000,00000000)
216 |
217 | // -|-
218 | #define EZS_MAXIMIZEBOX MKDW(00000000,00000000,00010000,00000000)//最大化按钮
219 | #define EZS_NO_MAXIMIZEBOX MKDW(00000000,00000000,00000000,00000000)
220 |
221 | // -|-
222 | #define EZS_CLOSEBOX MKDW(00000000,00000000,00100000,00000000)//关闭按钮
223 | #define EZS_NO_CLOSEBOX MKDW(00000000,00000000,00000000,00000000)
224 |
225 | // -|-
226 | #define EZS_VSCROLL MKDW(00000000,00000000,01000000,00000000)//竖直
227 | #define EZS_NO_VSCROLL MKDW(00000000,00000000,00000000,00000000)
228 |
229 | // -|-
230 | #define EZS_HSCROLL MKDW(00000000,00000000,10000000,00000000)//水平
231 | #define EZS_NO_HSCROLL MKDW(00000000,00000000,00000000,00000000)
232 |
233 |
234 | //*****窗口主要属性 - 定义
235 | //子窗口篇
236 | #define EZS_STATIC MKDW(00000000,00000000,00000000,00000001)
237 | #define EZS_BUTTON MKDW(00000000,00000000,00000000,00000010)
238 | //这两个可不是带有滚动控件的窗口,这两个就是滚动控件。
239 | #define EZS_CHILD_VSCROLL MKDW(00000000,00000000,00000000,00000011)//竖直
240 | #define EZS_CHILD_HSCROLL MKDW(00000000,00000000,00000000,00000100)//水平
241 |
242 |
243 | #define EZS_EDIT MKDW(00000000,00000000,00000000,00000101)//编辑框
244 |
245 |
246 |
247 | //父窗口篇
248 | #define EZS_POPUP MKDW(00000000,00000000,00000000,00000001)
249 | #define EZS_OVERLAPPED MKDW(00000000,00000000,00000000,00000010)
250 | #define EZS_POPUPWINDOW MKDW(00000000,00000000,00000000,00000011)
251 | #define EZS_OVERLAPPEDWINDOW MKDW(00000000, 00000000, 00000000, 00000100)
252 |
253 | //有关父窗口的其他定义
254 | #define EZWND_CAP_HEIGHT 30
255 |
256 |
257 | //*****窗口细分属性 - 定义
258 | //***子窗口篇
259 | //按钮篇
260 | #define EZBS_PUSHBUTTON MKDW(00000000,00000000,00000000,00000000)//默认,什么都不带就是普通按钮
261 | #define EZBS_RADIOBUTTON MKDW(00000001,00000000,00000000,00000000)
262 |
263 | //编辑框篇
264 | // -|-
265 | #define EZES_SINGLELINE MKDW(10000000,00000000,00000000,00000000)
266 | // -|-
267 | #define EZES_MULTILINE MKDW(00000000,00000000,00000000,00000000)//默认
268 |
269 | #pragma endregion
270 |
271 |
272 | #pragma region DialogStyleDefines
273 | #define EZDLG_MASK 1//在父窗口上渐变显示一个遮罩。如果没有该选项,颜色参数将被忽略
274 |
275 | #define EZDLG_CENTER 2//始终居中显示,忽略x,y参数。
276 |
277 | #pragma endregion
278 |
279 |
280 | #pragma region OtherDefines
281 |
282 | //各种其他宏定义
283 |
284 | //内部文本最大长度
285 | #define MAX_TEXT 16384
286 |
287 | #define GET_EXTEND(ezWnd,Extend) (((pEZSE)(ezWnd))->Extend)
288 |
289 | //抗锯齿
290 | #define STRETCH 3.0
291 |
292 | #pragma endregion
293 |
294 |
295 | #pragma region EasyWindowClassName
296 |
297 | #define EZWindowClass TEXT("EasyWindowClass")
298 |
299 | #pragma endregion
300 |
301 |
302 | //*******************************************************************************************
303 | // 结构体声明
304 | //*******************************************************************************************
305 |
306 |
307 | typedef struct tagEZWND* EZWND;//对EZWINDOW结构体的定义。EZWND是指向该结构的指针。
308 |
309 |
310 |
311 | #pragma region ExtendForStyles
312 | typedef struct tagExtendStyle
313 | {
314 | PBYTE Title;//每次动态申请,最多不得超过 MAX_TEXT
315 | int TitleLen;
316 |
317 | //UI相关
318 | COLORREF BackGroundColor;
319 | COLORREF ForeGroundColor;
320 |
321 | HFONT hFont;
322 |
323 | DWORD TextAlign;
324 | int IsFontUserControl;//字体谁负责释放?(-1 之前没字体,0 用户控制,1 EZWnd负责,2 默认字体)
325 |
326 |
327 | //鼠标相关
328 | int MouseHold;//用于判断鼠标是否按着,比如按钮控件就会用得到。当然用来记录鼠标按的时间长短也没问题
329 |
330 | //自由使用扩展
331 | int iExtend[4];//4个整型扩展 程序可以自由根据控件类型使用。
332 | EZWND hExtend[8];//8个EZWND扩展 程序可以自由根据控件类型使用。
333 | void* vExtend[4];//4个指针扩展 程序可以自由根据控件类型使用。
334 |
335 | }EZSE, * pEZSE;
336 | #pragma endregion
337 |
338 |
339 | typedef INT(*EZWNDPROC)(EZWND, int, WPARAM, LPARAM);//回调函数定义
340 |
341 | #define MAX_EZ_TIMER 64//64个计时器
342 | #define EZTIMER_BASE 10000
343 |
344 | #pragma region TopWindowExtend
345 | typedef struct tagezTopWindowExtend
346 | {
347 | EZWND FocusWindow;//拥有输入焦点的窗口
348 | EZWND CptMouseWindow;//捕获了鼠标的
349 | EZWND MouseOnWnd;//鼠标在上面的
350 |
351 |
352 | HDC hdcTop;//顶层窗口申请内存使用,其他窗口而言,这只是一个空的句柄。
353 |
354 | // int TimerNum;//当前使用了的计时器数量
355 |
356 | struct ezTimer
357 | {
358 | int WinTimerID;
359 |
360 | EZWND ezWnd;
361 | } Timer[MAX_EZ_TIMER];
362 |
363 | }TopWndExt, * pTWE;
364 | #pragma endregion
365 |
366 |
367 | #pragma region ezWndStruct
368 |
369 |
370 | #define WND_TIMER_NUM 8
371 | typedef struct tagEZWND
372 | {
373 | //有关窗口信息
374 | int x;
375 | int y;
376 | int Width;
377 | int Height;
378 |
379 | //设置这两个变量可以滚动客户区内的子窗口,以及鼠标输入坐标。
380 | int ScrollX;
381 | int ScrollY;
382 |
383 | int px;//x坐标(相对于主窗口)
384 | int py;//y坐标(相对于主窗口)
385 | RECT VisibleRect;//可见的矩形(相对于主窗口)
386 | BOOL IsVsbRectNull;
387 | //有关绘制状态****************************
388 | BYTE Transparent;//透明度,0是完全透明,255不透明
389 |
390 | //有关窗口状态****************************
391 | int FocusState;//输入焦点状态。0-无焦点。1-有焦点
392 | int MouseMsgRecv;//鼠标消息接受情况。 1:正常接受,2:透明
393 | int ShowState;//显示状态(和鼠标无关)1:正常显示,2:透明
394 |
395 | //有关鼠标****************************
396 | BOOL MouseOn;//鼠标在该窗口上。
397 |
398 | //有关绘制****************************
399 | HDC hdc;//一个绘制空间。始终存在,直到窗口被销毁。窗口绘制就绘制在这个上面。
400 | //HDC hdcCopy;//用于加速绘制,下一个窗口可以直接复制的DC。
401 |
402 | BOOL bOpaque;//优化用,关闭父窗口拷贝。
403 |
404 | //BOOL DrawOnNC;//是否覆盖非客户区绘制,换言之绘制的时候是否用GetWindowDC
405 | BOOL Update;//更新区域,0为无需更新,1为发生了改变,需要更新。
406 |
407 | //有关关联窗口****************************
408 | EZWNDPROC ezWndProc;//窗口过程
409 | EZWND ezParent;//EZ父窗口
410 | EZWND ezRootParent;//EZ祖先窗口
411 |
412 | BOOL IsTopWindow;//用于指示是否是顶层EZ窗口。
413 | HWND hParent;//祖先Win窗口.
414 |
415 | BOOL IsWinWnd;//是否链接到了一个Win子窗口
416 | HWND hChild;//子Win窗口
417 | WNDPROC WinChildProc;
418 |
419 | EZWND FirstChild;//第一个子窗口
420 | EZWND LastEZWnd;//(和这个窗口)并列的上一个窗口
421 | EZWND NextEZWnd;//(和这个窗口)并列的下一个窗口
422 |
423 |
424 | //顶层窗口专属
425 | pTWE TopWndExtend;
426 |
427 |
428 | //扩展****************************
429 |
430 | int ezID;//用户可以自由使用,用于标识窗口ID。
431 | int TimerID[WND_TIMER_NUM];//8个应该够用了,普通窗口可以自由使用。带有样式的窗口可能会用来存放Windows计时器ID
432 | pEZSE Extend;//扩展指针。如果EZ窗口是自创的,那么EZWindow不会使用这个变量。但是假如这个窗口是含有 EZSTYLE 的窗口,这个指针会被EZWindow使用
433 |
434 | DWORD EZStyle;//窗口样式。
435 | BOOL IsStyleWindow;//是否是带有样式的窗口
436 |
437 | #pragma region ezWndStyleExplaination
438 | /*窗口样式注释
439 |
440 | EZStyle 被定义为了 DWORD 也就是 4个字节,32位。
441 |
442 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
443 |
444 | 这里是每个字段的含义:
445 |
446 | 最后一个字节 :256种,表示窗口主要类型,比如,是不是按钮,是不是编辑框等。
447 | 倒数第二三个字节:16位,表示窗口的可选择属性,比如窗口是否带有边框。
448 | 倒数第四个字节 :256种,表示在主要类型下窗口的细分属性,比如按钮窗口是否是单选按钮。
449 | */
450 | #pragma endregion
451 | }EZWINDOW;
452 |
453 | #pragma endregion
454 |
455 | //*******************************************************************************************
456 | // 函数声明
457 | //*******************************************************************************************
458 |
459 | #pragma region EZWindowFunctionDefines
460 |
461 | //static BOOL InitEZWindow();
462 | //static EZWND CreateEZParentWindowEx(DWORD EZStyle, int x, int y, int Width, int Height, DWORD WinStyle, EZWNDPROC ezWndProc, HMENU hMenu, HWND hParent);
463 | //static EZWND CreateEZWindowEx(EZWND ezParent, DWORD EZStyle, int x, int y, int Width, int Height, EZWNDPROC ezWndProc);
464 | //static BOOL DestroyEZWindow(EZWND ezWnd);
465 | //static BOOL DestroyEZWindowWithNext(EZWND ezWnd);
466 | //static BOOL MoveEZWindow(EZWND ezWnd, int x, int y, int Width, int Height, BOOL repaint);
467 | //static BOOL EZResetChildPxPy(EZWND ezWnd);
468 | //static BOOL ScrollEZWindow(EZWND ezWnd, int x, int y, BOOL bAdd);
469 | //static BOOL EZCaptureMouse(EZWND ezWnd);
470 | //static BOOL EZReleaseMouse(EZWND ezWnd);
471 | //static BOOL SetMouseMsgRecvMode(EZWND ezWnd, int Mode);
472 | //static BOOL SetShowState(EZWND ezWnd, int State);
473 | //static BOOL EZRedraw(EZWND ezWnd);
474 | //static BOOL EZUpdate(EZWND ezWnd, HDC hdc);
475 | //static BOOL EZRepaint(EZWND ezWnd, HDC hdc);
476 | //static BOOL EZAddChild(EZWND ezParent, EZWND ezChild);
477 | //static EZWND CreateEZStyleWindow(EZWND ezParent, TCHAR Title[], DWORD EZStyle, int x, int y, int Width, int Height);
478 | //static EZWND CreateEZStyleParentWindow(TCHAR Title[], DWORD EZStyle, int x, int y, int Width, int Height, BOOL bAdjust, EZWNDPROC ezWndProc);
479 | //static int SetEZTimer(EZWND ezWnd, int iTimeSpace);
480 | //static BOOL KillEZTimer(EZWND ezWnd, int TimerID);
481 | //static BOOL EZCreateCaret(EZWND ezWnd, HBITMAP hBitmap, int nWidth, int nHeight);
482 | //static BOOL EZSetCaretPos(EZWND ezWnd, int x, int y);
483 | //static BOOL EZShowCaret(EZWND ezWnd);
484 | //static BOOL EZHideCaret(EZWND ezWnd);
485 | //static BOOL EZDestroyCaret();
486 | //static EZWND EZDialogBox(EZWND ezParent, int x, int y, int w, int h, DWORD Style, COLORREF MaskClr, EZWNDPROC ezWndProc);
487 | //static BOOL EZEndDialog(EZWND ezWnd);
488 | //static EZWNDPROC EZDlgHookProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
489 | //static EZWNDPROC EZDialogBoxMask(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
490 | //static LRESULT CALLBACK EZParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
491 | //static VOID CALLBACK ezInsideTimerProc(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime);
492 | //static int ezInsideWndProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
493 | //static BOOL PtInEZWnd(EZWND ezWnd, int x, int y);
494 | //static BOOL IsEZWindow(EZWND ezWnd);
495 | //static BOOL EZBroadcastToAllChildFunc(EZWND ezWnd, BOOL sequence, int message, WPARAM wp, LPARAM lp);
496 | //static BOOL BroadcastProc(EZWND ezWnd, int Param, WPARAM wP, LPARAM lP);
497 | ////static int EZSendMessage(EZWND ezWnd, int message, WPARAM wP, LPARAM lP);
498 | //static BOOL SetEZWndTransparent(EZWND ezWnd, int Transparent);
499 | //
500 | //static BOOL RedrawBroadcast(EZWND ezWnd, WPARAM wp, LPARAM lp, int cx, int cy, RECT RectSrc);
501 | //static int EZWndMessageLoop();
502 | //
503 | //
504 | //
505 | ////外部样式
506 | //static EZWNDPROC EZStyle_ButtonProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
507 | //static EZWNDPROC EZStyle_StaticProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
508 | //static EZWNDPROC EZStyle_ScrollChildProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
509 | //static EZWNDPROC EZStyle_Scroll_BtnProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
510 | //static EZWNDPROC EZStyle_Scroll_BarProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
511 | //static EZWNDPROC EZStyle_DefaultProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
512 | //static EZWNDPROC EZStyle_EditProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
513 | //static EZWNDPROC EZStyle_Edit_InputProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
514 | //static EZWNDPROC EZStyle_Edit_InputChildProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
515 | //static EZWNDPROC EZStyle_OverlappedWndProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
516 | //
517 | //static EZWNDPROC EZStyle_WndMinProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
518 | //
519 | //static EZWNDPROC EZStyle_WndMaxProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
520 | //
521 | //static EZWNDPROC EZStyle_WndCloseProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
522 |
523 |
524 |
525 | BOOL InitEZWindow();
526 | EZWND CreateEZParentWindowEx(DWORD EZStyle, int x, int y, int Width, int Height, DWORD WinStyle, EZWNDPROC ezWndProc, HMENU hMenu, HWND hParent);
527 | EZWND CreateEZWindowEx(EZWND ezParent, DWORD EZStyle, int x, int y, int Width, int Height, EZWNDPROC ezWndProc);
528 | BOOL DestroyEZWindow(EZWND ezWnd);
529 | BOOL DestroyEZWindowWithNext(EZWND ezWnd);
530 | BOOL MoveEZWindow(EZWND ezWnd, int x, int y, int Width, int Height, BOOL repaint);
531 | BOOL EZResetChildPxPy(EZWND ezWnd);
532 | BOOL ScrollEZWindow(EZWND ezWnd, int x, int y, BOOL bAdd);
533 | BOOL EZCaptureMouse(EZWND ezWnd);
534 | BOOL EZReleaseMouse(EZWND ezWnd);
535 | BOOL SetMouseMsgRecvMode(EZWND ezWnd, int Mode);
536 | BOOL SetShowState(EZWND ezWnd, int State);
537 | BOOL EZRedraw(EZWND ezWnd);
538 | BOOL EZUpdate(EZWND ezWnd, HDC hdc);
539 | BOOL EZRepaint(EZWND ezWnd, HDC hdc);
540 | BOOL EZAddChild(EZWND ezParent, EZWND ezChild);
541 | EZWND CreateEZStyleWindow(EZWND ezParent, TCHAR Title[], DWORD EZStyle, int x, int y, int Width, int Height);
542 | EZWND CreateEZStyleParentWindow(TCHAR Title[], DWORD EZStyle, int x, int y, int Width, int Height, BOOL bAdjust, EZWNDPROC ezWndProc);
543 | int SetEZTimer(EZWND ezWnd, int iTimeSpace);
544 | BOOL KillEZTimer(EZWND ezWnd, int TimerID); BOOL EZCreateCaret(EZWND ezWnd, HBITMAP hBitmap, int nWidth, int nHeight);
545 | BOOL EZSetCaretPos(EZWND ezWnd, int x, int y);
546 | BOOL EZShowCaret(EZWND ezWnd);
547 | BOOL EZHideCaret(EZWND ezWnd);
548 | BOOL EZDestroyCaret();
549 | EZWND EZDialogBox(EZWND ezParent, int x, int y, int w, int h, DWORD Style, COLORREF MaskClr, EZWNDPROC ezWndProc);
550 | BOOL EZEndDialog(EZWND ezWnd);
551 | EZWNDPROC EZDlgHookProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
552 | EZWNDPROC EZDialogBoxMask(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
553 | LRESULT CALLBACK EZParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
554 | VOID CALLBACK ezInsideTimerProc(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime);
555 | int ezInsideWndProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
556 | BOOL PtInEZWnd(EZWND ezWnd, int x, int y);
557 | BOOL IsEZWindow(EZWND ezWnd);
558 | BOOL EZBroadcastToAllChildFunc(EZWND ezWnd, BOOL sequence, int message, WPARAM wp, LPARAM lp);
559 | BOOL BroadcastProc(EZWND ezWnd, int Param, WPARAM wP, LPARAM lP);
560 | //int EZSendMessage(EZWND ezWnd, int message, WPARAM wP, LPARAM lP);
561 | BOOL SetEZWndTransparent(EZWND ezWnd, int Transparent);
562 |
563 | BOOL RedrawBroadcast(EZWND ezWnd, WPARAM wp, LPARAM lp, int cx, int cy, RECT RectSrc);
564 | int EZWndMessageLoop();
565 |
566 |
567 |
568 | //外部样式
569 | EZWNDPROC EZStyle_ButtonProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
570 | EZWNDPROC EZStyle_StaticProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
571 | EZWNDPROC EZStyle_ScrollChildProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
572 | EZWNDPROC EZStyle_Scroll_BtnProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
573 | EZWNDPROC EZStyle_Scroll_BarProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
574 | EZWNDPROC EZStyle_DefaultProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
575 | EZWNDPROC EZStyle_EditProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
576 | EZWNDPROC EZStyle_Edit_InputProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
577 | EZWNDPROC EZStyle_Edit_InputChildProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
578 | EZWNDPROC EZStyle_OverlappedWndProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
579 |
580 | EZWNDPROC EZStyle_WndMinProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
581 |
582 | EZWNDPROC EZStyle_WndMaxProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
583 |
584 | EZWNDPROC EZStyle_WndCloseProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
585 |
586 |
587 | #pragma endregion
588 |
589 |
590 | #pragma region OtherFunctions
591 |
592 | HDC GetMemDC(HDC hdc, int cx, int cy);
593 |
594 | BOOL DeleteMemDC(HDC hdc);
595 |
596 | BOOL AdjustMemDC(HDC hdc, HDC hdcCpb, int cx, int cy);
597 |
598 | #pragma endregion
599 |
600 | //*******************************************************************************************
601 | // 函数宏定义
602 | //*******************************************************************************************
603 |
604 | #pragma region EZWindowFunctions
605 |
606 | //#define CreateEZParentWindow(x, y, Width, Height, ezWndProc, hMenu, hParent) CreateEZParentWindow(x, y, Width, Height, WS_CHILD|WS_VISIBLE, ezWndProc, hMenu, hParent)
607 |
608 | #define CreateEZWindow(ezParent, x,y, Width, Height, ezWndProc) CreateEZWindowEx(ezParent,0L, x,y, Width, Height, ezWndProc)
609 |
610 | #define CreateEZParentWindow(x, y, Width, Height,WinStyle, ezWndProc, hMenu, hParent) CreateEZParentWindowEx(0L, x, y, Width, Height,WinStyle, ezWndProc, hMenu, hParent)
611 |
612 |
613 |
614 | #define EZBroadcastToAllChild(ezWnd, sequence, message, wp,lp) if(IsEZWindow(ezWnd->FirstChild)){ EZBroadcastToAllChildFunc(ezWnd, sequence, message, wp,lp); }
615 |
616 | //#define EZRepaint(ezWnd,hdc) { EZRedraw(ezWnd); EZUpdate(ezWnd, hdc);}
617 |
618 | #define EZGetTopParentWindow(ezWnd) (ezWnd->ezRootParent)
619 |
620 |
621 | #define EZSendMessage(ezWnd, message, wP, lP) (ezWnd)->ezWndProc(ezWnd, message, wP, lP)
622 |
623 |
624 | //#define EZRepaint(ezWnd,hdc) { EZRedraw(ezWnd); EZUpdate(ezWnd, hdc);}
625 |
626 | #pragma endregion
627 |
628 |
629 |
--------------------------------------------------------------------------------
/EasyWindowDemo/EasyWindowDemo.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 |
23 |
24 |
25 | 15.0
26 | {63AB13FD-00DA-46D0-ACB6-633F8FBDD89A}
27 | EasyWindowDemo
28 | 10.0.17763.0
29 |
30 |
31 |
32 | Application
33 | true
34 | v141
35 | MultiByte
36 |
37 |
38 | Application
39 | false
40 | v141
41 | true
42 | MultiByte
43 |
44 |
45 | Application
46 | true
47 | v141
48 | MultiByte
49 |
50 |
51 | Application
52 | false
53 | v141
54 | true
55 | MultiByte
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | Level3
80 | Disabled
81 | true
82 | true
83 |
84 |
85 |
86 |
87 | Level3
88 | Disabled
89 | true
90 | true
91 |
92 |
93 |
94 |
95 | Level3
96 | MaxSpeed
97 | true
98 | true
99 | true
100 | true
101 |
102 |
103 | true
104 | true
105 |
106 |
107 |
108 |
109 | Level3
110 | MaxSpeed
111 | true
112 | true
113 | true
114 | true
115 |
116 |
117 | true
118 | true
119 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/EasyWindowDemo/EasyWindowDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/EasyWindowDemo/Main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include"EasyWindow.h"
3 |
4 | #define WIDTH 930
5 | #define HEIGHT 570
6 |
7 | EZWND MainWnd;
8 | EZWNDPROC MainProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam);
9 |
10 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
11 | {
12 | InitEZWindow();
13 | MainWnd = CreateEZStyleParentWindow(TEXT("EasyWindow Demo"), EZS_PARENT | EZS_OVERLAPPEDWINDOW,
14 | (GetSystemMetrics(SM_CXSCREEN) - WIDTH) / 2, (GetSystemMetrics(SM_CYSCREEN) - HEIGHT) / 2, WIDTH, HEIGHT, 1, MainProc);
15 | return EZWndMessageLoop();
16 | }
17 |
18 | EZWNDPROC MainProc(EZWND ezWnd, int message, WPARAM wParam, LPARAM lParam)
19 | {
20 | switch (message)
21 | {
22 | case EZWM_DRAW:
23 | {
24 | RECT rect = { 0,0,ezWnd->Width,ezWnd->Height };
25 | DrawText(wParam, TEXT("Hello, EasyWindow!!"), -1, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
26 | return 0;
27 | }
28 | case EZWM_DESTROY:
29 | {
30 | PostQuitMessage(0);
31 | return 0;
32 | }
33 | }
34 | return 0;
35 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 杨赫
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------