-
Notifications
You must be signed in to change notification settings - Fork 0
/
AsmPad.asm
761 lines (606 loc) · 22.1 KB
/
AsmPad.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
; #########################################################################
.386
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include AsmPad.inc ; local includes for this file
include \masm32\macros\macros.asm
; ---------------------------------------
; Select rich edit version here, leave
; uncomment for richedit version 1 or
; comment out for richedit version 2
; ---------------------------------------
;riched1 equ <anytext>
; -----------------------------------
; Select right click menu popup here
; -----------------------------------
menu_popup equ 0 ; 0 = File, 1 = Edit etc ....
; --------------------------
; Select either system font
; --------------------------
edit_font equ <SYSTEM_FIXED_FONT>
; edit_font equ <ANSI_FIXED_FONT>
; #########################################################################
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke InitCommonControls
; --------------------------
; preset GLOBAL scope flags
; --------------------------
mov CaseFlag, 1
mov WholeWord, 0
mov CtrlFlag, 0
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
; #########################################################################
WinMain proc hInst :DWORD,
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD
;====================
; Put LOCALs on stack
;====================
LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD
LOCAL mWid :DWORD
LOCAL lpArg:DWORD
LOCAL sWid :DWORD
LOCAL sHgt :DWORD
LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
;; LOCAL Wwd:DWORD,Wht:DWORD,Wtx:DWORD,Wty:DWORD,
; --------------------------------------------------
; Fill WNDCLASSEX structure with required variables
; --------------------------------------------------
invoke LoadIcon,hInst,500 ; icon ID
mov hIcon, eax
szText szClassName,"Rich_Edit_Class"
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInst
mov wc.hbrBackground, NULL
m2m wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName
m2m wc.hIcon, hIcon
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
m2m wc.hIconSm, hIcon
invoke RegisterClassEx, ADDR wc
; ---------------------------------------------
; set width and height as percentages of screen
; ---------------------------------------------
mov sWid, rv(GetSystemMetrics,SM_CXSCREEN)
mov sHgt, rv(GetSystemMetrics,SM_CYSCREEN)
invoke GetPercent,sWid,42
mov Wwd, eax
invoke GetPercent,sHgt,62
mov Wht, eax
; ----------------------
; set aspect ratio limit
; ----------------------
FLOAT4 aspect_ratio, 1.4 ; set the maximum startup aspect ratio
fild Wht ; load source
fld aspect_ratio ; load multiplier
fmul ; multiply source by multiplier
fistp mWid ; store result in variable
mov eax, Wwd
.if eax > mWid ; if the default window width is > aspect ratio
m2m Wwd, mWid ; set the width to the maximum aspect ratio
.endif
; ------------------------------------------------
; Top X and Y co-ordinates for the centered window
; ------------------------------------------------
mov eax, sWid
sub eax, Wwd ; sub window width from screen width
shr eax, 1 ; divide it by 2
mov Wtx, eax ; copy it to variable
mov eax, sHgt
sub eax, Wht ; sub window height from screen height
shr eax, 1 ; divide it by 2
mov Wty, eax ; copy it to variable
; ----------------------------------
invoke CreateWindowEx,WS_EX_LEFT or WS_EX_ACCEPTFILES,
ADDR szClassName,
ADDR Untitled,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInst,NULL
mov hWnd,eax
; ------------------------------
; get any command line filename
; ------------------------------
invoke PathGetArgs,CommandLine
mov lpArg, eax
mov esi, eax
lodsb
cmp al, 0
je noArgs ; jump if no arg
cmp al, 34
jne @F ; jump if no quote
invoke PathUnquoteSpaces,lpArg
mov lpArg, eax
@@:
invoke exist,lpArg
.if eax == 1
invoke StreamFileIn,hRichEd,lpArg
invoke SetWindowText,hWnd,lpArg
invoke SendMessage,hRichEd,EM_SETMODIFY,0,0
.else
szText cantfind,"Sorry, cannot find that file."
invoke MessageBox,hWnd,lpArg,ADDR cantfind,MB_OK
.endif
noArgs:
; ------------------------------
invoke LoadMenu,hInst,600 ; menu ID
mov hMnu, eax
invoke SetMenu,hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
; -----------------------------------
; Loop until PostQuitMessage is sent
; -----------------------------------
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
; ------------------------------------------------
; process keystrokes directly in the message loop
; ------------------------------------------------
.if msg.message == WM_KEYDOWN
.if msg.wParam == VK_ESCAPE
invoke SendMessage,hWnd,WM_SYSCOMMAND,SC_CLOSE,NULL
.elseif msg.wParam == VK_CONTROL
mov CtrlFlag, 1 ; flag set
.endif
.endif
.if msg.message == WM_KEYUP
;.if msg.wParam == VK_CONTROL
mov CtrlFlag, 0 ; flag clear
;.endif
.endif
.if msg.message == WM_KEYDOWN
;.if msg.wParam == VK_CONTROL
;mov CtrlFlag, 0 ; flag clear
.if msg.wParam == 54h ; Ctrl + T
.if CtrlFlag == 1
invoke SendMessage,hWnd,WM_COMMAND,1106,0
.endif
.elseif msg.wParam == 4Eh ; Ctrl + N
.if CtrlFlag == 1
invoke SendMessage,hWnd,WM_COMMAND,1000,0
.endif
.elseif msg.wParam == 57h ; Ctrl + W
.if CtrlFlag == 1
invoke SendMessage,hWnd,WM_COMMAND,1001,0
jmp StartLoop
.endif
.elseif msg.wParam == 4Fh ; Ctrl + O
.if CtrlFlag == 1
invoke SendMessage,hWnd,WM_COMMAND,1002,0
.endif
.elseif msg.wParam == 53h ; Ctrl + S
.if CtrlFlag == 1
invoke SendMessage,hWnd,WM_COMMAND,1003,0
.endif
.elseif msg.wParam == 42h ; Ctrl + B
.if CtrlFlag == 1
invoke SendMessage,hWnd,WM_COMMAND,1004,0
.endif
.elseif msg.wParam == 74h ; F5
invoke SendMessage,hWnd,WM_COMMAND,1200,0
.endif
.endif
; ------------------------------------------------
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:
return msg.wParam
WinMain endp
; #########################################################################
WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD
LOCAL var :DWORD
LOCAL caW :DWORD
LOCAL caH :DWORD
LOCAL hTbar :DWORD
LOCAL hSbar :DWORD
LOCAL tl :DWORD
LOCAL hDC :DWORD
LOCAL lpTxt :DWORD
LOCAL nmh :NMHDR
LOCAL Rct :RECT
LOCAL Ps :PAINTSTRUCT
LOCAL tbab :TBADDBITMAP
LOCAL tbb :TBBUTTON
LOCAL buffer1[260]:BYTE
LOCAL FileBuffer[260]:BYTE
LOCAL tmpBuf[260]:BYTE
.if uMsg == WM_COMMAND
;======== toolbar commands ========
.if wParam == 50
jmp NewFile
.elseif wParam == 51
jmp FileOpen
.elseif wParam == 52
jmp FileSave
.elseif wParam == 53
jmp mnu_Cut
.elseif wParam == 54
jmp mnu_Copy
.elseif wParam == 55
jmp mnu_Paste
.elseif wParam == 56
jmp mnu_Undo
.elseif wParam == 57
jmp mnu_Redo
.elseif wParam == 58
jmp mnu_FindText
.elseif wParam == 59
jmp mnu_Run
.elseif wParam == 60
jmp new_instance
.elseif wParam == 61
jmp QuitApp
;======== menu commands ========
.elseif wParam == 1000 ; **** New ****
NewFile:
invoke Confirmation,hRichEd
.if eax == IDYES
jmp FileSave
.elseif eax == IDNO
jmp @F
.elseif eax == IDCANCEL
return 0
.endif
@@:
invoke SendMessage,hWin,WM_SETTEXT,0,ADDR Untitled
invoke SendMessage,hRichEd,WM_SETTEXT,0,0
invoke SendMessage,hRichEd,EM_SETMODIFY,0,0
; -------------------------
; Reset status bar message
; -------------------------
szText nStr,0
invoke SendMessage,hStatus,SB_SETTEXT,3,ADDR nStr
.elseif wParam == 1001 ; **** New Instance ****
new_instance:
invoke GetModuleFileName,NULL,ADDR buffer1,128
invoke WinExec,ADDR buffer1,SW_SHOW
.elseif wParam == 1002 ; **** Open ****
FileOpen:
invoke Confirmation,hRichEd
.if eax == IDYES
jmp FileSave
.elseif eax == IDCANCEL
return 0
.endif
jmp @F
szTitleO db "Open A File",0
szFilterO db "All files",0,"*.*",0,
"Text files",0,"*.TEXT",0,0
@@:
mov szFileName[0],0
invoke GetFileName,hWin,ADDR szTitleO,ADDR szFilterO
cmp szFileName[0],0 ;<< zero if cancel pressed in dlgbox
je @F
invoke StreamFileIn,hRichEd,ADDR szFileName
invoke SetWindowText,hWin,ADDR szFileName
@@:
.elseif wParam == 1003 ; **** Save ****
FileSave:
invoke SendMessage,hWin,WM_GETTEXTLENGTH,0,0
mov tl, eax
inc tl ; 1 extra for zero terminator
invoke GetWindowText,hWin,ADDR buffer1,tl
invoke lstrcmp,ADDR buffer1,ADDR Untitled
cmp eax, 0 ; eax is zero is strings are equal
jne @F
jmp FileSaveAs
@@:
invoke StreamFileOut,hRichEd,ADDR buffer1
invoke SendMessage,hRichEd,EM_SETMODIFY,0,0
.elseif wParam == 1004 ; **** Save As ****
FileSaveAs:
jmp @F
szTitleS db "Save file as",0
szFilterS db "All files",0,"*.*",0,
"Text files",0,"*.TEXT",0,0
@@:
mov szFileName[0],0
invoke SaveFileName,hWin,ADDR szTitleS,ADDR szFilterS
cmp szFileName[0],0 ;<< zero if cancel pressed in dlgbox
je @F
invoke StreamFileOut,hRichEd,ADDR szFileName
invoke SendMessage,hRichEd,EM_SETMODIFY,0,0
invoke SendMessage,hWin,WM_SETTEXT,0,ADDR szFileName
@@:
.elseif wParam == 1005
invoke MergeFile,hRichEd
.elseif wParam == 1010 ; **** Exit ****
QuitApp:
invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
; ----------
; Edit Menu
; ----------
.elseif wParam == 1100
mnu_Undo:
invoke SendMessage,hRichEd,EM_UNDO,0,0
.elseif wParam == 1101
mnu_Redo:
invoke SendMessage,hRichEd,EM_REDO,0,0
.elseif wParam == 1102
mnu_Cut:
invoke SendMessage,hRichEd,WM_CUT,0,0
.elseif wParam == 1103
mnu_Copy:
invoke SendMessage,hRichEd,WM_COPY,0,0
.elseif wParam == 1104
mnu_Paste:
invoke SendMessage,hRichEd,EM_PASTESPECIAL,CF_TEXT,0
.elseif wParam == 1105
invoke SendMessage,hRichEd,WM_CLEAR,0,0
.elseif wParam == 1106
invoke SendMessage,hRichEd,EM_SETOPTIONS,ECOOP_XOR,ECO_SELECTIONBAR
.elseif wParam == 1107
mnu_FindText:
invoke CallSearchDlg
.elseif wParam == 1108
mnu_FindNext:
invoke TextFind,ADDR SearchText,TextLen
.elseif wParam == 1109
invoke Select_All,hRichEd
.elseif wParam == 1900 ; **** About ****
szText caption,"AsmPad"
szText msg,"Simple Asm Text Editor",13,10,\
"Copyright © 2019 Michael Binder aka RednibCoding"
fn MsgboxI,hWin,ADDR msg,ADDR caption,MB_OK,500
; ----------
; Run Menu
; ----------
.elseif wParam == 1200
mnu_Run:
invoke SendMessage,hWin,WM_GETTEXTLENGTH,0,0
mov tl, eax
inc tl ; 1 extra for zero terminator
invoke GetWindowText,hWin,ADDR buffer1,tl
invoke lstrcmp,ADDR buffer1,ADDR Untitled
.if eax == 0 ; eax is zero means strings are equal
fn MsgboxI,hWin,"Please save file first.!","AsmPad",MB_OK,500
.else
fn GetPathOnly, ADDR buffer1, ADDR buffer1
mov tmpBuf, 0
invoke exist, cat$(ADDR tmpBuf,ADDR buffer1, ADDR TaskFile)
.if eax == 0
mov tmpBuf, 0
fn MsgboxI,hWin,cat$(ADDR tmpBuf, ADDR TaskFile, " not found in: ", ADDR buffer1),"AsmPad",MB_OK,500
.else
mov tmpBuf, 0
mov ptr$(tmpBuf), cat$(ADDR tmpBuf,ADDR buffer1,ADDR TaskFile)
fn ShellExecute,0,0,ADDR tmpBuf,0,ADDR buffer1,SW_SHOWDEFAULT;
mov ptr$(buffer1), cat$(ADDR buffer1,"Ran: ", ADDR tmpBuf)
invoke SendMessage,hStatus,SB_SETTEXT,3, ADDR buffer1
.endif
.endif
.endif
;====== end menu commands ======
.elseif uMsg == WM_NOTIFY
; ---------------------------------------------------
; The toolbar has the TBSTYLE_TOOLTIPS style enabled
; so that a WM_NOTIFY message is sent when the mouse
; is over the toolbar buttons.
; ---------------------------------------------------
mov eax, lParam
mov eax, [eax] ; get 1st member of NMHDR structure "hwndFrom"
.if eax == hToolTips
.if wParam == 50
mov lpTxt, offset tbn_new
.elseif wParam == 51
mov lpTxt, offset tbn_open
.elseif wParam == 52
mov lpTxt, offset tbn_save
.elseif wParam == 53
mov lpTxt, offset tbn_cut
.elseif wParam == 54
mov lpTxt, offset tbn_copy
.elseif wParam == 55
mov lpTxt, offset tbn_paste
.elseif wParam == 56
mov lpTxt, offset tbn_undo
.elseif wParam == 57
mov lpTxt, offset tbn_redo
.elseif wParam == 58
mov lpTxt, offset tbn_find
.elseif wParam == 59
mov lpTxt, offset tbn_run
.elseif wParam == 60
mov lpTxt, offset tbn_instance
.elseif wParam == 61
mov lpTxt, offset tbn_quit
.endif
.else
mov lpTxt, offset tbn_else
.endif
invoke SendMessage,hStatus,SB_SETTEXT,2,lpTxt
; ---------------------------------------------------
; Set the line info in the toolbar
; ---------------------------------------------------
mov eax, lParam
mov eax, [eax].NMHDR.code
.if eax == EN_SELCHANGE
mov tmpBuf, 0
invoke SendMessage, hRichEd, EM_EXLINEFROMCHAR, 0, -1
inc eax
push ebx
mov ebx, eax
mov ptr$(tmpBuf), cat$(ADDR tmpBuf, "Line: ", str$(ebx))
pop ebx
invoke SendMessage, hStatus, SB_SETTEXT, 0, ADDR tmpBuf
.endif
@@:
.elseif uMsg == WM_DROPFILES
invoke DragQueryFile,wParam,0,ADDR FileBuffer,LENGTHOF FileBuffer
invoke Confirmation,hRichEd
.if eax == IDYES
jmp FileSave
.elseif eax == IDCANCEL
return 0
.endif
invoke StreamFileIn,hRichEd,ADDR FileBuffer
invoke SendMessage,hRichEd,EM_SETMODIFY,0,0
invoke SendMessage,hWin,WM_SETTEXT,0,ADDR FileBuffer
return 0
.elseif uMsg == WM_SYSCOLORCHANGE
invoke Do_ToolBar,hWin
.elseif uMsg == WM_CREATE
invoke Do_ToolBar,hWin
invoke Do_Status,hWin
; --------------------------------
; conditional assembly directives
; --------------------------------
IFDEF riched1
szText ReDLL,"RICHED32.DLL"
ELSE
szText ReDLL,"RICHED20.DLL"
ENDIF
; --------------------------------
invoke LoadLibrary,ADDR ReDLL
invoke EditControl,hWin,0,40,250,250,800
mov hRichEd, eax
.elseif uMsg == WM_SETFOCUS
invoke SetFocus,hRichEd
.elseif uMsg == WM_SIZE
invoke SendMessage,hToolBar,TB_AUTOSIZE,0,0
invoke MoveWindow,hStatus,0,0,0,0,TRUE
; -------------------------------------
; get toolbar & statusbar heights, get
; window client area size and position
; edit window in remaining client area
; -------------------------------------
invoke GetClientRect,hToolBar,ADDR Rct
mov eax, Rct.bottom
mov hTbar, eax
invoke GetClientRect,hStatus,ADDR Rct
mov eax, Rct.bottom
mov hSbar, eax
invoke GetClientRect,hWin,ADDR Rct
mov eax, Rct.bottom
sub eax, hTbar
sub eax, hSbar
; -----------------------------
; drop edit window by 2 pixels
; to display toolbar properly
; -----------------------------
add hTbar, 2
sub eax, 2
invoke MoveWindow,hRichEd,0,hTbar,Rct.right,eax,TRUE
.elseif uMsg == WM_CLOSE
invoke Confirmation,hRichEd
.if eax == IDYES
jmp FileSave
.elseif eax == IDCANCEL
return 0
.endif
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
WndProc endp
; ########################################################################
TopXY proc wDim:DWORD, sDim:DWORD
shr sDim, 1 ; divide screen dimension by 2
shr wDim, 1 ; divide window dimension by 2
mov eax, wDim ; copy window dimension into eax
sub sDim, eax ; sub half win dimension from half screen dimension
return sDim
TopXY endp
; ########################################################################
EditControl proc hParent:DWORD, x:DWORD, y:DWORD, wd:DWORD, ht:DWORD, ID:DWORD
LOCAL hEdit:DWORD
LOCAL hFont:DWORD
LOCAL charfmt:CHARFORMAT2
; --------------------------------
; conditional assembly directives
; --------------------------------
IFDEF riched1
szText EditMl,"RICHEDIT"
ELSE
szText EditMl,"RichEdit20a"
ENDIF
; --------------------------------
invoke CreateWindowEx,WS_EX_STATICEDGE,ADDR EditMl,0,
WS_VISIBLE or \
WS_CHILDWINDOW or WS_CLIPSIBLINGS or \
ES_MULTILINE or WS_VSCROLL or \
ES_AUTOVSCROLL or ES_NOHIDESEL or \
WS_HSCROLL or ES_AUTOHSCROLL,
x,y,wd,ht,hParent,ID,hInstance,NULL
mov hEdit, eax
invoke SetWindowLong,hEdit,GWL_WNDPROC,hEditProc
mov lpfnhEditProc, eax
invoke GetStockObject,edit_font
invoke SendMessage,hEdit,WM_SETFONT,eax,0
invoke SendMessage,hEdit,EM_EXLIMITTEXT,0,100000000
invoke SendMessage,hEdit,EM_SETOPTIONS,ECOOP_XOR,ECO_SELECTIONBAR
invoke SendMessage,hEdit,EM_SETEVENTMASK, 0, ENM_SELCHANGE or ENM_CHANGE
; ----------------------------------------------------
; set the background color of rich edit
; ----------------------------------------------------
invoke SendMessage,hEdit,EM_SETBKGNDCOLOR,0,00323232h
; ----------------------------------------------------
; set the foreground color of rich edit
; ----------------------------------------------------
mov charfmt.cbSize, sizeof CHARFORMAT2
m2m charfmt.dwMask, CFM_COLOR
m2m charfmt.crTextColor, 00CCCCCCh
invoke SendMessage, hEdit, EM_SETCHARFORMAT, SCF_ALL, ADDR charfmt
mov eax, hEdit
ret
EditControl endp
; #########################################################################
hEditProc proc hCtl :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD
LOCAL Pt :POINT
LOCAL hSM :DWORD
.if uMsg == WM_KEYUP
; --------------------------
; process the F1 to F3 keys
; --------------------------
.if wParam == VK_F1
; -------------------------
; impliment help code here
; -------------------------
.elseif wParam == VK_F2
invoke CallSearchDlg
return 0
.elseif wParam == VK_F3
invoke TextFind,ADDR SearchText, TextLen
.elseif wParam == VK_F4
invoke TextFind,ADDR SearchText, TextLen
.endif
.elseif uMsg == WM_RBUTTONDOWN
invoke GetCursorPos,ADDR Pt
invoke GetSubMenu,hMnu,menu_popup
mov hSM, eax
invoke TrackPopupMenu,hSM,TPM_LEFTALIGN or TPM_LEFTBUTTON,
Pt.x,Pt.y,0, hWnd,NULL
.endif
invoke CallWindowProc,lpfnhEditProc,hCtl,uMsg,wParam,lParam
ret
hEditProc endp
; #########################################################################
end start