Monday, August 17, 2009

Useful WM_Messages Define WIN32 Platform

using System;
///
/// Summary description for WM_Messages.
///

public enum WM_Messages
{
WM_NULL = 0x0000, //0
WM_CREATE = 0x0001, //1
WM_DESTROY = 0x0002, //2
WM_MOVE = 0x0003, //3
WM_SIZE = 0x0005, //5
WM_ACTIVATE = 0x0006, //6
WM_SETFOCUS = 0x0007, //7
WM_KILLFOCUS = 0x0008, //8
WM_ENABLE = 0x000A, //10
WM_SETREDRAW = 0x000B, //11
WM_SETTEXT = 0x000C, //12
WM_GETTEXT = 0x000D, //13
WM_GETTEXTLENGTH = 0x000E, //14
WM_PAINT = 0x000F, //15
WM_CLOSE = 0x0010, //16
WM_QUERYENDSESSION = 0x0011, //17
WM_QUERYOPEN = 0x0013, //19
WM_ENDSESSION = 0x0016, //22
WM_QUIT = 0x0012, //18
WM_ERASEBKGND = 0x0014, //20
WM_SYSCOLORCHANGE = 0x0015, //21
WM_SHOWWINDOW = 0x0018, //24
WM_WININICHANGE = 0x001A, //26
WM_DEVMODECHANGE = 0x001B, //27
WM_ACTIVATEAPP = 0x001C, //28
WM_FONTCHANGE = 0x001D, //29
WM_TIMECHANGE = 0x001E, //30
WM_CANCELMODE = 0x001F, //31
WM_SETCURSOR = 0x0020, //32
WM_MOUSEACTIVATE = 0x0021, //33
WM_CHILDACTIVATE = 0x0022, //34
WM_QUEUESYNC = 0x0023, //35
WM_GETMINMAXINFO = 0x0024, //36
WM_PAINTICON = 0x0026, //38
WM_ICONERASEBKGND = 0x0027, //39
WM_NEXTDLGCTL = 0x0028, //40
WM_SPOOLERSTATUS = 0x002A, //42
WM_DRAWITEM = 0x002B, //43
WM_MEASUREITEM = 0x002C, //44
WM_DELETEITEM = 0x002D, //45
WM_VKEYTOITEM = 0x002E, //46
WM_CHARTOITEM = 0x002F, //47
WM_SETFONT = 0x0030, //48
WM_GETFONT = 0x0031, //49
WM_SETHOTKEY = 0x0032, //50
WM_GETHOTKEY = 0x0033, //51
WM_QUERYDRAGICON = 0x0037, //55
WM_COMPAREITEM = 0x0039, //57
WM_GETOBJECT = 0x003D, //61
WM_COMPACTING = 0x0041, //65
WM_COMMNOTIFY = 0x0044, //68 /* no longer suported */
WM_WINDOWPOSCHANGING = 0x0046, //70
WM_WINDOWPOSCHANGED = 0x0047, //71
WM_POWER = 0x0048, //72
WM_COPYDATA = 0x004A, //74
WM_CANCELJOURNAL = 0x004B, //75
WM_NOTIFY = 0x004E, //78
WM_INPUTLANGCHANGEREQUEST = 0x0050, //80
WM_INPUTLANGCHANGE = 0x0051, //81
WM_TCARD = 0x0052, //82
WM_HELP = 0x0053, //83
WM_USERCHANGED = 0x0054, //84
WM_NOTIFYFORMAT = 0x0055, //85
WM_CONTEXTMENU = 0x007B, //123
WM_STYLECHANGING = 0x007C, //124
WM_STYLECHANGED = 0x007D, //125
WM_DISPLAYCHANGE = 0x007E, //126
WM_GETICON = 0x007F, //127
WM_SETICON = 0x0080, //128
WM_NCCREATE = 0x0081, //129
WM_NCDESTROY = 0x0082, //130
WM_NCCALCSIZE = 0x0083, //131
WM_NCHITTEST = 0x0084, //132
WM_NCPAINT = 0x0085, //133
WM_NCACTIVATE = 0x0086, //134
WM_GETDLGCODE = 0x0087, //135
WM_SYNCPAINT = 0x0088, //136
WM_NCMOUSEMOVE = 0x00A0, //160
WM_NCLBUTTONDOWN = 0x00A1, //161
WM_NCLBUTTONUP = 0x00A2, //162
WM_NCLBUTTONDBLCLK = 0x00A3, //163
WM_NCRBUTTONDOWN = 0x00A4, //164
WM_NCRBUTTONUP = 0x00A5, //165
WM_NCRBUTTONDBLCLK = 0x00A6, //166
WM_NCMBUTTONDOWN = 0x00A7, //167
WM_NCMBUTTONUP = 0x00A8, //168
WM_NCMBUTTONDBLCLK = 0x00A9, //169
WM_NCXBUTTONDOWN = 0x00AB, //171
WM_NCXBUTTONUP = 0x00AC, //172
WM_NCXBUTTONDBLCLK = 0x00AD, //173
WM_INPUT = 0x00FF, //255
WM_KEYFIRST = 0x0100, //256
WM_KEYDOWN = 0x0100, //256
WM_KEYUP = 0x0101, //257
WM_CHAR = 0x0102, //258
WM_DEADCHAR = 0x0103, //259
WM_SYSKEYDOWN = 0x0104, //260
WM_SYSKEYUP = 0x0105, //261
WM_SYSCHAR = 0x0106, //262
WM_SYSDEADCHAR = 0x0107, //263
WM_UNICHAR = 0x0109, //265
WM_KEYLAST = 0x0109, //265
WM_KEYLASTBefore0x0501 = 0x0108, //264
WM_IME_STARTCOMPOSITION = 0x010D, //269
WM_IME_ENDCOMPOSITION = 0x010E, //270
WM_IME_COMPOSITION = 0x010F, //271
WM_IME_KEYLAST = 0x010F, //271
WM_INITDIALOG = 0x0110, //272
WM_COMMAND = 0x0111, //273
WM_SYSCOMMAND = 0x0112, //274
WM_TIMER = 0x0113, //275
WM_HSCROLL = 0x0114, //276
WM_VSCROLL = 0x0115, //277
WM_INITMENU = 0x0116, //278
WM_INITMENUPOPUP = 0x0117, //279
WM_MENUSELECT = 0x011F, //287
WM_MENUCHAR = 0x0120, //288
WM_ENTERIDLE = 0x0121, //289
WM_MENURBUTTONUP = 0x0122, //290
WM_MENUDRAG = 0x0123, //291
WM_MENUGETOBJECT = 0x0124, //292
WM_UNINITMENUPOPUP = 0x0125, //293
WM_MENUCOMMAND = 0x0126, //294
WM_CHANGEUISTATE = 0x0127, //295
WM_UPDATEUISTATE = 0x0128, //296
WM_QUERYUISTATE = 0x0129, //297
WM_CTLCOLORMSGBOX = 0x0132, //306
WM_CTLCOLOREDIT = 0x0133, //307
WM_CTLCOLORLISTBOX = 0x0134, //308
WM_CTLCOLORBTN = 0x0135, //309
WM_CTLCOLORDLG = 0x0136, //310
WM_CTLCOLORSCROLLBAR = 0x0137, //311
WM_CTLCOLORSTATIC = 0x0138, //312
WM_MOUSEFIRST = 0x0200, //512
WM_MOUSEMOVE = 0x0200, //512
WM_LBUTTONDOWN = 0x0201, //513
WM_LBUTTONUP = 0x0202, //514
WM_LBUTTONDBLCLK = 0x0203, //515
WM_RBUTTONDOWN = 0x0204, //516
WM_RBUTTONUP = 0x0205, //517
WM_RBUTTONDBLCLK = 0x0206, //518
WM_MBUTTONDOWN = 0x0207, //519
WM_MBUTTONUP = 0x0208, //520
WM_MBUTTONDBLCLK = 0x0209, //521
WM_MOUSEWHEEL = 0x020A, //522
WM_XBUTTONDOWN = 0x020B, //523
WM_XBUTTONUP = 0x020C, //524
WM_XBUTTONDBLCLK = 0x020D, //525
WM_MOUSELAST = 0x020D, //525
WM_MOUSELASTBefore0x0500 = 0x020A, //522
WM_MOUSELASTBefore0x0400 = 0x0209, //521
WM_PARENTNOTIFY = 0x0210, //528
WM_ENTERMENULOOP = 0x0211, //529
WM_EXITMENULOOP = 0x0212, //530
WM_NEXTMENU = 0x0213, //531
WM_SIZING = 0x0214, //532
WM_CAPTURECHANGED = 0x0215, //533
WM_MOVING = 0x0216, //534
WM_POWERBROADCAST = 0x0218, //536
WM_DEVICECHANGE = 0x0219, //537
WM_MDICREATE = 0x0220, //544
WM_MDIDESTROY = 0x0221, //545
WM_MDIACTIVATE = 0x0222, //546
WM_MDIRESTORE = 0x0223, //547
WM_MDINEXT = 0x0224, //548
WM_MDIMAXIMIZE = 0x0225, //549
WM_MDITILE = 0x0226, //550
WM_MDICASCADE = 0x0227, //551
WM_MDIICONARRANGE = 0x0228, //552
WM_MDIGETACTIVE = 0x0229, //553
WM_MDISETMENU = 0x0230, //560
WM_ENTERSIZEMOVE = 0x0231, //561
WM_EXITSIZEMOVE = 0x0232, //562
WM_DROPFILES = 0x0233, //563
WM_MDIREFRESHMENU = 0x0234, //564
WM_IME_SETCONTEXT = 0x0281, //641
WM_IME_NOTIFY = 0x0282, //642
WM_IME_CONTROL = 0x0283, //643
WM_IME_COMPOSITIONFULL = 0x0284, //644
WM_IME_SELECT = 0x0285, //645
WM_IME_CHAR = 0x0286, //646
WM_IME_REQUEST = 0x0288, //648
WM_IME_KEYDOWN = 0x0290, //656
WM_IME_KEYUP = 0x0291, //657
WM_MOUSEHOVER = 0x02A1, //673
WM_MOUSELEAVE = 0x02A3, //675
WM_NCMOUSEHOVER = 0x02A0, //672
WM_NCMOUSELEAVE = 0x02A2, //674
WM_WTSSESSION_CHANGE = 0x02B1, //689
WM_TABLET_FIRST = 0x02c0, //704
WM_TABLET_LAST = 0x02df, //735
WM_CUT = 0x0300, //768
WM_COPY = 0x0301, //769
WM_PASTE = 0x0302, //770
WM_CLEAR = 0x0303, //771
WM_UNDO = 0x0304, //772
WM_RENDERFORMAT = 0x0305, //773
WM_RENDERALLFORMATS = 0x0306, //774
WM_DESTROYCLIPBOARD = 0x0307, //775
WM_DRAWCLIPBOARD = 0x0308, //776
WM_PAINTCLIPBOARD = 0x0309, //777
WM_VSCROLLCLIPBOARD = 0x030A, //778
WM_SIZECLIPBOARD = 0x030B, //779
WM_ASKCBFORMATNAME = 0x030C, //780
WM_CHANGECBCHAIN = 0x030D, //781
WM_HSCROLLCLIPBOARD = 0x030E, //782
WM_QUERYNEWPALETTE = 0x030F, //783
WM_PALETTEISCHANGING = 0x0310, //784
WM_PALETTECHANGED = 0x0311, //785
WM_HOTKEY = 0x0312, //786
WM_PRINT = 0x0317, //791
WM_PRINTCLIENT = 0x0318, //792
WM_APPCOMMAND = 0x0319, //793
WM_THEMECHANGED = 0x031A, //794
WM_HANDHELDFIRST = 0x0358, //856
WM_HANDHELDLAST = 0x035F, //863
WM_AFXFIRST = 0x0360, //864
WM_AFXLAST = 0x037F, //895
WM_PENWINFIRST = 0x0380, //896
WM_PENWINLAST = 0x038F, //911
WM_APP = 0x8000, //32768
WM_USER = 0x0400, //1024
WM_HELP_Before0x0400 = 0x000c, //12
}

