soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SNativeWnd.h
Go to the documentation of this file.
1/**
2 * @file SNativeWnd.h
3 * @brief Interface and Implementation for Native Window Handling
4 * @version v1.0
5 * @author SOUI group
6 * @date 2014/08/01
7 *
8 * @details This file defines the SNativeWndHelper class and the SNativeWnd class,
9 * which provide interfaces and implementations for handling native Windows.
10 */
11
12 #ifndef __SNATIVEWND__H__
13 #define __SNATIVEWND__H__
14
17 #include <helper/obj-ref-impl.hpp>
18 #include <windows.h>
19 #include <soui_exp.h>
20
21 SNSBEGIN
22
23 /**
24 * @class SNativeWndHelper
25 * @brief Helper class for managing native window resources.
26 *
27 * @details This class provides methods for initializing and managing resources related to native windows,
28 * such as heap management, shared pointers, and window class registration.
29 */
30 class SOUI_EXP SNativeWndHelper {
31 public:
32 /**
33 * @brief Retrieves the handle to the heap.
34 *
35 * @return HANDLE Handle to the heap.
36 */
37 HANDLE GetHeap()
38 {
39 return m_hHeap;
40 }
41
42 /**
43 * @brief Locks a shared pointer.
44 *
45 * @param p Pointer to the shared object.
46 */
47 void LockSharePtr(void *p);
48
49 /**
50 * @brief Unlocks a shared pointer.
51 */
52 void UnlockSharePtr();
53
54 /**
55 * @brief Retrieves the shared pointer.
56 *
57 * @return void* Pointer to the shared object.
58 */
60 {
61 return m_sharePtr;
62 }
63
64 /**
65 * @brief Retrieves the application instance handle.
66 *
67 * @return HINSTANCE Handle to the application instance.
68 */
69 HINSTANCE GetAppInstance()
70 {
71 return m_hInst;
72 }
73
74 /**
75 * @brief Retrieves the atom for the simple window class.
76 *
77 * @return ATOM Atom for the simple window class.
78 */
80 {
81 return m_atom;
82 }
83
84 /**
85 * @brief Initializes the helper with the application instance and window class name.
86 *
87 * @param hInst Handle to the application instance.
88 * @param pszClassName Name of the window class.
89 * @param bImeApp Flag indicating if the application uses IME.
90 * @return BOOL TRUE if initialization is successful, FALSE otherwise.
91 */
92 BOOL Init(HINSTANCE hInst, LPCTSTR pszClassName, BOOL bImeApp);
93
94 public:
95 /**
96 * @brief Retrieves the singleton instance of SNativeWndHelper.
97 *
98 * @return SNativeWndHelper* Pointer to the singleton instance.
99 */
100 static SNativeWndHelper *instance()
101 {
102 static SNativeWndHelper _this;
103 return &_this;
104 }
105
106 private:
109
110 HANDLE m_hHeap; //!< Handle to the heap.
111 SCriticalSection m_cs; //!< Critical section for thread-safe operations.
112 void *m_sharePtr; //!< Shared pointer.
113 ATOM m_atom; //!< Atom for the simple window class.
114 HINSTANCE m_hInst; //!< Handle to the application instance.
115 };
116
117 struct tagThunk;
118
119 /**
120 * @class SNativeWnd
121 * @brief Class for managing native window operations.
122 *
123 * @details This class provides methods for creating, subclassing, and managing native Windows,
124 * as well as handling window messages and notifications.
125 */
126 class SOUI_EXP SNativeWnd : public TObjRefImpl<INativeWnd> {
127 public:
128 SNativeWnd();
129 virtual ~SNativeWnd(void);
130
131 /**
132 * @brief Registers a simple window class.
133 *
134 * @param hInst Handle to the application instance.
135 * @param pszSimpleWndName Name of the simple window class.
136 * @param bImeWnd Flag indicating if the window uses IME.
137 * @return ATOM Atom for the registered window class.
138 */
139 static ATOM RegisterSimpleWnd(HINSTANCE hInst, LPCTSTR pszSimpleWndName, BOOL bImeWnd);
140
141 /**
142 * @brief Initializes the window class.
143 *
144 * @param hInst Handle to the application instance.
145 * @param pszSimpleWndName Name of the simple window class.
146 * @param bImeWnd Flag indicating if the window uses IME.
147 */
148 static void InitWndClass(HINSTANCE hInst, LPCTSTR pszSimpleWndName, BOOL bImeWnd);
149
150 /**
151 * @brief Retrieves the window ID.
152 *
153 * @return int Window ID.
154 */
155 STDMETHOD_(int, GetID)(THIS) SCONST
156 {
157 return GetDlgCtrlID();
158 }
159
160 /**
161 * @brief Sets the window ID.
162 *
163 * @param nID New window ID.
164 */
165 STDMETHOD_(void, SetID)(THIS_ int nID)
166 {
167 SetWindowLongPtr(GWL_ID, nID);
168 }
169
170 /**
171 * @brief Creates a native window.
172 *
173 * @param lpWindowName Name of the window.
174 * @param dwStyle Window style.
175 * @param dwExStyle Extended window style.
176 * @param x X position of the window.
177 * @param y Y position of the window.
178 * @param nWidth Width of the window.
179 * @param nHeight Height of the window.
180 * @param hWndParent Handle to the parent window.
181 * @param nID Control ID of the window.
182 * @param lpParam Pointer to creation parameters.
183 * @return HWND Handle to the created window.
184 */
185 STDMETHOD_(HWND, CreateNative)
186 (THIS_ LPCTSTR lpWindowName, DWORD dwStyle, DWORD dwExStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, int nID DEF_VAL(0), LPVOID lpParam DEF_VAL(0)) OVERRIDE;
187
188 /**
189 * @brief Retrieves the handle to the window.
190 *
191 * @return HWND Handle to the window.
192 */
193 STDMETHOD_(HWND, GetHwnd)(THIS) OVERRIDE;
194
195 /**
196 * @brief Subclasses an existing window.
197 *
198 * @param hWnd Handle to the window to subclass.
199 * @return BOOL TRUE--SUCCEEDED, FALSE--FAILED.
200 */
201 STDMETHOD_(BOOL, SubclassWindow)(THIS_ HWND hWnd) OVERRIDE;
202
203 /**
204 * @brief Unsubclasses a window.
205 *
206 * @param bForce Flag indicating if the unsubclassing should be forced.
207 * @return HWND Handle to the unsubclassed window.
208 */
209 STDMETHOD_(HWND, UnsubclassWindow)(THIS_ BOOL bForce DEF_VAL(FALSE)) OVERRIDE;
210
211 /**
212 * @brief Retrieves the current message being processed.
213 *
214 * @return const MSG* Pointer to the current message.
215 */
216 STDMETHOD_(const MSG *, GetCurrentMessage)(THIS) SCONST OVERRIDE;
217
218 /**
219 * @brief Retrieves the dialog control ID.
220 *
221 * @return int Dialog control ID.
222 */
223 STDMETHOD_(int, GetDlgCtrlID)(THIS) SCONST OVERRIDE;
224
225 /**
226 * @brief Retrieves the window style.
227 *
228 * @return DWORD Window style.
229 */
230 STDMETHOD_(DWORD, GetStyle)(THIS) SCONST OVERRIDE;
231
232 /**
233 * @brief Retrieves the extended window style.
234 *
235 * @return DWORD Extended window style.
236 */
237 STDMETHOD_(DWORD, GetExStyle)(THIS) SCONST OVERRIDE;
238
239 /**
240 * @brief Retrieves the long pointer value at the specified index.
241 *
242 * @param nIndex Index of the value to retrieve.
243 * @return LONG_PTR Long pointer value.
244 */
245 STDMETHOD_(LONG_PTR, GetWindowLongPtr)(THIS_ int nIndex) SCONST OVERRIDE;
246
247 /**
248 * @brief Sets the long pointer value at the specified index.
249 *
250 * @param nIndex Index of the value to set.
251 * @param dwNewLong New long pointer value.
252 * @return LONG_PTR Previous long pointer value.
253 */
254 STDMETHOD_(LONG_PTR, SetWindowLongPtr)(THIS_ int nIndex, LONG_PTR dwNewLong) OVERRIDE;
255
256 /**
257 * @brief Retrieves the handle to the parent window.
258 *
259 * @return HWND Handle to the parent window.
260 */
261 STDMETHOD_(HWND, GetParent)(THIS) OVERRIDE;
262
263 /**
264 * @brief Sets the handle to the parent window.
265 *
266 * @param hWndNewParent Handle to the new parent window.
267 * @return HWND Handle to the previous parent window.
268 */
269 STDMETHOD_(HWND, SetParent)(THIS_ HWND hWndNewParent) OVERRIDE;
270
271 /**
272 * @brief Checks if the window is enabled.
273 *
274 * @return BOOL TRUE if the window is enabled, FALSE otherwise.
275 */
276 STDMETHOD_(BOOL, IsWindowEnabled)(THIS) SCONST OVERRIDE;
277
278 /**
279 * @brief Modifies the window style.
280 *
281 * @param dwRemove Styles to remove.
282 * @param dwAdd Styles to add.
283 * @param nFlags Flags for modification.
284 * @return BOOL TRUE if successful, FALSE otherwise.
285 */
286 STDMETHOD_(BOOL, ModifyStyle)
287 (THIS_ DWORD dwRemove, DWORD dwAdd, UINT nFlags DEF_VAL(0)) OVERRIDE;
288
289 /**
290 * @brief Modifies the extended window style.
291 *
292 * @param dwRemove Styles to remove.
293 * @param dwAdd Styles to add.
294 * @param nFlags Flags for modification.
295 * @return BOOL TRUE if successful, FALSE otherwise.
296 */
297 STDMETHOD_(BOOL, ModifyStyleEx)
298 (THIS_ DWORD dwRemove, DWORD dwAdd, UINT nFlags DEF_VAL(0)) OVERRIDE;
299
300 /**
301 * @brief Sets the window position.
302 *
303 * @param hWndInsertAfter Handle to the window to insert after.
304 * @param x X position of the window.
305 * @param y Y position of the window.
306 * @param cx Width of the window.
307 * @param cy Height of the window.
308 * @param nFlags Flags for positioning.
309 * @return BOOL TRUE if successful, FALSE otherwise.
310 */
311 STDMETHOD_(BOOL, SetWindowPos)
312 (THIS_ HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags) OVERRIDE;
313
314 /**
315 * @brief Centers the window relative to another window.
316 *
317 * @param hWndCenter Handle to the window to center relative to.
318 * @return BOOL TRUE if successful, FALSE otherwise.
319 */
320 STDMETHOD_(BOOL, CenterWindow)(THIS_ HWND hWndCenter DEF_VAL(0)) OVERRIDE;
321
322 /**
323 * @brief Destroys the window.
324 *
325 * @return BOOL TRUE if successful, FALSE otherwise.
326 */
327 STDMETHOD_(BOOL, DestroyWindow)(THIS) OVERRIDE;
328
329 /**
330 * @brief Checks if the handle is a valid window handle.
331 *
332 * @return BOOL TRUE if valid, FALSE otherwise.
333 */
334 STDMETHOD_(BOOL, IsWindow)(THIS) SCONST OVERRIDE;
335
336 /**
337 * @brief Invalidates the entire window.
338 *
339 * @param bErase Flag indicating if the background should be erased.
340 * @return BOOL TRUE if successful, FALSE otherwise.
341 */
342 STDMETHOD_(BOOL, Invalidate)(THIS_ BOOL bErase DEF_VAL(TRUE)) OVERRIDE;
343
344 /**
345 * @brief Invalidates a specified rectangle of the window.
346 *
347 * @param lpRect Rectangle to invalidate.
348 * @param bErase Flag indicating if the background should be erased.
349 * @return BOOL TRUE if successful, FALSE otherwise.
350 */
351 STDMETHOD_(BOOL, InvalidateRect)(THIS_ LPCRECT lpRect, BOOL bErase DEF_VAL(TRUE)) OVERRIDE;
352
353 /**
354 * @brief Retrieves the window rectangle.
355 *
356 * @param lpRect Rectangle to receive the window rectangle.
357 * @return BOOL TRUE if successful, FALSE otherwise.
358 */
359 STDMETHOD_(BOOL, GetWindowRect)(THIS_ LPRECT lpRect) SCONST OVERRIDE;
360
361 /**
362 * @brief Retrieves the client rectangle.
363 *
364 * @param lpRect Rectangle to receive the client rectangle.
365 * @return BOOL TRUE if successful, FALSE otherwise.
366 */
367 STDMETHOD_(BOOL, GetClientRect)(THIS_ LPRECT lpRect) SCONST OVERRIDE;
368
369 /**
370 * @brief Converts client coordinates to screen coordinates.
371 *
372 * @param lpPoint Point to convert.
373 * @return BOOL TRUE if successful, FALSE otherwise.
374 */
375 STDMETHOD_(BOOL, ClientToScreen)(THIS_ LPPOINT lpPoint) SCONST OVERRIDE;
376
377 /**
378 * @brief Converts client rectangle coordinates to screen coordinates.
379 *
380 * @param lpRect Rectangle to convert.
381 * @return BOOL TRUE if successful, FALSE otherwise.
382 */
383 STDMETHOD_(BOOL, ClientToScreen2)(THIS_ LPRECT lpRect) SCONST OVERRIDE;
384
385 /**
386 * @brief Converts screen coordinates to client coordinates.
387 *
388 * @param lpPoint Point to convert.
389 * @return BOOL TRUE if successful, FALSE otherwise.
390 */
391 STDMETHOD_(BOOL, ScreenToClient)(THIS_ LPPOINT lpPoint) SCONST OVERRIDE;
392
393 /**
394 * @brief Converts screen rectangle coordinates to client coordinates.
395 *
396 * @param lpRect Rectangle to convert.
397 * @return BOOL TRUE if successful, FALSE otherwise.
398 */
399 STDMETHOD_(BOOL, ScreenToClient2)(THIS_ LPRECT lpRect) SCONST OVERRIDE;
400
401 /**
402 * @brief Maps points from one window to another.
403 *
404 * @param hWndTo Handle to the destination window.
405 * @param lpPoint Points to map.
406 * @param nCount Number of points.
407 * @return int Number of points mapped.
408 */
409 STDMETHOD_(int, MapWindowPoints)
410 (THIS_ HWND hWndTo, LPPOINT lpPoint, UINT nCount) SCONST OVERRIDE;
411
412 /**
413 * @brief Maps a rectangle from one window to another.
414 *
415 * @param hWndTo Handle to the destination window.
416 * @param lpRect Rectangle to map.
417 * @return int Number of points mapped.
418 */
419 STDMETHOD_(int, MapWindowRect)(THIS_ HWND hWndTo, LPRECT lpRect) SCONST OVERRIDE;
420
421 /**
422 * @brief Sets a timer for the window.
423 *
424 * @param nIDEvent Timer ID.
425 * @param nElapse Elapse time in milliseconds.
426 * @param lpfnTimer Timer callback function.
427 * @return UINT_PTR Timer ID.
428 */
429 STDMETHOD_(UINT_PTR, SetTimer)
430 (THIS_ UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD) DEF_VAL(NULL)) OVERRIDE;
431
432 /**
433 * @brief Kills a timer for the window.
434 *
435 * @param nIDEvent Timer ID.
436 * @return BOOL TRUE if successful, FALSE otherwise.
437 */
438 STDMETHOD_(BOOL, KillTimer)(THIS_ UINT_PTR nIDEvent) OVERRIDE;
439
440 /**
441 * @brief Retrieves a device context for the window.
442 *
443 * @return HDC Handle to the device context.
444 */
445 STDMETHOD_(HDC, GetDC)(THIS) OVERRIDE;
446
447 /**
448 * @brief Retrieves a device context for the entire window.
449 *
450 * @return HDC Handle to the device context.
451 */
452 STDMETHOD_(HDC, GetWindowDC)(THIS) OVERRIDE;
453
454 /**
455 * @brief Releases a device context.
456 *
457 * @param hDC Handle to the device context to release.
458 * @return int Number of times the device context was released.
459 */
460 STDMETHOD_(int, ReleaseDC)(THIS_ HDC hDC) OVERRIDE;
461
462 /**
463 * @brief Creates a caret for the window.
464 *
465 * @param hBitmap Handle to the bitmap for the caret.
466 * @param nWidth Width of the caret.
467 * @param nHeight Height of the caret.
468 * @return BOOL TRUE if successful, FALSE otherwise.
469 */
470 STDMETHOD_(BOOL, CreateCaret)(THIS_ HBITMAP hBitmap, int nWidth, int nHeight) OVERRIDE;
471
472 /**
473 * @brief Hides the caret.
474 *
475 * @return BOOL TRUE if successful, FALSE otherwise.
476 */
477 STDMETHOD_(BOOL, HideCaret)(THIS) OVERRIDE;
478
479 /**
480 * @brief Shows the caret.
481 *
482 * @return BOOL TRUE if successful, FALSE otherwise.
483 */
484 STDMETHOD_(BOOL, ShowCaret)(THIS) OVERRIDE;
485
486 /**
487 * @brief Retrieves the handle to the window that has captured the mouse.
488 *
489 * @return HWND Handle to the capturing window.
490 */
491 STDMETHOD_(HWND, GetCapture)(THIS) OVERRIDE;
492
493 /**
494 * @brief Sets the window to capture the mouse.
495 *
496 * @return HWND Handle to the previous capturing window.
497 */
498 STDMETHOD_(HWND, SetCapture)(THIS) OVERRIDE;
499
500 /**
501 * @brief Releases the mouse capture.
502 *
503 * @return BOOL TRUE if successful, FALSE otherwise.
504 */
505 STDMETHOD_(BOOL, ReleaseCapture)(THIS) OVERRIDE;
506
507 /**
508 * @brief Sets the input focus to the window.
509 *
510 * @return HWND Handle to the previous focused window.
511 */
512 STDMETHOD_(HWND, SetFocus)(THIS) OVERRIDE;
513
514 /**
515 * @brief Sends a message to the window.
516 *
517 * @param message Message to send.
518 * @param wParam WPARAM for the message.
519 * @param lParam LPARAM for the message.
520 * @return LRESULT Result of the message processing.
521 */
522 STDMETHOD_(LRESULT, SendMessage)
523 (THIS_ UINT message, WPARAM wParam DEF_VAL(0), LPARAM lParam DEF_VAL(0)) OVERRIDE;
524
525 /**
526 * @brief Posts a message to the window.
527 *
528 * @param message Message to post.
529 * @param wParam WPARAM for the message.
530 * @param lParam LPARAM for the message.
531 * @return BOOL TRUE if successful, FALSE otherwise.
532 */
533 STDMETHOD_(BOOL, PostMessage)
534 (THIS_ UINT message, WPARAM wParam DEF_VAL(0), LPARAM lParam DEF_VAL(0)) OVERRIDE;
535
536 /**
537 * @brief Sends a notify message to the window.
538 *
539 * @param message Message to send.
540 * @param wParam WPARAM for the message.
541 * @param lParam LPARAM for the message.
542 * @return BOOL TRUE if successful, FALSE otherwise.
543 */
544 STDMETHOD_(BOOL, SendNotifyMessage)
545 (THIS_ UINT message, WPARAM wParam DEF_VAL(0), LPARAM lParam DEF_VAL(0)) OVERRIDE;
546
547 /**
548 * @brief Sets the window text.
549 *
550 * @param lpszString String to set as the window text.
551 * @return BOOL TRUE if successful, FALSE otherwise.
552 */
553 STDMETHOD_(BOOL, SetWindowText)(THIS_ LPCTSTR lpszString) OVERRIDE;
554
555 /**
556 * @brief Retrieves the window text.
557 *
558 * @param lpszStringBuf Buffer to receive the window text.
559 * @param nMaxCount Maximum number of characters to copy to the buffer.
560 * @return int Length of the string copied to the buffer, not including the terminating null character.
561 */
562 STDMETHOD_(int, GetWindowText)(THIS_ LPTSTR lpszStringBuf, int nMaxCount) SCONST OVERRIDE;
563
564 /**
565 * @brief Checks if the window is iconic (minimized).
566 *
567 * @return BOOL TRUE if the window is iconic, FALSE otherwise.
568 */
569 STDMETHOD_(BOOL, IsIconic)(THIS) SCONST OVERRIDE;
570
571 /**
572 * @brief Checks if the window is zoomed (maximized).
573 *
574 * @return BOOL TRUE if the window is zoomed, FALSE otherwise.
575 */
576 STDMETHOD_(BOOL, IsZoomed)(THIS) SCONST OVERRIDE;
577
578 /**
579 * @brief Checks if the window is visible.
580 *
581 * @return BOOL TRUE if the window is visible, FALSE otherwise.
582 */
583 STDMETHOD_(BOOL, IsWindowVisible)(THIS) SCONST OVERRIDE;
584
585 /**
586 * @brief Moves the window to the specified position and resizes it.
587 *
588 * @param x X position of the window.
589 * @param y Y position of the window.
590 * @param nWidth Width of the window.
591 * @param nHeight Height of the window.
592 * @param bRepaint Flag indicating if the window should be repainted.
593 * @return BOOL TRUE if successful, FALSE otherwise.
594 */
595 STDMETHOD_(BOOL, MoveWindow)
596 (THIS_ int x, int y, int nWidth, int nHeight, BOOL bRepaint DEF_VAL(TRUE)) OVERRIDE;
597
598 /**
599 * @brief Moves the window to the specified position and resizes it using a rectangle.
600 *
601 * @param lpRect Rectangle defining the new position and size of the window.
602 * @param bRepaint Flag indicating if the window should be repainted.
603 * @return BOOL TRUE if successful, FALSE otherwise.
604 */
605 STDMETHOD_(BOOL, MoveWindow2)(THIS_ LPCRECT lpRect, BOOL bRepaint DEF_VAL(TRUE)) OVERRIDE;
606
607 /**
608 * @brief Sets the show state of the window.
609 *
610 * @param nCmdShow Command to show the window (e.g., SW_SHOW, SW_HIDE).
611 * @return BOOL TRUE if successful, FALSE otherwise.
612 */
613 STDMETHOD_(BOOL, ShowWindow)(THIS_ int nCmdShow) OVERRIDE;
614
615 /**
616 * @brief Sets the window region.
617 *
618 * @param hRgn Handle to the region.
619 * @param bRedraw Flag indicating if the window should be redrawn.
620 * @return int Previous region handle.
621 */
622 STDMETHOD_(int, SetWindowRgn)(THIS_ HRGN hRgn, BOOL bRedraw DEF_VAL(TRUE)) OVERRIDE;
623
624 /**
625 * @brief Sets the layered window attributes.
626 *
627 * @param crKey Color key for transparency.
628 * @param bAlpha Alpha value for transparency.
629 * @param dwFlags Flags for the layered window attributes.
630 * @return BOOL TRUE if successful, FALSE otherwise.
631 */
632 STDMETHOD_(BOOL, SetLayeredWindowAttributes)
633 (THIS_ COLORREF crKey, BYTE bAlpha, DWORD dwFlags) OVERRIDE;
634
635 /**
636 * @brief Updates the layered window.
637 *
638 * @param hdcDst Destination device context.
639 * @param pptDst Destination point.
640 * @param psize Size of the destination.
641 * @param hdcSrc Source device context.
642 * @param pptSrc Source point.
643 * @param crKey Color key for transparency.
644 * @param pblend Blend function.
645 * @param dwFlags Flags for the update.
646 * @return BOOL TRUE if successful, FALSE otherwise.
647 */
648 STDMETHOD_(BOOL, UpdateLayeredWindow)
649 (THIS_ HDC hdcDst, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags) OVERRIDE;
650
651 /**
652 * @brief Sets the message handler for the window.
653 *
654 * @param fun Function pointer to the message handler.
655 * @param ctx Context pointer for the message handler.
656 */
657 STDMETHOD_(void, SetMsgHandler)(THIS_ FunMsgHandler fun, void *ctx) OVERRIDE;
658
659 /**
660 * @brief Retrieves the message handler for the window.
661 *
662 * @return MsgHandlerInfo* Pointer to the message handler information.
663 */
664 STDMETHOD_(MsgHandlerInfo *, GetMsgHandler)(THIS) OVERRIDE;
665
666 /**
667 * @brief Calls the default window procedure.
668 *
669 * @return LRESULT Result of the default window procedure.
670 */
671 LRESULT DefWindowProc();
672
673 /**
674 * @brief Forwards notifications to the appropriate handler.
675 *
676 * @param uMsg Message identifier.
677 * @param wParam WPARAM for the message.
678 * @param lParam LPARAM for the message.
679 * @param bHandled Flag indicating if the message was handled.
680 * @return LRESULT Result of the message processing.
681 */
682 LRESULT ForwardNotifications(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
683
684 /**
685 * @brief Reflects notifications to the appropriate handler.
686 *
687 * @param uMsg Message identifier.
688 * @param wParam WPARAM for the message.
689 * @param lParam LPARAM for the message.
690 * @param bHandled Flag indicating if the message was handled.
691 * @return LRESULT Result of the message processing.
692 */
693 LRESULT ReflectNotifications(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
694
695 /**
696 * @brief Default reflection handler for notifications.
697 *
698 * @param hWnd Handle to the window.
699 * @param uMsg Message identifier.
700 * @param wParam WPARAM for the message.
701 * @param lParam LPARAM for the message.
702 * @param lResult Result of the message processing.
703 * @return BOOL TRUE if the message was handled, FALSE otherwise.
704 */
705 static BOOL DefaultReflectionHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult);
706
707 public: // EXTRACT FROM BEGIN_MSG_MAP_EX and END_MSG_MAP
708 /**
709 * @brief Processes a window message.
710 *
711 * @param hWnd Handle to the window.
712 * @param uMsg Message identifier.
713 * @param wParam WPARAM for the message.
714 * @param lParam LPARAM for the message.
715 * @param lResult Result of the message processing.
716 * @param dwMsgMapID Message map ID.
717 * @return BOOL TRUE if the message was handled, FALSE otherwise.
718 */
719 virtual BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD dwMsgMapID = 0);
720
721 protected:
722 /**
723 * @brief Calls the default window procedure with specific parameters.
724 *
725 * @param uMsg Message identifier.
726 * @param wParam WPARAM for the message.
727 * @param lParam LPARAM for the message.
728 * @return LRESULT Result of the default window procedure.
729 */
730 LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
731
732 /**
733 * @brief Handles the final message for the window.
734 *
735 * @param hWnd Handle to the window.
736 */
737 virtual void OnFinalMessage(HWND hWnd);
738
739 const MSG *m_pCurrentMsg; //!< Pointer to the current message.
740 BOOL m_bDestoryed; //!< Flag indicating if the window is destroyed.
741 MsgHandlerInfo m_msgHandlerInfo; //!< Message handler information.
742
743 public:
744 HWND m_hWnd; //!< Handle to the window.
745
746 protected:
747 /**
748 * @brief Window procedure callback function.
749 *
750 * @param hWnd Handle to the window.
751 * @param uMsg Message identifier.
752 * @param wParam WPARAM for the message.
753 * @param lParam LPARAM for the message.
754 * @return LRESULT Result of the message processing.
755 */
756 static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
757
758 /**
759 * @brief Start window procedure callback function (executed once).
760 *
761 * @param hWnd Handle to the window.
762 * @param uMsg Message identifier.
763 * @param wParam WPARAM for the message.
764 * @param lParam LPARAM for the message.
765 * @return LRESULT Result of the message processing.
766 */
767 static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
768 tagThunk *m_pThunk; //!< Thunk structure.
769 WNDPROC m_pfnSuperWindowProc; //!< Pointer to the superclass window procedure.
770 };
771
772 SNSEND
773 #endif // __SNATIVEWND__H__
Header file for SCriticalSection and SAutoLock classes.
Interface for Native Window Operations.
Wrapper class for a critical section.
Helper class for managing native window resources.
Definition SNativeWnd.h:30
static SNativeWndHelper * instance()
Retrieves the singleton instance of SNativeWndHelper.
Definition SNativeWnd.h:100
HINSTANCE GetAppInstance()
Retrieves the application instance handle.
Definition SNativeWnd.h:69
void * GetSharePtr()
Retrieves the shared pointer.
Definition SNativeWnd.h:59
HANDLE GetHeap()
Retrieves the handle to the heap.
Definition SNativeWnd.h:37
ATOM GetSimpleWndAtom()
Retrieves the atom for the simple window class.
Definition SNativeWnd.h:79
static void InitWndClass(HINSTANCE hInst, LPCTSTR pszSimpleWndName, BOOL bImeWnd)
Initializes the window class.
const MSG * m_pCurrentMsg
Pointer to the current message.
Definition SNativeWnd.h:739
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Window procedure callback function.
tagThunk * m_pThunk
Thunk structure.
Definition SNativeWnd.h:768
WNDPROC m_pfnSuperWindowProc
Pointer to the superclass window procedure.
Definition SNativeWnd.h:769
MsgHandlerInfo m_msgHandlerInfo
Message handler information.
Definition SNativeWnd.h:741
static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Start window procedure callback function (executed once).
int GetID() SCONST
Retrieves the window ID.
Definition SNativeWnd.h:155
BOOL m_bDestoryed
Flag indicating if the window is destroyed.
Definition SNativeWnd.h:740
static ATOM RegisterSimpleWnd(HINSTANCE hInst, LPCTSTR pszSimpleWndName, BOOL bImeWnd)
Registers a simple window class.
HWND m_hWnd
Handle to the window.
Definition SNativeWnd.h:744
void SetID(int nID)
Sets the window ID.
Definition SNativeWnd.h:165
LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong) OVERRIDE
Sets the long pointer value at the specified index.
int GetDlgCtrlID() SCONST OVERRIDE
Retrieves the dialog control ID.
Structure containing message handler information.