Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7039 | 0CodErr | 1 | Comment *--------------------+ |
2 | | | |
||
3 | | Run with OpenDialog | |
||
4 | | UASM + KolibriOS.lib | |
||
5 | | | |
||
6 | +----------------------------* |
||
7 | .586 |
||
8 | .Model Flat, StdCall |
||
9 | Option CaseMap: None |
||
10 | |||
11 | Public @Main |
||
12 | |||
13 | FALSE = 0 |
||
14 | TRUE = Not FALSE |
||
15 | |||
16 | CStr Macro QuotedText:VarArg |
||
17 | Local LocalText |
||
18 | .Const |
||
19 | LocalText db QuotedText,0 |
||
20 | .Code |
||
21 | ExitM |
||
22 | EndM |
||
23 | |||
24 | IfDef LANG_IT |
||
25 | szProgramRunSuccessfully equ |
||
26 | szFileNotFound equ |
||
27 | szFileIsNotExecutable equ |
||
28 | szTooManyProcesses equ |
||
29 | szAccessDenied equ |
||
30 | szOutOfMemory equ |
||
31 | szUnknownError equ |
||
32 | szTypeNameOfProgram equ |
||
33 | szRun equ |
||
34 | szTitle equ |
||
35 | szPressF1 equ |
||
36 | szHelpInfo equ |
||
37 | "Ctrl + Insert - aggiungi percorso alla posizione corrente del cursore\n",\ |
||
38 | "Ctrl + Shift + Insert - aggiungi sempre un percorso senza virgolette")> |
||
39 | ElseIfDef LANG_SP |
||
40 | szProgramRunSuccessfully equ |
||
41 | szFileNotFound equ |
||
42 | szFileIsNotExecutable equ |
||
43 | szTooManyProcesses equ |
||
44 | szAccessDenied equ |
||
45 | szOutOfMemory equ |
||
46 | szUnknownError equ |
||
47 | szTypeNameOfProgram equ |
||
48 | szRun equ |
||
49 | szTitle equ |
||
50 | szPressF1 equ |
||
51 | szHelpInfo equ |
||
52 | "Ctrl + Insert - agregar ruta a la posicion actual del cursor\n",\ |
||
53 | "Ctrl + Shift + Insert - siempre agregar la ruta sin las comillas")> |
||
54 | ElseIfDef LANG_RU |
||
55 | szProgramRunSuccessfully equ |
||
56 | szFileNotFound equ |
||
57 | szFileIsNotExecutable equ |
||
58 | szTooManyProcesses equ |
||
59 | szAccessDenied equ |
||
60 | szOutOfMemory equ |
||
61 | szUnknownError equ |
||
62 | szTypeNameOfProgram equ |
||
63 | szRun equ |
||
64 | szTitle equ |
||
65 | szPressF1 equ |
||
66 | szHelpInfo equ |
||
67 | "Ctrl + Insert - добавить путь из диалога открытия в поле ввода в текущую позицию курсора\n",\ |
||
68 | "Ctrl + Shift + Insert - всегда добавлять путь без кавычек")> |
||
69 | ElseIfDef LANG_EN |
||
70 | szProgramRunSuccessfully equ |
||
71 | szFileNotFound equ |
||
72 | szFileIsNotExecutable equ |
||
73 | szTooManyProcesses equ |
||
74 | szAccessDenied equ |
||
75 | szOutOfMemory equ |
||
76 | szUnknownError equ |
||
77 | szTypeNameOfProgram equ |
||
78 | szRun equ |
||
79 | szTitle equ |
||
80 | szPressF1 equ |
||
81 | szHelpInfo equ |
||
82 | "Ctrl + Insert - add path from open dialog into edit box at the current cursor position\n",\ |
||
83 | "Ctrl + Shift + Insert - always add path without quotes")> |
||
84 | Else |
||
85 | .Err LANG_?? |
||
86 | EndIf |
||
87 | |||
88 | ; Events |
||
89 | REDRAW_EVENT = 1 |
||
90 | KEY_EVENT = 2 |
||
91 | BUTTON_EVENT = 3 |
||
92 | BACKGROUND_EVENT = 5 |
||
93 | MOUSE_EVENT = 6 |
||
94 | IPC_EVENT = 7 |
||
95 | NETWORK_EVENT = 8 |
||
96 | DEBUG_EVENT = 9 |
||
97 | |||
98 | ; Window Style Constants |
||
99 | WS_SKINNED_FIXED = 4000000H |
||
100 | WS_COORD_CLIENT = 20000000H |
||
101 | WS_CAPTION = 10000000H |
||
102 | |||
103 | ; Caption Style Constants |
||
104 | CS_MOVABLE = 0 |
||
105 | |||
106 | ; Event Mask Constants |
||
107 | EM_REDRAW = 001H |
||
108 | EM_KEY = 002H |
||
109 | EM_BUTTON = 004H |
||
110 | EM_BACKGROUND = 010H |
||
111 | EM_MOUSE = 020H |
||
112 | EM_IPC = 040H |
||
113 | EM_NETWORK = 080H |
||
114 | EM_DEBUG = 100H |
||
115 | |||
116 | ; Draw zero terminated string for DrawText |
||
117 | DT_ZSTRING = 080000000H |
||
118 | |||
119 | ; Charset specifiers for DrawText |
||
120 | DT_CP866_8X16 = 10000000H |
||
121 | |||
122 | ; bits for the GetControlKeyState |
||
123 | LEFT_SHIFT_PRESSED = 1 |
||
124 | RIGHT_SHIFT_PRESSED = 2 |
||
125 | LEFT_CTRL_PRESSED = 4 |
||
126 | RIGHT_CTRL_PRESSED = 8 |
||
127 | |||
128 | TOpenDialog Struct |
||
129 | mode Dword ? |
||
130 | procinfo Dword ? |
||
131 | com_area_name Dword ? |
||
132 | com_area Dword ? |
||
133 | opendir_path Dword ? |
||
134 | dir_default_path Dword ? |
||
135 | start_path Dword ? |
||
136 | draw_Window Dword ? |
||
137 | status Dword ? |
||
138 | openfile_path Dword ? |
||
139 | filename_area Dword ? |
||
140 | filter_area Dword ? |
||
141 | x_size Word ? |
||
142 | x_start SWord ? |
||
143 | y_size Word ? |
||
144 | y_start SWord ? |
||
145 | TOpenDialog EndS |
||
146 | |||
147 | TEditBox Struct |
||
148 | x_size Dword ? |
||
149 | left SDword ? |
||
150 | top SDword ? |
||
151 | color Dword ? |
||
152 | shift_color Dword ? |
||
153 | focus_border_color Dword ? |
||
154 | blur_border_color Dword ? |
||
155 | text_color Dword ? |
||
156 | max Dword ? |
||
157 | text Dword ? |
||
158 | mouse_variable Dword ? |
||
159 | flags Dword ? |
||
160 | count Dword ? |
||
161 | pos Dword ? |
||
162 | offs Dword ? |
||
163 | cl_curs_x SWord ? |
||
164 | cl_curs_y SWord ? |
||
165 | shift Word ? |
||
166 | shift_old Word ? |
||
167 | height Dword ? |
||
168 | char_width Dword ? |
||
169 | TEditBox EndS |
||
170 | |||
171 | TStandartColors Struct |
||
172 | frames Dword ? |
||
173 | grab Dword ? |
||
174 | grab_button Dword ? |
||
175 | grab_button_text Dword ? |
||
176 | grab_text Dword ? |
||
177 | work Dword ? |
||
178 | work_button Dword ? |
||
179 | work_button_text Dword ? |
||
180 | work_text Dword ? |
||
181 | work_graph Dword ? |
||
182 | TStandartColors EndS |
||
183 | |||
184 | TRect Struct |
||
185 | Left SDword ? |
||
186 | Top SDword ? |
||
187 | Right SDword ? |
||
188 | Bottom SDword ? |
||
189 | TRect EndS |
||
190 | |||
191 | TSize Struct |
||
192 | SizeY Word ? |
||
193 | SizeX Word ? |
||
194 | TSize EndS |
||
195 | |||
196 | TKeyboardInput Struct |
||
197 | Flag Byte ? |
||
198 | Code Byte ? |
||
199 | Union |
||
200 | Scan Byte ? |
||
201 | Control Word ? |
||
202 | EndS |
||
203 | TKeyboardInput EndS |
||
204 | |||
205 | TButtonInput Struct |
||
206 | MouseButton Byte ? |
||
207 | ID Word ? |
||
208 | HiID Byte ? |
||
209 | TButtonInput EndS |
||
210 | |||
211 | ; Button identifiers |
||
212 | BUTTON_RUN = 10 |
||
213 | BUTTON_BROWSE = 20 |
||
214 | |||
215 | KEY_SCAN_ENTER = 01CH |
||
216 | KEY_SCAN_INSERT = 052H |
||
217 | KEY_SCAN_F1 = 03BH |
||
218 | |||
219 | KEY_CODE_0 = 030H |
||
220 | |||
221 | PROC_INFO_BUFFER_SIZE = 1024 |
||
222 | OPEN_FILE_PATH_BUFFER_SIZE = 4096 |
||
223 | FILE_NAME_AREA_BUFFER_SIZE = 1024 |
||
224 | OPEN_DIR_PATH_BUFFER_SIZE = OPEN_FILE_PATH_BUFFER_SIZE - FILE_NAME_AREA_BUFFER_SIZE |
||
225 | |||
226 | EDIT1_TEXT_BUFFER_SIZE = 4096 |
||
227 | TMP_BUFFER_SIZE = 4096 |
||
228 | |||
229 | GetButton Proto |
||
230 | GetKey Proto |
||
231 | WaitEvent Proto |
||
232 | BeginDraw Proto |
||
233 | EndDraw Proto |
||
234 | DrawWindow Proto Left:SDword, Top:SDword, Right:SDword, Bottom:SDword, Caption:Ptr, BackColor:Dword, Style:Dword, CapStyle:Dword |
||
235 | ThreadTerminate Proto |
||
236 | LoadLibrary Proto Path:Ptr |
||
237 | GetProcAddress Proto hLib:Ptr, ProcName:Ptr |
||
238 | SetEventMask Proto EventMask:Dword |
||
239 | GetScreenSize Proto |
||
240 | GetSkinHeight Proto |
||
241 | HeapAllocate Proto Bytes:Dword |
||
242 | DrawButton Proto Left:SDword, Top:SDword, Right:SDword, Bottom:SDword, BackColor:Dword, Style:Dword, ID:Dword |
||
243 | RunFile Proto Path:Ptr, CmdLine:Ptr |
||
244 | GetStandardColors Proto ColorTable:Ptr, TableSize:Dword |
||
245 | DrawText Proto X:SDword, Y:SDword, Text:Ptr, ForeColor:Dword, BackColor:Dword, Flags:Dword, Count:Dword |
||
246 | GetControlKeyState Proto |
||
247 | |||
248 | EditBoxDraw_proto TypeDef Proto :Ptr |
||
249 | EditBoxKey_proto TypeDef Proto :Ptr |
||
250 | EditBoxMouse_proto TypeDef Proto :Ptr |
||
251 | EditBoxSetText_proto TypeDef Proto :Ptr, :Ptr |
||
252 | |||
253 | OpenDialogInit_proto TypeDef Proto :Ptr |
||
254 | OpenDialogStart_proto TypeDef Proto :Ptr |
||
255 | |||
256 | OpenDialogInit_proc TypeDef Ptr OpenDialogInit_proto |
||
257 | OpenDialogStart_proc TypeDef Ptr OpenDialogStart_proto |
||
258 | |||
259 | EditBoxDraw_proc TypeDef Ptr EditBoxDraw_proto |
||
260 | EditBoxKey_proc TypeDef Ptr EditBoxKey_proto |
||
261 | EditBoxMouse_proc TypeDef Ptr EditBoxMouse_proto |
||
262 | EditBoxSetText_proc TypeDef Ptr EditBoxSetText_proto |
||
263 | ; -------------------------------------------------------- ; |
||
264 | .Const; -------------------------------------------------- ; |
||
265 | ; -------------------------------------------------------- ; |
||
266 | szFFFFFFFFOpenDialog db "FFFFFFFF_open_dialog",0 |
||
267 | szSYS db "/sys",0 |
||
268 | szOpenDialPath db "/sys/File managers/opendial",0 |
||
269 | szEmpty db 0 |
||
270 | ; -------------------------------------------------------- ; |
||
271 | .Data; --------------------------------------------------- ; |
||
272 | ; -------------------------------------------------------- ; |
||
273 | FileFilter Dword 0 |
||
274 | |||
275 | OD TOpenDialog <\ |
||
276 | 0,\ |
||
277 | Offset ProcInfoBuffer,\ |
||
278 | Offset szFFFFFFFFOpenDialog,\ |
||
279 | 0,\ |
||
280 | Offset OpenDirPathBuffer,\ |
||
281 | Offset szSYS,\ |
||
282 | Offset szOpenDialPath,\ |
||
283 | Offset OnRedraw,\ |
||
284 | 0,\ |
||
285 | 0,\ |
||
286 | Offset FileNameAreaBuffer,\ |
||
287 | Offset FileFilter,\ |
||
288 | 414,\ |
||
289 | 0,\ |
||
290 | 414,\ |
||
291 | 0\ |
||
292 | > |
||
293 | |||
294 | Edit1 TEditBox <\ |
||
295 | 0,\ |
||
296 | 5,\ |
||
297 | 26,\ |
||
298 | 00FFFFFFH,\ |
||
299 | 00A4C4E4H,\ |
||
300 | 0,\ |
||
301 | 0,\ |
||
302 | DT_CP866_8X16,\ |
||
303 | EDIT1_TEXT_BUFFER_SIZE,\ |
||
304 | Offset Edit1TextBuffer,\ |
||
305 | Offset Edit1MouseVariable,\ |
||
306 | 4002H,\ |
||
307 | 0,\ |
||
308 | 0,\ |
||
309 | 0,\ |
||
310 | 0,\ |
||
311 | 0,\ |
||
312 | 0,\ |
||
313 | 0\ |
||
314 | > |
||
315 | ; -------------------------------------------------------- ; |
||
316 | .Data? ; ------------------------------------------------- ; |
||
317 | ; -------------------------------------------------------- ; |
||
318 | BoxLib Dword ? |
||
319 | ProcLib Dword ? |
||
320 | |||
321 | OpenDialogInit OpenDialogInit_proc ? |
||
322 | OpenDialogStart OpenDialogStart_proc ? |
||
323 | |||
324 | EditBoxDraw EditBoxDraw_proc ? |
||
325 | EditBoxKey EditBoxKey_proc ? |
||
326 | EditBoxMouse EditBoxMouse_proc ? |
||
327 | EditBoxSetText EditBoxSetText_proc ? |
||
328 | |||
329 | SC TStandartColors <> |
||
330 | Window TRect <> |
||
331 | Screen TSize <> |
||
332 | |||
333 | RunResult Dword ? |
||
334 | RunParams Dword ? |
||
335 | RunPath Dword ? |
||
336 | |||
337 | AlwaysWithoutQuote Dword ? |
||
338 | ClearBeforeInsert Dword ? |
||
339 | |||
340 | Key TKeyboardInput <> |
||
341 | Button TButtonInput <> |
||
342 | |||
343 | FileNameAreaBuffer Byte FILE_NAME_AREA_BUFFER_SIZE Dup (?) |
||
344 | OpenFilePathBuffer Byte OPEN_FILE_PATH_BUFFER_SIZE Dup (?) |
||
345 | OpenDirPathBuffer Byte OPEN_DIR_PATH_BUFFER_SIZE Dup (?) |
||
346 | ProcInfoBuffer Byte PROC_INFO_BUFFER_SIZE Dup (?) |
||
347 | |||
348 | Edit1MouseVariable Dword ? |
||
349 | Edit1TextBuffer Byte EDIT1_TEXT_BUFFER_SIZE + 2 Dup (?) ; buffer for Edit1.text |
||
350 | TmpBuffer Byte TMP_BUFFER_SIZE Dup (?) ; this buffer uses in StrInsert |
||
351 | ; -------------------------------------------------------- ; |
||
352 | .Code ; -------------------------------------------------- ; |
||
353 | ; -------------------------------------------------------- ; |
||
354 | OnRedraw Proc |
||
355 | Invoke BeginDraw |
||
356 | Invoke GetStandardColors, Offset SC, SizeOf(SC) |
||
357 | |||
358 | mov eax, SC.work_graph |
||
359 | mov Edit1.focus_border_color, eax |
||
360 | |||
361 | Invoke DrawWindow, Window.Left, Window.Top, Window.Right, Window.Bottom, szTitle, SC.work, WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CS_MOVABLE |
||
362 | Invoke DrawText, 5, 5, szTypeNameOfProgram, SC.work_text, 0, DT_ZSTRING + DT_CP866_8X16, 0 |
||
363 | ; Browse button |
||
364 | mov eax, Window.Right |
||
365 | sub eax, 70 |
||
366 | Invoke DrawButton, eax, 26, 52, 21, SC.work_button, 0, 20 |
||
367 | mov eax, Window.Right |
||
368 | sub eax, 56 |
||
369 | Invoke DrawText, eax, 29, CStr("..."), SC.work_button_text, 0, DT_ZSTRING + DT_CP866_8X16, 0 |
||
370 | ; Run button |
||
371 | mov eax, Window.Right |
||
372 | sub eax, 22 |
||
373 | Invoke DrawButton, 5, 52, eax, 21, SC.work_button, 0, 10 |
||
374 | mov eax, Window.Right |
||
375 | shr eax, 1 |
||
376 | sub eax, 40 |
||
377 | Invoke DrawText, eax, 55, szRun, SC.work_button_text, 0, DT_ZSTRING + DT_CP866_8X16, 0 |
||
378 | ; Result text |
||
379 | Invoke DrawText, 5, 80, RunResult, SC.work_text, 0, DT_ZSTRING + DT_CP866_8X16, 0 |
||
380 | Invoke EditBoxDraw, Offset Edit1 |
||
381 | Invoke EndDraw |
||
382 | ret |
||
383 | OnRedraw Endp |
||
384 | ; -------------------------------------------------------- ; |
||
385 | StrInsert Proc Uses esi edi Src:Ptr, Dst:Ptr, Pos:Dword |
||
386 | Local TotalLength:Dword |
||
387 | |||
388 | mov TotalLength, 0 |
||
389 | |||
390 | mov esi, Dst |
||
391 | mov edi, Offset TmpBuffer |
||
392 | mov ecx, Pos |
||
393 | add TotalLength, ecx |
||
394 | rep movsb |
||
395 | |||
396 | mov edi, Src |
||
397 | mov ecx, 0FFFFFFFFH |
||
398 | xor eax, eax |
||
399 | repne scasb |
||
400 | mov eax, 0FFFFFFFEH |
||
401 | sub eax, ecx |
||
402 | add TotalLength, eax |
||
403 | |||
404 | mov esi, Src |
||
405 | mov edi, Offset TmpBuffer |
||
406 | add edi, Pos |
||
407 | mov ecx, eax |
||
408 | rep movsb |
||
409 | |||
410 | push edi |
||
411 | |||
412 | mov edi, Dst |
||
413 | add edi, Pos |
||
414 | mov ecx, 0FFFFFFFFH |
||
415 | xor eax, eax |
||
416 | repne scasb |
||
417 | mov eax, 0FFFFFFFEH |
||
418 | sub eax, ecx |
||
419 | inc eax |
||
420 | add TotalLength, eax |
||
421 | |||
422 | pop edi |
||
423 | |||
424 | mov esi, Dst |
||
425 | add esi, Pos |
||
426 | mov ecx, eax |
||
427 | rep movsb |
||
428 | |||
429 | mov esi, Offset TmpBuffer |
||
430 | mov edi, Dst |
||
431 | mov ecx, TotalLength |
||
432 | rep movsb |
||
433 | |||
434 | ret |
||
435 | StrInsert Endp |
||
436 | ; -------------------------------------------------------- ; |
||
437 | OnButtonRun Proc |
||
438 | Local TmpChar: Byte |
||
439 | Local StartWithQuote: Dword |
||
440 | ; need to split path & params |
||
441 | mov eax, Edit1.text |
||
442 | ; Skip Spaces |
||
443 | .While Byte Ptr [eax] == ' ' |
||
444 | inc eax |
||
445 | .EndW |
||
446 | mov StartWithQuote, 0 |
||
447 | ; Skip Possible Quotation Mark |
||
448 | .If Byte Ptr [eax] == '"' |
||
449 | mov StartWithQuote, TRUE |
||
450 | inc eax |
||
451 | .EndIf |
||
452 | mov RunPath, eax |
||
453 | ; Find Space Or Quote Or EndOfString |
||
454 | .Repeat |
||
455 | .If Byte Ptr [eax] == ' ' |
||
456 | .If !StartWithQuote |
||
457 | mov TmpChar, ' ' |
||
458 | mov Byte Ptr [eax], 0 |
||
459 | push eax ; save pointer |
||
460 | inc eax |
||
461 | ; Skip Spaces |
||
462 | .While Byte Ptr [eax] == ' ' |
||
463 | inc eax |
||
464 | .EndW |
||
465 | .Break |
||
466 | .EndIf |
||
467 | .ElseIf Byte Ptr [eax] == '"' |
||
468 | mov TmpChar, '"' |
||
469 | mov Byte Ptr [eax], 0 |
||
470 | push eax ; save pointer |
||
471 | inc eax |
||
472 | ; Skip Spaces |
||
473 | .While Byte Ptr [eax] == ' ' |
||
474 | inc eax |
||
475 | .EndW |
||
476 | ; params can be written immediately after quotation mark |
||
477 | ; without any spaces |
||
478 | ; like this way: "path"params |
||
479 | .Break |
||
480 | .ElseIf Byte Ptr [eax] == 0 |
||
481 | push eax ; save pointer |
||
482 | mov TmpChar, 0 |
||
483 | .Break |
||
484 | .EndIf |
||
485 | inc eax |
||
486 | .Until 0 |
||
487 | mov RunParams, eax |
||
488 | Invoke RunFile, RunPath, RunParams |
||
489 | test eax, eax |
||
490 | .If SIGN? |
||
491 | .If eax == -5 |
||
492 | mov RunResult, szFileNotFound |
||
493 | .ElseIf eax == -31 |
||
494 | mov RunResult, szFileIsNotExecutable |
||
495 | .ElseIf eax == -32 |
||
496 | mov RunResult, szTooManyProcesses |
||
497 | .ElseIf eax == -10 |
||
498 | mov RunResult, szAccessDenied |
||
499 | .ElseIf eax == -30 |
||
500 | mov RunResult, szOutOfMemory |
||
501 | .Else |
||
502 | mov RunResult, szUnknownError |
||
503 | .EndIf |
||
504 | .Else |
||
505 | mov RunResult, szProgramRunSuccessfully |
||
506 | .EndIf |
||
507 | |||
508 | pop eax ; restore char changed by 0 |
||
509 | mov cl, TmpChar |
||
510 | mov Byte Ptr [eax], cl |
||
511 | |||
512 | Invoke OnRedraw |
||
513 | ret |
||
514 | OnButtonRun Endp |
||
515 | ; -------------------------------------------------------- ; |
||
516 | OnButtonBrowse Proc |
||
517 | Local NeedQuote:Dword |
||
518 | |||
519 | Invoke OpenDialogStart, Offset OD |
||
520 | .If OD.status != 0 |
||
521 | |||
522 | ; need to check if spaces are in path and if so then quote path |
||
523 | mov eax, OD.openfile_path |
||
524 | ; by default assume quote not needed |
||
525 | mov NeedQuote, 0 |
||
526 | .While Byte Ptr [eax] |
||
527 | .If Byte Ptr [eax] == ' ' |
||
528 | ; need quote |
||
529 | mov NeedQuote, TRUE |
||
530 | .EndIf |
||
531 | inc eax |
||
532 | .EndW |
||
533 | ; eax -> zero byte |
||
534 | .If NeedQuote && !AlwaysWithoutQuote |
||
535 | mov Byte Ptr [eax], '"' |
||
536 | mov Byte Ptr [eax + 1], 0 |
||
537 | push eax ; save pointer |
||
538 | mov eax, OD.openfile_path |
||
539 | dec eax |
||
540 | .Else |
||
541 | mov eax, OD.openfile_path |
||
542 | .EndIf |
||
543 | |||
544 | .If ClearBeforeInsert |
||
545 | Invoke EditBoxSetText, Offset Edit1, Offset szEmpty |
||
546 | .EndIf |
||
547 | |||
548 | Invoke StrInsert, eax, Edit1.text, Edit1.pos |
||
549 | |||
550 | .If NeedQuote && !AlwaysWithoutQuote |
||
551 | pop eax ; restore zero changed by quote |
||
552 | mov Byte Ptr [eax], 0 |
||
553 | .EndIf |
||
554 | |||
555 | Invoke EditBoxSetText, Offset Edit1, Edit1.text |
||
556 | .EndIf |
||
557 | ret |
||
558 | OnButtonBrowse Endp |
||
559 | ; -------------------------------------------------------- ; |
||
560 | @Main: |
||
561 | Invoke SetEventMask, EM_REDRAW + EM_KEY + EM_BUTTON + EM_MOUSE |
||
562 | Invoke LoadLibrary, CStr("/sys/lib/box_lib.obj") |
||
563 | mov BoxLib, eax |
||
564 | Invoke LoadLibrary, CStr("/sys/lib/proc_lib.obj") |
||
565 | mov ProcLib, eax |
||
566 | Invoke GetProcAddress, BoxLib, CStr("edit_box") |
||
567 | mov EditBoxDraw, eax |
||
568 | Invoke GetProcAddress, BoxLib, CStr("edit_box_key") |
||
569 | mov EditBoxKey, eax |
||
570 | Invoke GetProcAddress, BoxLib, CStr("edit_box_mouse") |
||
571 | mov EditBoxMouse, eax |
||
572 | Invoke GetProcAddress, BoxLib, CStr("edit_box_set_text") |
||
573 | mov EditBoxSetText, eax |
||
574 | Invoke GetProcAddress, ProcLib, CStr("OpenDialog_init") |
||
575 | mov OpenDialogInit, eax |
||
576 | Invoke GetProcAddress, ProcLib, CStr("OpenDialog_start") |
||
577 | mov OpenDialogStart, eax |
||
578 | |||
579 | ; it need for case if spaces are present in filepath |
||
580 | lea eax, [OpenFilePathBuffer + 1] |
||
581 | mov OD.openfile_path, eax |
||
582 | mov OpenFilePathBuffer, '"' |
||
583 | |||
584 | Invoke OpenDialogInit, Offset OD |
||
585 | |||
586 | Invoke GetScreenSize |
||
587 | mov Screen, eax |
||
588 | shr eax, 17 |
||
589 | add eax, 90 |
||
590 | mov Window.Right, eax |
||
591 | |||
592 | Invoke GetSkinHeight |
||
593 | add eax, 100 |
||
594 | mov Window.Bottom, eax |
||
595 | |||
596 | movzx eax, Screen.SizeX |
||
597 | sub eax, Window.Right |
||
598 | shr eax, 1 |
||
599 | mov Window.Left, eax |
||
600 | |||
601 | movzx eax, Screen.SizeY |
||
602 | sub eax, Window.Bottom |
||
603 | sub eax, 100 |
||
604 | mov Window.Top, eax |
||
605 | |||
606 | mov eax, Window.Right |
||
607 | sub eax, 80 |
||
608 | mov Edit1.x_size, eax |
||
609 | |||
610 | mov RunResult, szPressF1 |
||
611 | |||
612 | .Repeat |
||
613 | Invoke WaitEvent |
||
614 | .If eax == REDRAW_EVENT |
||
615 | Invoke OnRedraw |
||
616 | .ElseIf eax == KEY_EVENT |
||
617 | Invoke GetControlKeyState |
||
618 | .If eax & (RIGHT_SHIFT_PRESSED Or LEFT_SHIFT_PRESSED) |
||
619 | mov AlwaysWithoutQuote, TRUE |
||
620 | .Else |
||
621 | mov AlwaysWithoutQuote, FALSE |
||
622 | .EndIf |
||
623 | .If eax & (RIGHT_CTRL_PRESSED Or LEFT_CTRL_PRESSED) |
||
624 | mov ClearBeforeInsert, FALSE |
||
625 | .Else |
||
626 | mov ClearBeforeInsert, TRUE |
||
627 | .EndIf |
||
628 | Invoke GetKey |
||
629 | mov Key, eax |
||
630 | .If Key.Scan == KEY_SCAN_ENTER |
||
631 | Invoke OnButtonRun |
||
632 | ; need check Code cause numpad0.Scan = Insert.Scan |
||
633 | .ElseIf (Key.Scan == KEY_SCAN_INSERT) && \ |
||
634 | (Key.Code != KEY_CODE_0) |
||
635 | Invoke OnButtonBrowse |
||
636 | .ElseIf Key.Scan == KEY_SCAN_F1 |
||
637 | Invoke RunFile, CStr("/SYS/@NOTIFY"), szHelpInfo |
||
638 | .Else |
||
639 | Invoke EditBoxKey, Offset Edit1 |
||
640 | .EndIf |
||
641 | .ElseIf eax == BUTTON_EVENT |
||
642 | Invoke GetButton |
||
643 | mov Button, eax |
||
644 | .If Button.ID == 1 |
||
645 | Invoke ThreadTerminate |
||
646 | .ElseIf Button.ID == BUTTON_RUN |
||
647 | Invoke OnButtonRun |
||
648 | .ElseIf Button.ID == BUTTON_BROWSE |
||
649 | Invoke OnButtonBrowse |
||
650 | .EndIf |
||
651 | .ElseIf eax == MOUSE_EVENT |
||
652 | Invoke EditBoxMouse, Offset Edit1 |
||
653 | .EndIf |
||
654 | .Until 0 |
||
655 | END>>>>>\ |