1. // ShowMSG.cpp : Defines the entry point for the application.
2. //
3.
4. #include "stdafx.h"
5. #include "ShowMSG.h"
6. #define MAX_LOADSTRING 100
7.
8. // Global Variables:
9. HINSTANCE hInst; // current instance
10. TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
11. TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
12.
13. // Forward declarations of functions included in this code module:
14. ATOM MyRegisterClass(HINSTANCE hInstance);
15. BOOL InitInstance(HINSTANCE, int);
16. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
17. LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
18.
19. //define Windows all message struct
20. typedef struct _MSGList
21. {
22. UINT MSGNum;
23. char MSG[50];
24. }MSGList,*PMSGList;
25.
26. HWND hSubOfNOTEPADWND = NULL;
27.
28. //Windows message List
29.
30. MSGList msglist[] = {
31. {0x0000, "WM_NULL"},
32. {0x0001, "WM_CREATE"},
33. {0x0002, "WM_DESTROY"},
34. {0x0003, "WM_MOVE"},
35. {0x0004, "WM_SIZEWAIT"},
36. {0x0005, "WM_SIZE"},
37. {0x0006, "WM_ACTIVATE"},
38. {0x0007, "WM_SETFOCUS"},
39. {0x0008, "WM_KILLFOCUS"},
40. {0x0009, "WM_SETVISIBLE"},
41. {0x000A, "WM_ENABLE"},
42. {0x000B, "WM_SETREDRAW"},
43. {0x000C, "WM_SETTEXT"},
44. {0x000D, "WM_GETTEXT"},
45. {0x000E, "WM_GETTEXTLENGTH"},
46. {0x000F, "WM_PAINT"},
47. {0x0010, "WM_CLOSE"},
48. {0x0011, "WM_QUERYENDSESSION"},
49. {0x0012, "WM_QUIT"},
50. {0x0013, "WM_QUERYOPEN"},
51. {0x0014, "WM_ERASEBKGND"},
52. {0x0015, "WM_SYSCOLORCHANGE"},
53. {0x0016, "WM_ENDSESSION"},
54. {0x0017, "WM_SYSTEMERROR"},
55. {0x0018, "WM_SHOWWINDOW"},
56. {0x0019, "WM_CTLCOLOR"},
57. {0x001A, "WM_WININICHANGE"},
58. {0x001B, "WM_DEVMODECHANGE"},
59. {0x001C, "WM_ACTIVATEAPP"},
60. {0x001D, "WM_FONTCHANGE"},
61. {0x001E, "WM_TIMECHANGE"},
62. {0x001F, "WM_CANCELMODE"},
63. {0x0020, "WM_SETCURSOR"},
64. {0x0021, "WM_MOUSEACTIVATE"},
65. {0x0022, "WM_CHILDACTIVATE"},
66. {0x0023, "WM_QUEUESYNC"},
67. {0x0024, "WM_GETMINMAXINFO"},
68. {0x0026, "WM_PAINTICON"},
69. {0x0027, "WM_ICONERASEBKGND"},
70. {0x0028, "WM_NEXTDLGCTL"},
71. {0x0029, "WM_ALTTABACTIVE"},
72. {0x002A, "WM_SPOOLERSTATUS"},
73. {0x002B, "WM_DRAWITEM"},
74. {0x002C, "WM_MEASUREITEM"},
75. {0x002D, "WM_DELETEITEM"},
76. {0x002E, "WM_VKEYTOITEM"},
77. {0x002F, "WM_CHARTOITEM"},
78. {0x0030, "WM_SETFONT"},
79. {0x0031, "WM_GETFONT"},
80. {0x0032, "WM_SETHOTKEY"},
81. {0x0033, "WM_GETHOTKEY"},
82. {0x0034, "WM_FILESYSCHANGE"},
83. {0x0035, "WM_ISACTIVEICON"},
84. {0x0036, "WM_QUERYPARKICON"},
85. {0x0037, "WM_QUERYDRAGICON"},
86. {0x0038, "WM_QUERYSAVESTATE"},
87. {0x0039, "WM_COMPAREITEM"},
88. {0x0040, "WM_TESTING"},
89. {0x0041, "WM_COMPACTING"},
90. {0x0044, "WM_COMMNOTIFY"},
91. {0x0046, "WM_WINDOWPOSCHANGING"},
92. {0x0047, "WM_WINDOWPOSCHANGED"},
93. {0x0048, "WM_POWER"},
94. {0x004A, "WM_COPYDATA"},
95. {0x004B, "WM_CANCELJOURNAL"},
96. {0x004E, "WM_NOTIFY"},
97. {0x0050, "WM_KBDCHANGEREQUEST"},
98. {0x0051, "WM_KBDLAYOUTCHANGE"},
99. {0x0052, "WM_TCARD"},
100. {0x0053, "WM_HELP"},
101. {0x0054, "WM_USERCHANGED"},
102. {0x0055, "WM_NOTIFYFORMAT"},
103. {0x007B, "WM_CONTEXTMENU"},
104. {0x007C, "WM_STYLECHANGING"},
105. {0x007D, "WM_STYLECHANGED"},
106. {0x007E, "WM_DISPLAYCHANGE"},
107. {0x007F, "WM_GETICON"},
108. {0x0080, "WM_SETICON"},
109. {0x0081, "WM_NCCREATE"},
110. {0x0082, "WM_NCDESTROY"},
111. {0x0083, "WM_NCCALCSIZE"},
112. {0x0084, "WM_NCHITTEST"},
113. {0x0085, "WM_NCPAINT"},
114. {0x0086, "WM_NCACTIVATE"},
115. {0x0087, "WM_GETDLGCODE"},
116. {0x0088, "WM_SYNCPAINT"},
117. {0x0089, "WM_SYNCTASK"},
118. {0x00A0, "WM_NCMOUSEMOVE"},
119. {0x00A1, "WM_NCLBUTTONDOWN"},
120. {0x00A2, "WM_NCLBUTTONUP"},
121. {0x00A3, "WM_NCLBUTTONDBLCLK"},
122. {0x00A4, "WM_NCRBUTTONDOWN"},
123. {0x00A5, "WM_NCRBUTTONUP"},
124. {0x00A6, "WM_NCRBUTTONDBLCLK"},
125. {0x00A7, "WM_NCMBUTTONDOWN"},
126. {0x00A8, "WM_NCMBUTTONUP"},
127. {0x00A9, "WM_NCMBUTTONDBLCLK"},
128. {0x00B0, "EM_GETSEL"},
129. {0x00B1, "EM_SETSEL"},
130. {0x00B2, "EM_GETRECT"},
131. {0x00B3, "EM_SETRECT"},
132. {0x00B4, "EM_SETRECTNP"},
133. {0x00B5, "EM_SCROLL"},
134. {0x00B6, "EM_LINESCROLL"},
135. {0x00B7, "EM_SCROLLCARET"},
136. {0x00B8, "EM_GETMODIFY"},
137. {0x00B9, "EM_SETMODIFY"},
138. {0x00BA, "EM_GETLINECOUNT"},
139. {0x00BB, "EM_LINEINDEX"},
140. {0x00BC, "EM_SETHANDLE"},
141. {0x00BD, "EM_GETHANDLE"},
142. {0x00BE, "EM_GETTHUMB"},
143. {0x00C1, "EM_LINELENGTH"},
144. {0x00C2, "EM_REPLACESEL"},
145. {0x00C4, "EM_GETLINE"},
146. {0x00C5, "EM_LIMITTEXT"},
147. {0x00C6, "EM_CANUNDO"},
148. {0x00C7, "EM_UNDO"},
149. {0x00C8, "EM_FMTLINES"},
150. {0x00C9, "EM_LINEFROMCHAR"},
151. {0x00CB, "EM_SETTABSTOPS"},
152. {0x00CC, "EM_SETPASSWORDCHAR"},
153. {0x00CD, "EM_EMPTYUNDOBUFFER"},
154. {0x00CE, "EM_GETFIRSTVISIBLELINE"},
155. {0x00CF, "EM_SETREADONLY"},
156. {0x00D0, "EM_SETWORDBREAKPROC"},
157. {0x00D1, "EM_GETWORDBREAKPROC"},
158. {0x00D2, "EM_GETPASSWORDCHAR"},
159. {0x00D3, "EM_SETMARGINS"},
160. {0x00D4, "EM_GETMARGINS"},
161. {0x00D5, "EM_GETLIMITTEXT"},
162. {0x00D6, "EM_POSFROMCHAR"},
163. {0x00D7, "EM_CHARFROMPOS"},
164. {0x00E0, "SBM_SETPOS"},
165. {0x00E1, "SBM_GETPOS"},
166. {0x00E2, "SBM_SETRANGE"},
167. {0x00E3, "SBM_GETRANGE"},
168. {0x00E4, "SBM_ENABLE_ARROWS"},
169. {0x00E6, "SBM_SETRANGEREDRAW"},
170. {0x00E9, "SBM_SETSCROLLINFO"},
171. {0x00EA, "SBM_GETSCROLLINFO"},
172. {0x0100, "WM_KEYFIRST"},
173. {0x0100, "WM_KEYDOWN"},
174. {0x0101, "WM_KEYUP"},
175. {0x0102, "WM_CHAR"},
176. {0x0103, "WM_DEADCHAR"},
177. {0x0104, "WM_SYSKEYDOWN"},
178. {0x0105, "WM_SYSKEYUP"},
179. {0x0106, "WM_SYSCHAR"},
180. {0x0107, "WM_SYSDEADCHAR"},
181. {0x0108, "WM_KEYLAST"},
182. {0x010A, "WM_CONVERTREQUEST"},
183. {0x010B, "WM_CONVERTRESULT"},
184. {0x010C, "WM_INTERIM"},
185. {0x0110, "WM_INITDIALOG"},
186. {0x0111, "WM_COMMAND"},
187. {0x0112, "WM_SYSCOMMAND"},
188. {0x0113, "WM_TIMER"},
189. {0x0114, "WM_HSCROLL"},
190. {0x0115, "WM_VSCROLL"},
191. {0x0116, "WM_INITMENU"},
192. {0x0117, "WM_INITMENUPOPUP"},
193. {0x0118, "WM_SYSTIMER"},
194. {0x011F, "WM_MENUSELECT"},
195. {0x0120, "WM_MENUCHAR"},
196. {0x0121, "WM_ENTERIDLE"},
197. {0x0131, "WM_LBTRACKPOINT"},
198. {0x0132, "WM_CTLCOLORMSGBOX"},
199. {0x0133, "WM_CTLCOLOREDIT"},
200. {0x0134, "WM_CTLCOLORLISTBOX"},
201. {0x0135, "WM_CTLCOLORBTN"},
202. {0x0136, "WM_CTLCOLORDLG"},
203. {0x0137, "WM_CTLCOLORSCROLLBAR"},
204. {0x0138, "WM_CTLCOLORSTATIC"},
205. {0x0140, "CB_GETEDITSEL"},
206. {0x0141, "CB_LIMITTEXT"},
207. {0x0142, "CB_SETEDITSEL"},
208. {0x0143, "CB_ADDSTRING"},
209. {0x0144, "CB_DELETESTRING"},
210. {0x0145, "CB_DIR"},
211. {0x0146, "CB_GETCOUNT"},
212. {0x0147, "CB_GETCURSEL"},
213. {0x0148, "CB_GETLBTEXT"},
214. {0x0149, "CB_GETLBTEXTLEN"},
215. {0x014A, "CB_INSERTSTRING"},
216. {0x014B, "CB_RESETCONTENT"},
217. {0x014C, "CB_FINDSTRING"},
218. {0x014D, "CB_SELECTSTRING"},
219. {0x014E, "CB_SETCURSEL"},
220. {0x014F, "CB_SHOWDROPDOWN"},
221. {0x0150, "CB_GETITEMDATA"},
222. {0x0151, "CB_SETITEMDATA"},
223. {0x0152, "CB_GETDROPPEDCONTROLRECT"},
224. {0x0153, "CB_SETITEMHEIGHT"},
225. {0x0154, "CB_GETITEMHEIGHT"},
226. {0x0155, "CB_SETEXTENDEDUI"},
227. {0x0156, "CB_GETEXTENDEDUI"},
228. {0x0157, "CB_GETDROPPEDSTATE"},
229. {0x0158, "CB_FINDSTRINGEXACT"},
230. {0x0159, "CB_SETLOCALE"},
231. {0x015A, "CB_GETLOCALE"},
232. {0x015B, "CB_GETTOPINDEX"},
233. {0x015C, "CB_SETTOPINDEX"},
234. {0x015D, "CB_GETHORIZONTALEXTENT"},
235. {0x015E, "CB_SETHORIZONTALEXTENT"},
236. {0x015F, "CB_GETDROPPEDWIDTH"},
237. {0x0160, "CB_SETDROPPEDWIDTH"},
238. {0x0161, "CB_INITSTORAGE"},
239. {0x0170, "STM_SETICON"},
240. {0x0171, "STM_GETICON"},
241. {0x0172, "STM_SETIMAGE"},
242. {0x0173, "STM_GETIMAGE"},
243. {0x0180, "LB_ADDSTRING"},
244. {0x0181, "LB_INSERTSTRING"},
245. {0x0182, "LB_DELETESTRING"},
246. {0x0183, "LB_SELITEMRANGEEX"},
247. {0x0184, "LB_RESETCONTENT"},
248. {0x0185, "LB_SETSEL"},
249. {0x0186, "LB_SETCURSEL"},
250. {0x0187, "LB_GETSEL"},
251. {0x0188, "LB_GETCURSEL"},
252. {0x0189, "LB_GETTEXT"},
253. {0x018A, "LB_GETTEXTLEN"},
254. {0x018B, "LB_GETCOUNT"},
255. {0x018C, "LB_SELECTSTRING"},
256. {0x018D, "LB_DIR"},
257. {0x018E, "LB_GETTOPINDEX"},
258. {0x018F, "LB_FINDSTRING"},
259. {0x0190, "LB_GETSELCOUNT"},
260. {0x0191, "LB_GETSELITEMS"},
261. {0x0192, "LB_SETTABSTOPS"},
262. {0x0193, "LB_GETHORIZONTALEXTENT"},
263. {0x0194, "LB_SETHORIZONTALEXTENT"},
264. {0x0195, "LB_SETCOLUMNWIDTH"},
265. {0x0196, "LB_ADDFILE"},
266. {0x0197, "LB_SETTOPINDEX"},
267. {0x0198, "LB_GETITEMRECT"},
268. {0x0199, "LB_GETITEMDATA"},
269. {0x019A, "LB_SETITEMDATA"},
270. {0x019B, "LB_SELITEMRANGE"},
271. {0x019C, "LB_SETANCHORINDEX"},
272. {0x019D, "LB_GETANCHORINDEX"},
273. {0x019E, "LB_SETCARETINDEX"},
274. {0x019F, "LB_GETCARETINDEX"},
275. {0x01A0, "LB_SETITEMHEIGHT"},
276. {0x01A1, "LB_GETITEMHEIGHT"},
277. {0x01A2, "LB_FINDSTRINGEXACT"},
278. {0x01A5, "LB_SETLOCALE"},
279. {0x01A6, "LB_GETLOCALE"},
280. {0x01A7, "LB_SETCOUNT"},
281. {0x01A8, "LB_INITSTORAGE"},
282. {0x01A9, "LB_ITEMFROMPOINT"},
283. {0x01E0, "MN_SETHMENU"},
284. {0x01E1, "MN_GETHMENU"},
285. {0x01E2, "MN_SIZEWINDOW"},
286. {0x01E3, "MN_OPENHIERARCHY"},
287. {0x01E4, "MN_CLOSEHIERARCHY"},
288. {0x01E5, "MN_SELECTITEM"},
289. {0x01E6, "MN_CANCELMENUS"},
290. {0x01E7, "MN_SELECTFIRSTVALIDITEM"},
291. {0x0200, "WM_MOUSEFIRST"},
292. {0x0200, "WM_MOUSEMOVE"},
293. {0x0201, "WM_LBUTTONDOWN"},
294. {0x0202, "WM_LBUTTONUP"},
295. {0x0203, "WM_LBUTTONDBLCLK"},
296. {0x0204, "WM_RBUTTONDOWN"},
297. {0x0205, "WM_RBUTTONUP"},
298. {0x0206, "WM_RBUTTONDBLCLK"},
299. {0x0207, "WM_MBUTTONDOWN"},
300. {0x0208, "WM_MBUTTONUP"},
301. {0x0209, "WM_MOUSELAST"},
302. {0x0209, "WM_MBUTTONDBLCLK"},
303. {0x0210, "WM_PARENTNOTIFY"},
304. {0x0211, "WM_ENTERMENULOOP"},
305. {0x0212, "WM_EXITMENULOOP"},
306. {0x0213, "WM_NEXTMENU"},
307. {0x0214, "WM_SIZING"},
308. {0x0215, "WM_CAPTURECHANGED"},
309. {0x0216, "WM_MOVING"},
310. {0x0217, "WM_DEVICEBROADCAST"},
311. {0x0218, "WM_POWERBROADCAST"},
312. {0x0219, "WM_DEVICECHANGE"},
313. {0x0220, "WM_MDICREATE"},
314. {0x0221, "WM_MDIDESTROY"},
315. {0x0222, "WM_MDIACTIVATE"},
316. {0x0223, "WM_MDIRESTORE"},
317. {0x0224, "WM_MDINEXT"},
318. {0x0225, "WM_MDIMAXIMIZE"},
319. {0x0226, "WM_MDITILE"},
320. {0x0227, "WM_MDICASCADE"},
321. {0x0228, "WM_MDIICONARRANGE"},
322. {0x0229, "WM_MDIGETACTIVE"},
323. {0x022A, "WM_DROPOBJECT"},
324. {0x022B, "WM_QUERYDROPOBJECT"},
325. {0x022C, "WM_BEGINDRAG"},
326. {0x022D, "WM_DRAGLOOP"},
327. {0x022E, "WM_DRAGSELECT"},
328. {0x022F, "WM_DRAGMOVE"},
329. {0x0230, "WM_MDISETMENU"},
330. {0x0231, "WM_ENTERSIZEMOVE"},
331. {0x0232, "WM_EXITSIZEMOVE"},
332. {0x0233, "WM_DROPFILES"},
333. {0x0234, "WM_MDIREFRESHMENU"},
334. {0x0281, "WM_IME_SETCONTEXT"},
335. {0x0282, "WM_IME_NOTIFY"},
336. {0x0283, "WM_IME_CONTROL"},
337. {0x0284, "WM_IME_COMPOSITIONFULL"},
338. {0x0285, "WM_IME_SELECT"},
339. {0x0286, "WM_IME_CHAR"},
340. {0x0290, "WM_IME_KEYDOWN"},
341. {0x0291, "WM_IME_KEYUP"},
342. {0x0300, "WM_CUT"},
343. {0x0301, "WM_COPY"},
344. {0x0302, "WM_PASTE"},
345. {0x0303, "WM_CLEAR"},
346. {0x0304, "WM_UNDO"},
347. {0x0305, "WM_RENDERFORMAT"},
348. {0x0306, "WM_RENDERALLFORMATS"},
349. {0x0307, "WM_DESTROYCLIPBOARD"},
350. {0x0308, "WM_DRAWCLIPBOARD"},
351. {0x0309, "WM_PAINTCLIPBOARD"},
352. {0x030A, "WM_VSCROLLCLIPBOARD"},
353. {0x030B, "WM_SIZECLIPBOARD"},
354. {0x030C, "WM_ASKCBFORMATNAME"},
355. {0x030D, "WM_CHANGECBCHAIN"},
356. {0x030E, "WM_HSCROLLCLIPBOARD"},
357. {0x030F, "WM_QUERYNEWPALETTE"},
358. {0x0310, "WM_PALETTEISCHANGING"},
359. {0x0311, "WM_PALETTECHANGED"},
360. {0x0312, "WM_HOTKEY"},
361. {0x0317, "WM_PRINT"},
362. {0x0318, "WM_PRINTCLIENT"},
363. {0x0360, "WM_QUERYAFXWNDPROC"},
364. {0x0361, "WM_SIZEPARENT"},
365. {0x0362, "WM_SETMESSAGESTRING"},
366. {0x0363, "WM_IDLEUPDATECMDUI"},
367. {0x0364, "WM_INITIALUPDATE"},
368. {0x0365, "WM_COMMANDHELP"},
369. {0x0366, "WM_HELPHITTEST"},
370. {0x0367, "WM_EXITHELPMODE"},
371. {0x0368, "WM_RECALCPARENT"},
372. {0x0369, "WM_SIZECHILD"},
373. {0x036A, "WM_KICKIDLE"},
374. {0x036B, "WM_QUERYCENTERWND"},
375. {0x036C, "WM_DISABLEMODAL"},
376. {0x036D, "WM_FLOATSTATUS"},
377. {0x036E, "WM_ACTIVATETOPLEVEL"},
378. {0x036F, "WM_QUERY3DCONTROLS"},
379. {0x03E0, "WM_DDE_FIRST"},
380. {0x03E0, "WM_DDE_INITIATE"},
381. {0x03E1, "WM_DDE_TERMINATE"},
382. {0x03E2, "WM_DDE_ADVISE"},
383. {0x03E3, "WM_DDE_UNADVISE"},
384. {0x03E4, "WM_DDE_ACK"},
385. {0x03E5, "WM_DDE_DATA"},
386. {0x03E6, "WM_DDE_REQUEST"},
387. {0x03E7, "WM_DDE_POKE"},
388. {0x03E8, "WM_DDE_LAST"},
389. {0x03E8, "WM_DDE_EXECUTE"}
390. };
391.
392.
393. int APIENTRY _tWinMain(HINSTANCE hInstance,
394. HINSTANCE hPrevInstance,
395. LPTSTR lpCmdLine,
396. int nCmdShow)
397. {
398. // TODO: Place code here.
399. MSG msg;
400. HACCEL hAccelTable;
401.
402. // Initialize global strings
403. LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
404. LoadString(hInstance, IDC_SHOWMSG, szWindowClass, MAX_LOADSTRING);
405. MyRegisterClass(hInstance);
406.
407. //open NOTEPAD.EXE to display Windows message
408. char NOTEPADPath[MAX_PATH];
409. memset(NOTEPADPath,0,sizeof(NOTEPADPath));
410. GetWindowsDirectory(NOTEPADPath,MAX_PATH);
411. strcat(NOTEPADPath,"\\NOTEPAD.EXE");
412. WinExec(NOTEPADPath,SW_SHOWNORMAL);
413.
414. HWND hNOTEPADWND = NULL;
415. POINT NotePadPoint = {0};
416. NotePadPoint.x = 20;
417. NotePadPoint.y = 20;
418. hNOTEPADWND = FindWindow("NOTEPAD",NULL);
419. if(hNOTEPADWND == NULL)
420. {
421. MessageBox(NULL,"ÎÞ·¨ÕÒµ½¼Çʱ¾£¡","error",MB_OK);
422. }
423. hSubOfNOTEPADWND = ChildWindowFromPoint(hNOTEPADWND,NotePadPoint);
424.
425. // Perform application initialization:
426. if (!InitInstance (hInstance, nCmdShow))
427. {
428. return FALSE;
429. }
430.
431. hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SHOWMSG);
432.
433. // Main message loop:
434. while (GetMessage(&msg, NULL, 0, 0))
435. {
436. if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
437. {
438. TranslateMessage(&msg);
439. DispatchMessage(&msg);
440. }
441. }
442.
443. return (int) msg.wParam;
444. }
445.
446.
447.
448. //
449. // FUNCTION: MyRegisterClass()
450. //
451. // PURPOSE: Registers the window class.
452. //
453. // COMMENTS:
454. //
455. // This function and its usage are only necessary if you want this code
456. // to be compatible with Win32 systems prior to the 'RegisterClassEx'
457. // function that was added to Windows 95. It is important to call this function
458. // so that the application will get 'well formed' small icons associated
459. // with it.
460. //
461. ATOM MyRegisterClass(HINSTANCE hInstance)
462. {
463. WNDCLASSEX wcex;
464.
465. wcex.cbSize = sizeof(WNDCLASSEX);
466.
467. wcex.style = CS_HREDRAW | CS_VREDRAW;
468. wcex.lpfnWndProc = (WNDPROC)WndProc;
469. wcex.cbClsExtra = 0;
470. wcex.cbWndExtra = 0;
471. wcex.hInstance = hInstance;
472. wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SHOWMSG);
473. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
474. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
475. wcex.lpszMenuName = (LPCTSTR)IDC_SHOWMSG;
476. wcex.lpszClassName = szWindowClass;
477. wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
478.
479. return RegisterClassEx(&wcex);
480. }
481.
482. //
483. // FUNCTION: InitInstance(HANDLE, int)
484. //
485. // PURPOSE: Saves instance handle and creates main window
486. //
487. // COMMENTS:
488. //
489. // In this function, we save the instance handle in a global variable and
490. // create and display the main program window.
491. //
492. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
493. {
494. HWND hWnd;
495.
496. hInst = hInstance; // Store instance handle in our global variable
497.
498. hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
499. CW_USEDEFAULT, 0, 200, 200, NULL, NULL, hInstance, NULL);
500.
501. if (!hWnd)
502. {
503. return FALSE;
504. }
505.
506. ShowWindow(hWnd, nCmdShow);
507. UpdateWindow(hWnd);
508.
509. return TRUE;
510. }
511.
512. //
513. // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
514. //
515. // PURPOSE: Processes messages for the main window.
516. //
517. // WM_COMMAND - process the application menu
518. // WM_PAINT - Paint the main window
519. // WM_DESTROY - post a quit message and return
520. //
521. //
522. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
523. {
524. int wmId, wmEvent;
525. PAINTSTRUCT ps;
526. HDC hdc;
527.
528. //Search message
529. MSGList MSGListtemp = {0};
530. memset(MSGListtemp.MSG,0,sizeof(MSGListtemp.MSG));
531. MSGListtemp.MSGNum = message;
532.
533. PMSGList pMSGList = msglist;
534. for(int i = 0;i<=0x03E8;++i)
535. {
536. if(pMSGList->MSGNum == MSGListtemp.MSGNum)
537. {
538. strcpy(MSGListtemp.MSG,pMSGList->MSG);
539. break;
540. }
541. pMSGList++;
542. }
543.
544. for(int j = 0;j<=50;++j)
545. {
546. int Char_int = 0;
547. Char_int = MSGListtemp.MSG[j];
548. if(Char_int)
549. {
550. PostMessage(hSubOfNOTEPADWND,WM_CHAR,(WPARAM)Char_int,1);
551. }
552. else
553. {
554. PostMessage(hSubOfNOTEPADWND,WM_CHAR,'\n',1);
555. break;
556. }
557. }
558.
559.
560. switch (message)
561. {
562. case WM_COMMAND:
563. wmId = LOWORD(wParam);
564. wmEvent = HIWORD(wParam);
565. // Parse the menu selections:
566. switch (wmId)
567. {
568. case IDM_ABOUT:
569. DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
570. break;
571. case IDM_EXIT:
572. DestroyWindow(hWnd);
573. break;
574. default:
575. return DefWindowProc(hWnd, message, wParam, lParam);
576. }
577. break;
578. case WM_PAINT:
579. hdc = BeginPaint(hWnd, &ps);
580. // TODO: Add any drawing code here...
581. EndPaint(hWnd, &ps);
582. break;
583. case WM_DESTROY:
584. PostQuitMessage(0);
585. break;
586. default:
587. return DefWindowProc(hWnd, message, wParam, lParam);
588. }
589. return 0;
590. }
591.
592. // Message handler for about box.
593. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
594. {
595. switch (message)
596. {
597. case WM_INITDIALOG:
598. return TRUE;
599.
600. case WM_COMMAND:
601. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
602. {
603. EndDialog(hDlg, LOWORD(wParam));
604. return TRUE;
605. }
606. break;
607. }
608. return FALSE;
609. }

