forked from AgileEhsan/winasm-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinAsm.asm
7265 lines (6236 loc) · 228 KB
/
WinAsm.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
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.486
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
;DEBUG_BUILD EQU 1 ;Uncomment for debug builds
DIALOGSYMARGIN EQU 8
;CHANGE IT FOR EVERY NEW VERSION !!!!!!!!!!!!!!!!!!!!!!!!!!!!
WINASMVERSION EQU 5170
;CHANGE IT FOR EVERY NEW VERSION !!!!!!!!!!!!!!!!!!!!!!!!!!!!
MENUITEMAFTERPRINT EQU 13
Include WINDOWS.INC
;------------------------------------------------------------------
WinMain PROTO :DWORD, :DWORD, :DWORD, :SDWORD
ClientResize PROTO
SendCallBackToAllAddIns PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
;------------------------------------------------------------------
GetFileName PROTO :DWORD, :DWORD
GetFilesTitle PROTO :DWORD, :DWORD
DrawRectangle PROTO :DWORD, :DWORD
GetTextRange PROTO :DWORD, :DWORD, :DWORD, :DWORD
ClearPendingMessages PROTO :HWND, :DWORD, :DWORD
GetFilePath PROTO :DWORD, :DWORD
RemoveFileExt PROTO :DWORD
GetItemParameter PROTO :HWND, :DWORD
SetItemParameter PROTO :HWND, :DWORD, :DWORD
ChangeCase PROTO :HWND, :DWORD
DeleteFiles PROTO :DWORD, :DWORD
ReplaceBackSlashWithSlash PROTO :DWORD
DrawFocusRectangle PROTO :HWND, :DWORD
IsThereSuchAClass PROTO :DWORD
SetColumnsWidth PROTO :DWORD
RemoveFileFromProject PROTO :HWND, :BOOLEAN
BinToDec PROTO :DWORD, :DWORD
;------------------------------------------------------------------
Include WinAsm.inc
Include Misc.asm
Include BrowseProc.asm
Include Find.asm
Include Make.asm
Include FileIO.asm
Include Print.asm
Include Options.asm
Include Managers.asm
Include Intellisense.asm
Include AddIns.asm
Include ODMenus.asm
Include Docking.asm
Include ProjectE.asm
Include RCEditor.asm
;------------------------------------------------------------------
.CODE
Start:
;-----
Invoke GetModuleHandle,NULL
MOV hInstance,EAX
Invoke GetCommandLine
Invoke WinMain,hInstance,NULL,EAX,SW_SHOWDEFAULT
Invoke ExitProcess,EAX
FillListWithTemplates Proc Uses EBX lpFolderName:DWORD
Local lvi:LV_ITEM
Local FindData:WIN32_FIND_DATA
Local hFindFile:DWORD
Invoke SendMessage,hNewProjectList,LVM_DELETEALLITEMS,0,0
MOV lvi.imask, LVIF_TEXT OR LVIF_IMAGE; OR LVIF_STATE
XOR EBX,EBX
MOV lvi.iSubItem, 0
Invoke lstrcpy,Offset tmpBuffer, Offset szAppFilePath
Invoke lstrcat,Offset tmpBuffer, Offset szInTemplates
Invoke lstrcat,Offset tmpBuffer, lpFolderName
Invoke lstrcat,Offset tmpBuffer, Offset szSlashAllFiles
Invoke FindFirstFile, Offset tmpBuffer, ADDR FindData
.If EAX != INVALID_HANDLE_VALUE
MOV hFindFile, EAX
.If (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
.If BYTE PTR FindData.cFileName != '.'
CALL AddTheNewTemplate
.EndIf
.EndIf
@@:
Invoke FindNextFile, hFindFile, ADDR FindData
.If EAX!=0
.If EAX!= INVALID_HANDLE_VALUE
.If (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
.If BYTE PTR FindData.cFileName != '.'
CALL AddTheNewTemplate
.EndIf
.EndIf
.EndIf
JMP @B
.EndIf
Invoke FindClose, hFindFile
.EndIf
Invoke SendMessage, hNewProjectList, LVM_ARRANGE, LVA_ALIGNTOP, 0
MOV lvi.imask,LVIF_STATE
MOV lvi.stateMask, LVIS_FOCUSED OR LVIS_SELECTED
MOV lvi.state,LVIS_FOCUSED OR LVIS_SELECTED
MOV lvi.iItem,0
MOV lvi.iSubItem, 0
Invoke SendMessage, hNewProjectList, LVM_SETITEM, 0, ADDR lvi
RET
;-----------------------------------------------------------------------
AddTheNewTemplate:
;-----------------
LEA EAX,FindData.cFileName
MOV lvi.pszText,EAX
Invoke lstrcpy,Offset tmpBuffer, Offset szAppFilePath
Invoke lstrcat,Offset tmpBuffer, Offset szInTemplates ;"Templates\"
Invoke lstrcat,Offset tmpBuffer,lpFolderName
Invoke lstrcat,Offset tmpBuffer,Offset szSlash
Invoke lstrcat,Offset tmpBuffer,ADDR FindData.cFileName
Invoke lstrcat,Offset tmpBuffer,Offset szSlash
Invoke lstrcat,Offset tmpBuffer,ADDR FindData.cFileName
Invoke lstrcat,Offset tmpBuffer,Offset szExtwap
;[Get Project Type]
Invoke GetPrivateProfileInt, Offset szPROJECT, ADDR szType, -1,Offset tmpBuffer
.If EAX!=-1 ;i.e either a wap (with the same name as its folder) is not found or Project Type is not specified in this file(rare)
MOV lvi.iImage, EAX
MOV lvi.iItem,EBX
Invoke SendMessage,hNewProjectList,LVM_INSERTITEM,0,ADDR lvi
INC EBX
.EndIf
RETN
FillListWithTemplates EndP
FillListWithEmptyProjects Proc
Local lvi:LV_ITEM
Invoke SendMessage,hNewProjectList,LVM_DELETEALLITEMS,0,0
MOV lvi.imask, LVIF_TEXT OR LVIF_IMAGE OR LVIF_STATE
MOV lvi.state,LVIS_FOCUSED OR LVIS_SELECTED
MOV lvi.iItem,0
MOV lvi.iSubItem, 0
MOV lvi.pszText,Offset szStandardEXE
MOV lvi.iImage, 0
CALL InsertIt
MOV lvi.imask, LVIF_TEXT OR LVIF_IMAGE
MOV lvi.iItem,1
MOV lvi.pszText, Offset szStandardDLL
MOV lvi.iImage, 1
CALL InsertIt
MOV lvi.iItem,2
MOV lvi.pszText, Offset szConsoleApplication
MOV lvi.iImage, 2
CALL InsertIt
MOV lvi.iItem,3
MOV lvi.pszText, Offset szStaticLibrary
MOV lvi.iImage,3
CALL InsertIt
MOV lvi.iItem,4
MOV lvi.pszText, Offset szOtherExe
MOV lvi.iImage,4
CALL InsertIt
MOV lvi.iItem,5
MOV lvi.pszText, Offset szOtherNotExe
MOV lvi.iImage,5
CALL InsertIt
MOV lvi.iItem,6
MOV lvi.pszText,Offset szDOSProject
MOV lvi.iImage,6
CALL InsertIt
Invoke SendMessage, hNewProjectList, LVM_ARRANGE, LVA_ALIGNTOP, 0
RET
;------------------------------------------------------------------------
InsertIt:
Invoke SendMessage,hNewProjectList,LVM_INSERTITEM,0,ADDR lvi
RETN
FillListWithEmptyProjects EndP
ProjectPropertiesDlgProc_InitDialog Proc hWnd :DWORD, IsNewProjectDialog:DWORD
Local FindData :WIN32_FIND_DATA
Local hFindFile :DWORD
MOV TabCtrlItem.imask,TCIF_TEXT
;Get handles
Invoke GetDlgItem,hWnd,IDC_NEWPROJECTLIST
MOV hNewProjectList,EAX
Invoke GetDlgItem,hWnd,IDC_TABCONTROL
MOV hTabControl,EAX
Invoke GetDlgItem,hWnd,IDC_LABELRC
MOV hLabelRC, EAX
Invoke GetDlgItem,hWnd,IDC_TEXTRC
MOV hTextRC,EAX
Invoke GetDlgItem,hWnd,IDC_TEXTCVTRES
MOV hTextCVTRES, EAX
Invoke GetDlgItem,hWnd,IDC_LABELCVTRES
MOV hLabelCVTRES, EAX
Invoke GetDlgItem,hWnd,IDC_TEXTML
MOV hReleaseTextML, EAX
Invoke GetDlgItem,hWnd,IDC_TEXTLINK
MOV hReleaseTextLINK, EAX
Invoke GetDlgItem,hWnd,IDC_TEXTOUT
MOV hReleaseTextOUT, EAX
Invoke GetDlgItem,hWnd,IDC_LABELML
MOV hLabelML, EAX
Invoke GetDlgItem,hWnd,IDC_LABELLINK
MOV hLabelLINK, EAX
Invoke GetDlgItem,hWnd,IDC_LABELOUT
MOV hLabelOUT, EAX
Invoke GetDlgItem,hWnd,23
MOV hDebugTextML, EAX
Invoke GetDlgItem,hWnd,25
MOV hDebugTextLINK, EAX
Invoke GetDlgItem,hWnd,27
MOV hDebugTextOUT, EAX
Invoke GetDlgItem,hWnd,28
MOV hDividerLine, EAX
Invoke GetDlgItem,hWnd,29
MOV hReleaseTextCommandLine, EAX
Invoke GetDlgItem,hWnd,30
MOV hLabelCommandLine, EAX
Invoke GetDlgItem,hWnd,31
MOV hDebugTextCommandLine, EAX
Invoke GetDlgItem,hWnd,32
MOV hChkSilently, EAX
Invoke GetDlgItem,hWnd,33
MOV hPellesTools, EAX
.If !IsNewProjectDialog
MOV TabCtrlItem.pszText, Offset szDebugMakeOptions
Invoke SendMessage,hTabControl,TCM_INSERTITEM,0,Offset TabCtrlItem
MOV TabCtrlItem.pszText, Offset szReleaseMakeOptions
Invoke SendMessage,hTabControl,TCM_INSERTITEM,0,Offset TabCtrlItem
MOV TabCtrlItem.pszText, Offset szResourceMakeOptions
Invoke SendMessage,hTabControl,TCM_INSERTITEM,0,Offset TabCtrlItem
MOV TabCtrlItem.pszText, Offset szProjectType
.Else
Invoke lstrcpy,Offset tmpBuffer, Offset szAppFilePath
Invoke lstrcat,Offset tmpBuffer, Offset szInTemplatesAllFiles ;"Templates\*.*"
Invoke FindFirstFile,Offset tmpBuffer, ADDR FindData
.If EAX != INVALID_HANDLE_VALUE
MOV hFindFile, EAX
.If (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
.If BYTE PTR FindData.cFileName != '.'
LEA EAX,FindData.cFileName
MOV TabCtrlItem.pszText,EAX
Invoke SendMessage,hTabControl,TCM_INSERTITEM,0,Offset TabCtrlItem
.EndIf
.EndIf
@@:
Invoke FindNextFile, hFindFile, ADDR FindData
.If EAX!=0
.If EAX!= INVALID_HANDLE_VALUE
.If (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
.If BYTE PTR FindData.cFileName != '.'
LEA EAX,FindData.cFileName
MOV TabCtrlItem.pszText,EAX
Invoke SendMessage,hTabControl,TCM_INSERTITEM,0,Offset TabCtrlItem
.EndIf
.EndIf
.EndIf
JMP @B
.EndIf
Invoke FindClose, hFindFile
.EndIf
MOV TabCtrlItem.pszText, Offset szEmptyProject
.EndIf
Invoke SendMessage,hTabControl,TCM_INSERTITEM,0,Offset TabCtrlItem
Invoke SendMessage,hTabControl,TCM_SETCURSEL,0,NULL
;32: Width of each image
;0: Number of images by which the image list can grow.
;CLR_DEFAULT:The color of the pixel at the upper-left corner of the image is treated as the mask color.
;Invoke ImageList_LoadImage, hInstance, IDB_NEWPROJECTLIST, 32, 0,CLR_DEFAULT,IMAGE_BITMAP, LR_LOADTRANSPARENT
Invoke ImageList_LoadImage, hInstance, IDB_NEWPROJECTLIST, 32, 0,0FFFFFFh,IMAGE_BITMAP,LR_CREATEDIBSECTION
MOV hNewProjectImageList, EAX
Invoke SendMessage,hNewProjectList,LVM_SETIMAGELIST,LVSIL_NORMAL, hNewProjectImageList
Invoke FillListWithEmptyProjects
RET
ProjectPropertiesDlgProc_InitDialog EndP
ShowPropertiesFirstTab Proc fShow:DWORD
Invoke ShowWindow,hNewProjectList,fShow
RET
ShowPropertiesFirstTab EndP
ShowPropertiesSecondTab Proc fShow:DWORD
Invoke ShowWindow,hLabelRC,fShow
Invoke ShowWindow,hTextRC,fShow
Invoke ShowWindow,hLabelCVTRES,fShow
Invoke ShowWindow,hTextCVTRES,fShow
Invoke ShowWindow,hChkSilently,fShow
RET
ShowPropertiesSecondTab EndP
ShowPropertiesThirdTab Proc fShow:DWORD
Invoke ShowWindow,hReleaseTextML,fShow
Invoke ShowWindow,hReleaseTextLINK,fShow
Invoke ShowWindow,hReleaseTextOUT,fShow
Invoke ShowWindow,hLabelML,fShow
Invoke ShowWindow,hLabelLINK,fShow
Invoke ShowWindow,hLabelOUT,fShow
Invoke ShowWindow,hDividerLine,fShow
Invoke ShowWindow,hLabelCommandLine,fShow
Invoke ShowWindow,hReleaseTextCommandLine,fShow
Invoke ShowWindow,hPellesTools,fShow
RET
ShowPropertiesThirdTab EndP
ShowPropertiesFourthTab Proc fShow:DWORD
Invoke ShowWindow,hDebugTextML,fShow
Invoke ShowWindow,hDebugTextLINK,fShow
Invoke ShowWindow,hDebugTextOUT,fShow
Invoke ShowWindow,hLabelML,fShow
Invoke ShowWindow,hLabelLINK,fShow
Invoke ShowWindow,hLabelOUT,fShow
Invoke ShowWindow,hDividerLine,fShow
Invoke ShowWindow,hLabelCommandLine,fShow
Invoke ShowWindow,hDebugTextCommandLine,fShow
Invoke ShowWindow,hPellesTools,fShow
RET
ShowPropertiesFourthTab EndP
DoNewProject Proc Uses EBX AddOneEmptyASMFile:DWORD
Local Buffer[MAX_PATH]:BYTE
Invoke lstrcpy,Offset ProjectTitle,Offset szNewProjectTitle
Invoke lstrcpy,Offset FullProjectName,Offset szNewProjectFile
Invoke SetMainWindowCaption
.If AddOneEmptyASMFile
Invoke lstrcpy,Offset FileName,ADDR szNewFile;szNewASMFile
INC UntitledAsmCounter
Invoke BinToDec,UntitledAsmCounter,ADDR Buffer
Invoke lstrcat,Offset FileName,ADDR Buffer
Invoke lstrcat,Offset FileName,Offset szExtAsm
MOV ECX,MDIS_ALLCHILDSTYLES or WS_CLIPCHILDREN
OR ECX,OpenChildStyle
Invoke CreateWindowEx,WS_EX_MDICHILD ,ADDR szChildClass,ADDR FileName,ECX,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hClient,NULL,hInstance,1
;------This is needed so that combo gets one item "Select Procedure or go to Top"
Invoke GetWindowLong,EAX,0
MOV EBX,EAX
Invoke UpdateProcCombo,CHILDWINDOWDATA.hEditor[EAX],CHILDWINDOWDATA.hCombo[EBX]
MOV [EBX].CHILDWINDOWDATA.fNotOnDisk,1
Invoke SendMessage,[EBX].CHILDWINDOWDATA.hEditor,EM_SETMODIFY,TRUE,0
Invoke SetProjectRelatedItems
.EndIf
;-----------------------------------------------------------------------
Invoke SendCallBackToAllAddIns,pAddInsFrameProcedures,WinAsmHandles.hMain,WAM_DIFFERENTCURRENTPROJECT,0,0
MOV ProjectModified, TRUE
RET
DoNewProject EndP
ProjectPropertiesDlgProc_EndDialog Proc hDlg:DWORD
Local Buffer[32]:BYTE
Local LargeBuffer[MAX_PATH]:BYTE
Invoke GetWindowText, hDlg, ADDR Buffer, 32
Invoke lstrcmpi, ADDR Buffer, Offset szNewProjectDialogTitle
.If EAX!=0 ;i.e This is NOT a New Project Dialog
Invoke SendMessage, hNewProjectList, LVM_GETNEXTITEM, -1, LVIS_SELECTED;LVNI_FOCUSED; +
.If EAX!=ProjectType ;i.e user selected other type of project
MOV ProjectType,EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hTextRC
CALL GetModify
.If EAX ;i.e If User changed CompileRC arguments
MOV ProjectModified,TRUE
.Else
MOV ECX,hReleaseTextML
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hReleaseTextLINK
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hTextCVTRES
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hReleaseTextOUT
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hReleaseTextCommandLine
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hDebugTextML
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hDebugTextLINK
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hDebugTextOUT
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.Else
MOV ECX,hDebugTextCommandLine
CALL GetModify
.If EAX
MOV ProjectModified,TRUE
.EndIf
.EndIf
.EndIf
.EndIf
.EndIf
.EndIf
.EndIf
.EndIf
.EndIf
.EndIf
.EndIf
Invoke IsDlgButtonChecked,hDlg,32
.If EAX!=bRCSilent
MOV ProjectModified,TRUE
.EndIf
MOV bRCSilent,EAX
Invoke IsDlgButtonChecked,hDlg,33
.If EAX!=bPellesTools
MOV ProjectModified,TRUE
.EndIf
MOV bPellesTools,EAX
CALL GetMakeOptions
Invoke SetProjectRelatedItems
.Else ;New Project Dialog
Invoke SendMessage,hTabControl,TCM_GETCURSEL,0,0
.If EAX==0 ;i.e. User selected one Empty Project (non template)
Invoke ClearProject
Invoke SendMessage, hNewProjectList, LVM_GETNEXTITEM, -1,LVIS_SELECTED; LVNI_FOCUSED; +
MOV ProjectType,EAX
CALL GetMakeOptions
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; by shoorick
;-----------------------------------------------------------------------
invoke lstrcpy,Offset szProc,Offset dszProc
invoke lstrcpy,Offset szEndp,Offset dszEndp
invoke lstrcpy,Offset szMacro,Offset dszMacro
invoke lstrcpy,Offset szEndm,Offset dszEndm
invoke lstrcpy,Offset szStruct,Offset dszStruct
invoke lstrcpy,Offset szEnds,Offset dszEnds
;-----------------------------------------------------------------------
mov pIncludePath, offset IncludePath
mov pKeyWordsFileName, offset KeyWordsFileName
mov pAPIFunctionsFile, offset APIFunctionsFile
mov pAPIStructuresFile, offset APIStructuresFile
mov pAPIConstantsFile, offset APIConstantsFile
;-----------------------------------------------------------------------
Invoke GetKeyWords
Invoke GetAPIFunctions
Invoke GetAPIStructures
Invoke GetAPIConstants
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Invoke DoNewProject,TRUE
.Else
MOV TabCtrlItem.imask,TCIF_TEXT
LEA ECX,LargeBuffer
MOV TabCtrlItem.pszText,ECX
MOV TabCtrlItem.cchTextMax,SizeOf LargeBuffer-1
Invoke SendMessage,hTabControl,TCM_GETITEM,EAX,ADDR TabCtrlItem
Invoke RtlZeroMemory,Offset tmpBuffer2,SizeOf tmpBuffer2-1 ;so that we have a second zero after the folder end when we copy it
Invoke RtlZeroMemory,Offset tmpBuffer,SizeOf tmpBuffer-1 ;so that we have a second zero after the folder end when we copy it
Invoke lstrcpy,Offset tmpBuffer2, Offset szAppFilePath
Invoke lstrcat,Offset tmpBuffer2, Offset szInTemplates ;"Templates\"
Invoke lstrcat,Offset tmpBuffer2, ADDR LargeBuffer
Invoke lstrcat,Offset tmpBuffer2, Offset szSlash
Invoke SendMessage, hNewProjectList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED; + LVIS_SELECTED;
MOV ECX,EAX
Invoke GetItemText, hNewProjectList,ECX,0,ADDR LargeBuffer
Invoke lstrcat,Offset tmpBuffer2, ADDR LargeBuffer
Invoke BrowseForAnyFolder,hDlg,0,Offset tmpBuffer
.If EAX ;i.e. user did not select cancel
Invoke SendMessage,hStatus,SB_SETTEXT,4,Offset szCreatingProject
Invoke lstrcat,Offset tmpBuffer2,Offset szSlashAllFiles
Invoke CopyAllFromTo,Offset tmpBuffer2,Offset tmpBuffer
.If EAX==0 ;If the same folder found and user pressed OK or Cancel then EAX<>0
Invoke lstrlen,Offset tmpBuffer
.If EAX!=3 ;it is 3 if tmpBuffer=C:\, or D:\ etc. In such a case I will not add another slash
Invoke lstrcat,Offset tmpBuffer, Offset szSlash
.EndIf
Invoke lstrcat,Offset tmpBuffer, ADDR LargeBuffer
Invoke lstrcat,Offset tmpBuffer, Offset szExtwap
Invoke OpenWAP,Offset tmpBuffer
.EndIf
Invoke SendMessage,hStatus,SB_SETTEXT,4,Offset szNULL
.EndIf
.EndIf
.EndIf
RET
;------------------------------------------------------------------------
GetMakeOptions:
MOV ECX,hTextRC
LEA EDX,CompileRC
CALL GetText
MOV ECX,hReleaseTextML
LEA EDX,szReleaseAssemble
CALL GetText
MOV ECX,hReleaseTextLINK
LEA EDX,szReleaseLink
CALL GetText
MOV ECX,hDebugTextML
LEA EDX,szDebugAssemble
CALL GetText
MOV ECX,hDebugTextLINK
LEA EDX,szDebugLink
CALL GetText
;Trim any leading spaces
MOV ECX,hTextCVTRES
LEA EDX,LineTxt
CALL GetText
Invoke LTrim,Offset LineTxt,Offset RCToObj
;Get ReleaseOutCommand and trim any leading spaces
MOV ECX,hReleaseTextOUT
LEA EDX,LineTxt
CALL GetText
Invoke LTrim,Offset LineTxt,Offset szReleaseOutCommand
;Get DebugOutCommand and trim any leading spaces
MOV ECX,hDebugTextOUT
LEA EDX,LineTxt
CALL GetText
Invoke LTrim,Offset LineTxt,Offset szDebugOutCommand
MOV ECX,hReleaseTextCommandLine
LEA EDX,szReleaseCommandLine
CALL GetText
MOV ECX,hDebugTextCommandLine
LEA EDX,szDebugCommandLine
CALL GetText
RETN
;------------------------------------------------------------------------
GetModify:
Invoke SendMessage,ECX,EM_GETMODIFY,0,0
RETN
;------------------------------------------------------------------------
GetText:
Invoke SendMessage,ECX,WM_GETTEXT,256,EDX
RETN
;------------------------------------------------------------------------
ProjectPropertiesDlgProc_EndDialog EndP
;This Dialog Procedure is for both new projects as well as changing the properties of existing ones.
ProjectPropertiesDlgProc Proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
Local Buffer[32]:BYTE
.If uMsg == WM_INITDIALOG
;Build the Tab Control with all three tabs
.If lParam ;If the dialog is for a new project
Invoke ProjectPropertiesDlgProc_InitDialog, hWnd, TRUE
Invoke SetWindowText,hWnd, Offset szNewProjectDialogTitle
LEA EDX,szCompileRCNew
MOV ECX,hTextRC
CALL SetText
LEA EDX,szReleaseAssembleNew
MOV ECX,hReleaseTextML
CALL SetText
LEA EDX,szReleaseLinkNew
MOV ECX,hReleaseTextLINK
CALL SetText
;------------------------
LEA EDX,szDebugAssembleNew
MOV ECX,hDebugTextML
CALL SetText
LEA EDX,szDebugLinkNew
MOV ECX,hDebugTextLINK
CALL SetText
.Else ;If the dialog is for Project Properties
Invoke ProjectPropertiesDlgProc_InitDialog, hWnd,FALSE
MOV ECX,hTextRC
LEA EDX,CompileRC
CALL SetText
MOV ECX,hTextCVTRES
LEA EDX,RCToObj
CALL SetText
MOV ECX,hReleaseTextML
LEA EDX,szReleaseAssemble
CALL SetText
MOV ECX,hReleaseTextLINK
LEA EDX,szReleaseLink
CALL SetText
MOV ECX,hReleaseTextOUT
LEA EDX,szReleaseOutCommand
CALL SetText
MOV ECX,hReleaseTextCommandLine
LEA EDX,szReleaseCommandLine
CALL SetText
;---------------------
MOV ECX,hDebugTextML
LEA EDX,szDebugAssemble
CALL SetText
MOV ECX,hDebugTextLINK
LEA EDX,szDebugLink
CALL SetText
MOV ECX,hDebugTextOUT
LEA EDX,szDebugOutCommand
CALL SetText
MOV ECX,hDebugTextCommandLine
LEA EDX,szDebugCommandLine
CALL SetText
Invoke SelectListItem, hNewProjectList,ProjectType;,0
.If bRCSilent
Invoke CheckDlgButton,hWnd,32,BST_CHECKED
.EndIf
.If bPellesTools
Invoke CheckDlgButton,hWnd,33,BST_CHECKED
.EndIf
.EndIf
.ElseIf uMsg == WM_COMMAND
MOV EAX,wParam
SHR EAX,16
.If AX==BN_CLICKED
MOV EAX,wParam
.If AX == 1 ;OK
Invoke EndDialog, hWnd, TRUE
Invoke ProjectPropertiesDlgProc_EndDialog,hWnd
Invoke ImageList_Destroy,hNewProjectImageList
.ElseIf AX==2 ;Cancel
Invoke ImageList_Destroy,hNewProjectImageList
Invoke EndDialog, hWnd, FALSE
.EndIf
.EndIf
.ElseIf uMsg == WM_NOTIFY
PUSH EDI
MOV EDI, lParam
MOV EAX, [EDI].NMHDR.hwndFrom
.If EAX==hNewProjectList
.If [EDI].NMHDR.code == NM_DBLCLK
Invoke EndDialog, hWnd, TRUE
Invoke ProjectPropertiesDlgProc_EndDialog,hWnd
Invoke ImageList_Destroy,hNewProjectImageList
.ElseIf [EDI].NMHDR.code == LVN_ITEMCHANGED
.If [EDI].NM_LISTVIEW.uNewState==3 ;i.e focus and selected
Invoke GetWindowText, hWnd, ADDR Buffer, 32
Invoke lstrcmpi, ADDR Buffer, Offset szNewProjectDialogTitle
.If EAX==0 ;i.e This is a New Project Dialog
LEA EDX,szCompileRCNew
MOV ECX,hTextRC
CALL SetText
LEA EDX,szReleaseAssembleNew
MOV ECX,hReleaseTextML
CALL SetText
LEA EDX,szDebugAssembleNew
MOV ECX,hDebugTextML
CALL SetText
MOV EAX, [EDI].NM_LISTVIEW.iItem
.If EAX==2 ;Console
LEA EDX,szReleaseLinkNewConsole
MOV ECX,hReleaseTextLINK
CALL SetText
LEA EDX,szDebugLinkNewConsole
MOV ECX,hDebugTextLINK
CALL SetText
.ElseIf EAX==3 ;Library
;LEA EDX,szReleaseLinkNewLibrary
MOV EDX,Offset szNULL
MOV ECX,hReleaseTextLINK
CALL SetText
;LEA EDX,szDebugLinkNewLibrary
MOV EDX,Offset szNULL
MOV ECX,hDebugTextLINK
CALL SetText
.ElseIf EAX!=6
LEA EDX,szReleaseLinkNew
MOV ECX,hReleaseTextLINK
CALL SetText
LEA EDX,szDebugLinkNew
MOV ECX,hDebugTextLINK
CALL SetText
.Else ;i.e. DOS Projects
MOV EDX,Offset szNULL
MOV ECX,hTextRC
CALL SetText
MOV EDX,Offset szReleaseAssembleNewDOS
MOV ECX,hReleaseTextML
CALL SetText
MOV EDX,Offset szNULL
MOV ECX,hReleaseTextLINK
CALL SetText
MOV EDX,Offset szDebugAssembleNewDOS
MOV ECX,hDebugTextML
CALL SetText
MOV EDX,Offset szNULL
MOV ECX,hDebugTextLINK
CALL SetText
.EndIf
.Else ;Existing Project
Invoke EnableWindow,hReleaseTextCommandLine,TRUE
Invoke EnableWindow,hDebugTextCommandLine,TRUE
MOV EAX, [EDI].NM_LISTVIEW.iItem
.If EAX==6 ;existing
Invoke EnableWindow,hTextRC,FALSE
Invoke EnableWindow,hTextCVTRES,FALSE
.Else
.If EAX==1 || EAX==3 || EAX==5
Invoke EnableWindow,hReleaseTextCommandLine,FALSE
Invoke EnableWindow,hDebugTextCommandLine,FALSE
.EndIf
Invoke EnableWindow,hTextRC,TRUE
Invoke EnableWindow,hTextCVTRES,TRUE
.EndIf
.EndIf
.EndIf
.EndIf
.ElseIf EAX==hTabControl
.If [EDI].NMHDR.code==TCN_SELCHANGE
Invoke GetWindowText, hWnd, ADDR Buffer, 32
Invoke lstrcmpi, ADDR Buffer, Offset szNewProjectDialogTitle
.If EAX ;i.e This is NOT a New Project Dialog
Invoke SendMessage,hTabControl,TCM_GETCURSEL,0,0
.If EAX==0
Invoke ShowPropertiesFourthTab,SW_HIDE
Invoke ShowPropertiesThirdTab,SW_HIDE
Invoke ShowPropertiesSecondTab,SW_HIDE
Invoke ShowPropertiesFirstTab,SW_SHOW
.ElseIf EAX==1
Invoke ShowPropertiesFourthTab,SW_HIDE
Invoke ShowPropertiesThirdTab,SW_HIDE
Invoke ShowPropertiesFirstTab,SW_HIDE
Invoke ShowPropertiesSecondTab,SW_SHOW
.ElseIf EAX==2
Invoke ShowPropertiesFourthTab,SW_HIDE
Invoke ShowPropertiesFirstTab,SW_HIDE
Invoke ShowPropertiesSecondTab,SW_HIDE
Invoke ShowPropertiesThirdTab,SW_SHOW
.ElseIf EAX==3
Invoke ShowPropertiesThirdTab,SW_HIDE
Invoke ShowPropertiesFirstTab,SW_HIDE
Invoke ShowPropertiesSecondTab,SW_HIDE
Invoke ShowPropertiesFourthTab,SW_SHOW
.EndIf
.Else ;New Project Dialog
Invoke SendMessage,hTabControl,TCM_GETCURSEL,0,0
.If EAX==0
Invoke FillListWithEmptyProjects
.Else
MOV TabCtrlItem.imask,TCIF_TEXT
LEA EAX,tmpBuffer2
MOV TabCtrlItem.pszText,EAX
MOV TabCtrlItem.cchTextMax,SizeOf tmpBuffer2-1
Invoke SendMessage,hTabControl,TCM_GETCURSEL,0,0
Invoke SendMessage,hTabControl,TCM_GETITEM,EAX,ADDR TabCtrlItem
Invoke FillListWithTemplates,Offset tmpBuffer2
.EndIf
.EndIf
.EndIf
.EndIf
POP EDI
.ElseIf uMsg == WM_CTLCOLORSTATIC
Invoke SetBkMode, wParam, TRANSPARENT
;Invoke GetSysColorBrush,COLOR_WINDOW
MOV EAX, COLOR_WINDOW
RET
.ElseIf uMsg==WM_ACTIVATEAPP ;Thanks jnrz(List is not refreshed otherwise-->VERY Strange
Invoke UpdateWindow,hWnd
.Else
MOV EAX,FALSE
RET
.EndIf
MOV EAX,TRUE
RET
;----------------------------------------
SetText:
Invoke SendMessage,ECX,WM_SETTEXT,NULL,EDX
RETN
ProjectPropertiesDlgProc EndP
RepaintAllFont Proc Uses EBX, hChild:DWORD
Invoke GetWindowLong,hChild,0
MOV EBX,EAX
Invoke SendMessage,CHILDWINDOWDATA.hEditor[EBX],CHM_SETCOLOR,0,ADDR col
;This sets fonts and other things that are not needed here
Invoke SetFormat, CHILDWINDOWDATA.hEditor[EBX]
Invoke SendMessage,CHILDWINDOWDATA.hEditor[EBX],CHM_REPAINT,0,0
;Invoke SendMessage,CHILDWINDOWDATA.hCombo[EBX],WM_SETFONT,hFontTahoma,TRUE
RET
RepaintAllFont EndP
SelectLineNrFont Proc
Local cf:CHOOSEFONT
Local Buffer[12]:BYTE
Invoke RtlZeroMemory,ADDR cf,SizeOf cf
MOV cf.lStructSize,SizeOf cf
MOV EAX, WinAsmHandles.hMain
MOV cf.hwndOwner,EAX
MOV cf.lpLogFont,Offset lfntlnr
MOV cf.Flags,CF_ENABLEHOOK OR CF_SCREENFONTS OR CF_INITTOLOGFONTSTRUCT or CF_EFFECTS
MOV EAX,col.lnrcol
MOV cf.rgbColors, EAX
MOV cf.lpfnHook, Offset ChooseFontHook
Invoke ChooseFont,ADDR cf
.If EAX
Invoke DeleteObject,hLnrFont
Invoke CreateFontIndirect,Offset lfntlnr
MOV hLnrFont,EAX
MOV EAX,cf.rgbColors
MOV col.lnrcol,EAX
.If AutoLineNrWidth
Invoke CalculateLineNrWidth
MOV LineNrWidth,EAX
.EndIf
Invoke LockWindowUpdate,WinAsmHandles.hMain
Invoke EnumProjectItems,Offset RepaintAllFont
Invoke EnumOpenedExternalFiles,Offset RepaintAllFont
Invoke LockWindowUpdate,0
;Save Font Name in Ini File
Invoke WritePrivateProfileString, Offset szEDITOR, Offset szLineNrFontName,ADDR lfntlnr.lfFaceName,ADDR IniFileName
;Set LineNr Text Color in Ini file
Invoke wsprintf, ADDR Buffer, Offset szColorTemplate, col.lnrcol
Invoke WritePrivateProfileString, Offset szEDITOR, Offset szLineNrColor, ADDR Buffer, ADDR IniFileName
;Save Font Size
MOV EAX, lfntlnr.lfHeight
NEG EAX
LEA ECX,Buffer
Invoke BinToDec,EAX,ECX
Invoke WritePrivateProfileString, Offset szEDITOR, Offset szLineNrFontSize, ADDR Buffer, ADDR IniFileName
; Save Font style
MOV EAX, lfntlnr.lfWeight
AND EAX,03FFh
MOVZX ECX,lfntlnr.lfItalic
AND ECX,1
SHL ECX,10
OR EAX,ECX
MOVZX ECX,lfntlnr.lfStrikeOut
AND ECX,1
SHL ECX,11
OR EAX,ECX
MOVZX ECX,lfntlnr.lfUnderline
AND ECX,1
SHL ECX,12
OR EAX,ECX
Invoke wsprintf, ADDR Buffer, Offset szColorTemplate, EAX
Invoke WritePrivateProfileString, Offset szEDITOR, Offset szLineNrFontStyle, ADDR Buffer, ADDR IniFileName
.EndIf
RET
SelectLineNrFont EndP
SelectEditorFont Proc
Local cf:CHOOSEFONT
Local Buffer[12]:BYTE
Invoke RtlZeroMemory,ADDR cf,SizeOf cf
MOV cf.lStructSize,SizeOf cf
MOV EAX, WinAsmHandles.hMain
MOV cf.hwndOwner,EAX
MOV cf.lpLogFont,Offset lfnt
MOV cf.Flags,CF_ENABLEHOOK OR CF_SCREENFONTS or CF_EFFECTS or CF_INITTOLOGFONTSTRUCT
MOV EAX,col.txtcol
MOV cf.rgbColors,EAX
MOV cf.lpfnHook, Offset ChooseFontHook
Invoke ChooseFont,ADDR cf
.If EAX
Invoke DeleteObject,hFont
MOV AL,lfnt.lfItalic
PUSH EAX
Invoke CreateFontIndirect,Offset lfnt
MOV hFont,EAX
Invoke DeleteObject,hIFont
MOV lfnt.lfItalic,FALSE ;TRUE
Invoke CreateFontIndirect,Offset lfnt
MOV hIFont,EAX
POP EAX
MOV lfnt.lfItalic, AL
MOV EAX,cf.rgbColors
MOV col.txtcol,EAX
;Save Font Name in Ini File
Invoke WritePrivateProfileString, Offset szEDITOR, Offset szEditorFontName, ADDR lfnt.lfFaceName, ADDR IniFileName
;Set Editor Text Color in Ini file
Invoke wsprintf, ADDR Buffer, Offset szColorTemplate, col.txtcol
Invoke WritePrivateProfileString, Offset szEDITOR, Offset szTextColor, ADDR Buffer, ADDR IniFileName
;Save Font Size
MOV EAX, lfnt.lfHeight
NEG EAX
LEA ECX,Buffer
Invoke BinToDec,EAX,ECX
Invoke WritePrivateProfileString, Offset szEDITOR, Offset szEditorFontSize, ADDR Buffer, ADDR IniFileName
; Save Font style
MOV EAX, lfnt.lfWeight
AND EAX,03FFh
MOVZX ECX,lfnt.lfItalic
AND ECX,1
SHL ECX,10
OR EAX,ECX
MOVZX ECX,lfnt.lfStrikeOut
AND ECX,1