Wednesday, August 05, 2009

AS3 URI parser and code sequence to detect local file versus valid moniker

Sometimes when passing a file path to a SWF you would like to perform FileExistabce check before passing the file to an AS3 class. To do so you want to know if a URI is a file or an http URL or any other URI with specific protocol (moniker).
The following code will tell you if you are dealing with a local full or relative path.



var strURI:String;
var semicolumn:int = -1;
var bRemote:Boolean = false;
var bFileURI:Boolean = false;
var bUnknownURI:Boolean = false;
var bLocalFileExist:Boolean = false;
var uri:Object;
var p:String;
var strAuthority:String;
var strRelative:String;
var strProtocol:String;
var strFile:String;
var strQuery:String;
var strPath:String;
var strHost:String;
var strDirectory:String;
var strPort:String;
var strPassword:String;
var strUser:String;
var strUserInfo:String;
var strSource:String;
var strAnchor:String;
var _strURI:String = "c:\\folder\\subfolder\\test.flv";

uri = parseUri(_strURI);
for (p in uri)
{
switch (p)
{
case "authority":
strAuthority = uri[p];
break;
case "relative":
strRelative = uri[p];
break;
case "file":
strFile = uri[p];
break;
case "query":
strQuery = uri[p];
break;
case "path":
strPath = uri[p];
break;
case "host":
strHost = uri[p];
break;
case "directory":
strDirectory = uri[p];
break;
case "port":
strPort = uri[p];
break;
case "protocol":
strProtocol = uri[p];
break;
case "password":
strPassword = uri[p];
break;
case "user":
strUser = uri[p];
break;
case "userInfo":
strUserInfo = uri[p];
break;
case "source":
strSource = uri[p];
break;
case "anchor":
strAnchor = uri[p];
break;
default :
//trace(p + ": " + uri[p]);
break;
}
}

if ( (strProtocol.toLowerCase() == "http") ||
(strProtocol.toLowerCase().substr(0, 4) == "rtmp") )
bRemote = true;

if (strProtocol.toLowerCase() == "file")
bFileURI = true;

if (bRemote == false && bFileURI == false && strProtocol.toLowerCase() == "")
{
bUnknownURI = true;
// we have an unknown file moniker
// probably relative path we may have to reject
}

if (bUnknownURI || bFileURI)
{

semicolumn = _strVideoURL.lastIndexOf(":");
if ( (semicolumn>=0) && bFileURI ) {
strURI = _strVideoURL;
}
else
{
strURI = "file://" + _strVideoURL;
}

trace("URI = " + strURI);
}


public function parseUri(str:String, strictMode:Boolean=false):Object {
var o:Object = new Object();
o.strictMode = strictMode;
o.key = new Array("source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor");
o.q = new Object();
o.q.name = "queryKey";
o.q.parser = /(?:^|&)([^&=]*)=?([^&]*)/g
o.parser = new Object();
o.parser.strict = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/
o.parser.loose = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/

var m:Object = o.parser[o.strictMode ? "strict" : "loose"].exec(str);
var uri:Object = new Object();
var i:int = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = new Object();
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2){
if ($1) uri[o.q.name][$1] = $2;
}
);
return uri;
}


Enjoy !