~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Frontier Kernel
Frontier/Common/source/FrontierWinMain.c

Version: ~ [ 10.0 ] ~

** Warning: Cannot open xref database.

1 2 /* $Id: FrontierWinMain.c,v 1.6 2005/01/30 20:31:40 sethdill Exp $ */ 3 4 /****************************************************************************** 5 6 UserLand Frontier(tm) -- High performance Web content management, 7 object database, system-level and Internet scripting environment, 8 including source code editing and debugging. 9 10 Copyright (C) 1992-2004 UserLand Software, Inc. 11 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 2 of the License, or 15 (at your option) any later version. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 26 ******************************************************************************/ 27 28 #include "frontier.h" 29 #include "standard.h" 30 31 #ifdef PIKE 32 #define _WIN32_IE 0x0500 33 #endif 34 35 #include "WinLand.h" 36 #include "dialogs.h" 37 #include "file.h" 38 #include "font.h" 39 #include "kb.h" 40 #include "menu.h" 41 #include "mouse.h" 42 #include "quickdraw.h" 43 #include "scrap.h" 44 #include "strings.h" 45 #include "frontierwindows.h" 46 #include "cancoon.h" 47 #include "cancooninternal.h" 48 #include "shell.h" 49 #include "shellprivate.h" 50 #include "shellmenu.h" 51 #include "lang.h" 52 #include "launch.h" 53 #include "frontierstart.h" 54 #include "WinSockNetEvents.h" 55 #include "FrontierWinMain.h" 56 #include "winregistry.h" 57 #include "langdll.h" 58 #include "htmlcontrol.h" /*8/26/00 by RAB*/ 59 #include "langinternal.h" /*7.0b31 PBS*/ 60 #include "tablestructure.h" /*7.0b31 PBS*/ 61 #include "dockmenu.h" 62 63 extern typrocessid langipcself; 64 65 HINSTANCE shellinstance; 66 HINSTANCE hInst; 67 static boolean flinstanceinitialized = false; //5.1.5b7 dmb 68 69 HWND shellframewindow; 70 HWND hwndMDIClient= NULL; 71 HWND hwndActive; 72 HWND hwndStatus = NULL; 73 HWND hwndHTMLControl = NULL; 74 long gstatuswindowparts = 1; 75 long gstatuswindowarray[50] = {0}; 76 HICON hIconApp; 77 78 //#ifdef PIKE 79 HICON hTrayIconApp; 80 #define FWM_SYSTRAYICON WM_USER + 19 81 //#endif 82 83 HANDLE hAccel; 84 static HWND hwndNextViewer = (HWND) -1; 85 86 LONG styleDefault = WS_OVERLAPPEDWINDOW; //WS_MAXIMIZE; /* Default style bits for child windows */ 87 88 LONG CALLBACK FrontierOPWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 89 LONG CALLBACK FrontierFrameWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 90 91 #ifdef PIKE 92 CHAR szFrame[] = "pikeframe"; /* Class name for "frame" window */ 93 94 CHAR szChild1[] = "pikeopchild"; /* Class name for op MDI window */ 95 CHAR szChildFTop[] = "pikeoutlinechild"; 96 CHAR szChildFTwp[] = "pikewpchild"; 97 CHAR szChildFTtb[] = "piketablechild"; 98 CHAR szChildFTmb[] = "pikemenuchild"; 99 CHAR szChildFTsc[] = "pikescriptchild"; 100 CHAR szChildRoot[] = "pikerootchild"; 101 102 CHAR szChildHTML[] = "pikeHTMLchild"; 103 104 CHAR sz_frontierstartreplace [] = "PikeStartReplace"; 105 CHAR sz_frontierstartsearch [] = "PikeStartSearch"; 106 #else 107 CHAR szFrame[] = "frontierframe"; /* Class name for "frame" window */ 108 109 CHAR szChild1[] = "frontieropchild"; /* Class name for op MDI window */ 110 CHAR szChildFTop[] = "frontieroutlinechild"; 111 CHAR szChildFTwp[] = "frontierwpchild"; 112 CHAR szChildFTtb[] = "frontiertablechild"; 113 CHAR szChildFTmb[] = "frontiermenuchild"; 114 CHAR szChildFTsc[] = "frontierscriptchild"; 115 CHAR szChildRoot[] = "frontierrootchild"; 116 117 CHAR szChildHTML[] = "frontierHTMLchild"; 118 119 CHAR sz_frontierstartreplace [] = "FrontierStartReplace"; 120 CHAR sz_frontierstartsearch [] = "FrontierStartSearch"; 121 #endif 122 123 UINT wm_startreplace; 124 UINT wm_startsearch; 125 126 CHAR *pCmdLine; 127 128 static UINT wm_frontieropenfile; 129 static HANDLE frontiermutex; 130 static UINT wm_findmsgstring; /*Used for find/replace dialogs */ 131 132 //RAB: 1/20/98 this was 8 changed to 12 for status bar control window handle 133 #define OPWindowExtraByteCount 12 134 135 //-----------------------RABCC Message Tracking Code----------------------------------------------- 136 // August 20, 1994 137 // This code provides a logging of messages received by a window. This is useful for tracking 138 // re-entrency bugs. 139 // 140 // 141 #define MESSAGETRACKSYSTEM 0 142 143 #if (MESSAGETRACKSYSTEM == 1) 144 #pragma message ("***************************************MESSAGETRACKING IS ON!!***************************************") 145 FILE * errfile = NULL; 146 #define MSGDEFAULT 3 147 #define MSGOTHER 4 148 149 150 UINT MESSAGESTACK[100]; 151 short MESSAGESTACKPTR = 0; 152 153 void PUSHMESSAGE (UINT msg) 154 { 155 MESSAGESTACK[MESSAGESTACKPTR] = msg; 156 ++MESSAGESTACKPTR; 157 } 158 159 UINT POPMESSAGE () 160 { 161 --MESSAGESTACKPTR; 162 return (MESSAGESTACK[MESSAGESTACKPTR]); 163 } 164 165 166 void GETMESSAGETEXT (UINT msg, char * msgname) 167 { 168 switch (msg) 169 { 170 case WM_NULL: 171 strcpy (msgname, "WM_NULL"); 172 break; 173 174 case WM_CREATE : //001 175 strcpy (msgname, "WM_CREATE"); 176 break; 177 178 case WM_DESTROY : //0x0002 179 strcpy (msgname, "WM_DESTROY"); 180 break; 181 182 case WM_MOVE : //0x0003 183 strcpy (msgname, "WM_MOVE"); 184 break; 185 186 case WM_SIZE : //0x0005 187 strcpy (msgname, "WM_SIZE"); 188 break; 189 190 case WM_ACTIVATE : //0x0006 191 strcpy (msgname, "WM_ACTIVATE"); 192 break; 193 194 case WM_SETFOCUS : //0x0007 195 strcpy (msgname, "WM_SETFOCUS"); 196 break; 197 198 case WM_KILLFOCUS : //0x0008 199 strcpy (msgname, "WM_KILLFOCUS"); 200 break; 201 202 case WM_ENABLE : //0x000A 203 strcpy (msgname, "WM_ENABLE"); 204 break; 205 206 case WM_SETREDRAW : //0x000B 207 strcpy (msgname, "WM_SETREDRAW"); 208 break; 209 210 case WM_SETTEXT : //0x000C 211 strcpy (msgname, "WM_SETTEXT"); 212 break; 213 214 case WM_GETTEXT : //0x000D 215 strcpy (msgname, "WM_GETTEXT"); 216 break; 217 218 case WM_GETTEXTLENGTH : //0x000E 219 strcpy (msgname, "WM_GETTEXTLENGTH"); 220 break; 221 222 case WM_PAINT : //0x000F 223 strcpy (msgname, "WM_PAINT"); 224 break; 225 226 case WM_CLOSE : //0x0010 227 strcpy (msgname, "WM_CLOSE"); 228 break; 229 230 case WM_QUERYENDSESSION : //0x0011 231 strcpy (msgname, "WM_QUERYENDSESSION"); 232 break; 233 234 case WM_QUIT : //0x0012 235 strcpy (msgname, "WM_QUIT"); 236 break; 237 238 case WM_QUERYOPEN : //0x0013 239 strcpy (msgname, "WM_QUERYOPEN"); 240 break; 241 242 case WM_ERASEBKGND : //0x0014 243 strcpy (msgname, "WM_ERASEBKGND"); 244 break; 245 246 case WM_SYSCOLORCHANGE : //0x0015 247 strcpy (msgname, "WM_SYSCOLORCHANGE"); 248 break; 249 250 case WM_ENDSESSION : //0x0016 251 strcpy (msgname, "WM_ENDSESSION"); 252 break; 253 254 case WM_SHOWWINDOW : //0x0018 255 strcpy (msgname, "WM_SHOWWINDOW"); 256 break; 257 258 case WM_WININICHANGE : //0x001A 259 strcpy (msgname, "WM_WININICHANGE"); 260 break; 261 262 case WM_DEVMODECHANGE : //0x001B 263 strcpy (msgname, "WM_DEVMODECHANGE"); 264 break; 265 266 case WM_ACTIVATEAPP : //0x001C 267 strcpy (msgname, "WM_ACTIVATEAPP"); 268 break; 269 270 case WM_FONTCHANGE : //0x001D 271 strcpy (msgname, "WM_FONTCHANGE"); 272 break; 273 274 case WM_TIMECHANGE : //0x001E 275 strcpy (msgname, "WM_TIMECHANGE"); 276 break; 277 278 case WM_CANCELMODE : //0x001F 279 strcpy (msgname, "WM_CANCELMODE"); 280 break; 281 282 case WM_SETCURSOR : //0x0020 283 strcpy (msgname, "WM_SETCURSOR"); 284 break; 285 286 case WM_MOUSEACTIVATE : //0x0021 287 strcpy (msgname, "WM_MOUSEACTIVATE"); 288 break; 289 290 case WM_CHILDACTIVATE : //0x0022 291 strcpy (msgname, "WM_CHILDACTIVATE"); 292 break; 293 294 case WM_QUEUESYNC : //0x0023 295 strcpy (msgname, "WM_QUEUESYNC"); 296 break; 297 298 299 case WM_GETMINMAXINFO : //0x0024 300 strcpy (msgname, "WM_GETMINMAXINFO"); 301 break; 302 303 case WM_PAINTICON : //0x0026 304 strcpy (msgname, "WM_PAINTICON"); 305 break; 306 307 case WM_ICONERASEBKGND : //0x0027 308 strcpy (msgname, "WM_ICONERASEBKGND"); 309 break; 310 311 case WM_NEXTDLGCTL : //0x0028 312 strcpy (msgname, "WM_NEXTDLGCTL"); 313 break; 314 315 case WM_SPOOLERSTATUS : //0x002A 316 strcpy (msgname, "WM_SPOOLERSTATUS"); 317 break; 318 319 case WM_DRAWITEM : //0x002B 320 strcpy (msgname, "WM_DRAWITEM"); 321 break; 322 323 case WM_MEASUREITEM : //0x002C 324 strcpy (msgname, "WM_MEASUREITEM"); 325 break; 326 327 case WM_DELETEITEM : //0x002D 328 strcpy (msgname, "WM_DELETEITEM"); 329 break; 330 331 case WM_VKEYTOITEM : //0x002E 332 strcpy (msgname, "WM_VKEYTOITEM"); 333 break; 334 335 case WM_CHARTOITEM : //0x002F 336 strcpy (msgname, "WM_CHARTOITEM"); 337 break; 338 339 case WM_SETFONT : //0x0030 340 strcpy (msgname, "WM_SETFONT"); 341 break; 342 343 case WM_GETFONT : //0x0031 344 strcpy (msgname, "WM_GETFONT"); 345 break; 346 347 case WM_SETHOTKEY : //0x0032 348 strcpy (msgname, "WM_SETHOTKEY"); 349 break; 350 351 case WM_GETHOTKEY : //0x0033 352 strcpy (msgname, "WM_GETHOTKEY"); 353 break; 354 355 case WM_QUERYDRAGICON : //0x0037 356 strcpy (msgname, "WM_QUERYDRAGICON"); 357 break; 358 359 case WM_COMPAREITEM : //0x0039 360 strcpy (msgname, "WM_COMPAREITEM"); 361 break; 362 363 case WM_COMPACTING : //0x0041 364 strcpy (msgname, "WM_COMPACTING"); 365 break; 366 367 case WM_COMMNOTIFY : //0x0044 /* no longer suported */ 368 strcpy (msgname, "WM_COMMNOTIFY"); 369 break; 370 371 case WM_WINDOWPOSCHANGING : //0x0046 372 strcpy (msgname, "WM_WINDOWPOSCHANGING"); 373 break; 374 375 case WM_WINDOWPOSCHANGED : //0x0047 376 strcpy (msgname, "WM_WINDOWPOSCHANGED"); 377 break; 378 379 case WM_POWER : //0x0048 380 strcpy (msgname, "WM_POWER"); 381 break; 382 383 case WM_COPYDATA : //0x004A 384 strcpy (msgname, "WM_COPYDATA"); 385 break; 386 387 case WM_CANCELJOURNAL : //0x004B 388 strcpy (msgname, "WM_CANCELJOURNAL"); 389 break; 390 391 case WM_NOTIFY : //0x004E 392 strcpy (msgname, "WM_NOTIFY"); 393 break; 394 395 case WM_INPUTLANGCHANGEREQUEST : //0x0050 396 strcpy (msgname, "WM_INPUTLANGCHANGEREQUEST"); 397 break; 398 399 case WM_INPUTLANGCHANGE : //0x0051 400 strcpy (msgname, "WM_INPUTLANGCHANGE"); 401 break; 402 403 case WM_TCARD : //0x0052 404 strcpy (msgname, "WM_TCARD"); 405 break; 406 407 case WM_HELP : //0x0053 408 strcpy (msgname, "WM_HELP"); 409 break; 410 411 case WM_USERCHANGED : //0x0054 412 strcpy (msgname, "WM_USERCHANGED"); 413 break; 414 415 case WM_NOTIFYFORMAT : //0x0055 416 strcpy (msgname, "WM_NOTIFYFORMAT"); 417 break; 418 419 case WM_CONTEXTMENU : //0x007B 420 strcpy (msgname, "WM_CONTEXTMENU"); 421 break; 422 423 case WM_STYLECHANGING : //0x007C 424 strcpy (msgname, "WM_STYLECHANGING"); 425 break; 426 427 case WM_STYLECHANGED : //0x007D 428 strcpy (msgname, "WM_STYLECHANGED"); 429 break; 430 431 case WM_DISPLAYCHANGE : //0x007E 432 strcpy (msgname, "WM_DISPLAYCHANGE"); 433 break; 434 435 case WM_GETICON : //0x007F 436 strcpy (msgname, "WM_GETICON"); 437 break; 438 439 case WM_SETICON : //0x0080 440 strcpy (msgname, "WM_SETICON"); 441 break; 442 443 case WM_NCCREATE : //0x0081 444 strcpy (msgname, "WM_NCCREATE"); 445 break; 446 447 case WM_NCDESTROY : //0x0082 448 strcpy (msgname, "WM_NCDESTROY"); 449 break; 450 451 case WM_NCCALCSIZE : //0x0083 452 strcpy (msgname, "WM_NCCALCSIZE"); 453 break; 454 455 case WM_NCHITTEST : //0x0084 456 strcpy (msgname, "WM_NCHITTEST"); 457 break; 458 459 case WM_NCPAINT : //0x0085 460 strcpy (msgname, "WM_NCPAINT"); 461 break; 462 463 case WM_NCACTIVATE : //0x0086 464 strcpy (msgname, "WM_NCACTIVATE"); 465 break; 466 467 case WM_GETDLGCODE : //0x0087 468 strcpy (msgname, "WM_GETDLGCODE"); 469 break; 470 471 case WM_NCMOUSEMOVE : //0x00A0 472 strcpy (msgname, "WM_NCMOUSEMOVE"); 473 break; 474 475 case WM_NCLBUTTONDOWN : //0x00A1 476 strcpy (msgname, "WM_NCLBUTTONDOWN"); 477 break; 478 479 case WM_NCLBUTTONUP : //0x00A2 480 strcpy (msgname, "WM_NCLBUTTONUP"); 481 break; 482 483 case WM_NCLBUTTONDBLCLK : //0x00A3 484 strcpy (msgname, "WM_NCLBUTTONDBLCLK"); 485 break; 486 487 case WM_NCRBUTTONDOWN : //0x00A4 488 strcpy (msgname, "WM_NCRBUTTONDOWN"); 489 break; 490 491 case WM_NCRBUTTONUP : //0x00A5 492 strcpy (msgname, "WM_NCRBUTTONUP"); 493 break; 494 495 case WM_NCRBUTTONDBLCLK : //0x00A6 496 strcpy (msgname, "WM_NCRBUTTONDBLCLK"); 497 break; 498 499 case WM_NCMBUTTONDOWN : //0x00A7 500 strcpy (msgname, "WM_NCMBUTTONDOWN"); 501 break; 502 503 case WM_NCMBUTTONUP : //0x00A8 504 strcpy (msgname, "WM_NCMBUTTONUP"); 505 break; 506 507 case WM_NCMBUTTONDBLCLK : //0x00A9 508 strcpy (msgname, "WM_NCMBUTTONDBLCLK"); 509 break; 510 511 case WM_KEYDOWN : //0x0100 512 strcpy (msgname, "WM_KEYDOWN"); 513 break; 514 515 case WM_KEYUP : //0x0101 516 strcpy (msgname, "WM_KEYUP"); 517 break; 518 519 case WM_CHAR : //0x0102 520 strcpy (msgname, "WM_CHAR"); 521 break; 522 523 case WM_DEADCHAR : //0x0103 524 strcpy (msgname, "WM_DEADCHAR"); 525 break; 526 527 case WM_SYSKEYDOWN : //0x0104 528 strcpy (msgname, "WM_SYSKEYDOWN"); 529 break; 530 531 case WM_SYSKEYUP : //0x0105 532 strcpy (msgname, "WM_SYSKEYUP"); 533 break; 534 535 case WM_SYSCHAR : //0x0106 536 strcpy (msgname, "WM_SYSCHAR"); 537 break; 538 539 case WM_SYSDEADCHAR : //0x0107 540 strcpy (msgname, "WM_SYSDEADCHAR"); 541 break; 542 543 case WM_KEYLAST : //0x0108 544 strcpy (msgname, "WM_KEYLAST"); 545 break; 546 547 case WM_IME_STARTCOMPOSITION : //0x010D 548 strcpy (msgname, "WM_IME_STARTCOMPOSITION"); 549 break; 550 551 case WM_IME_ENDCOMPOSITION : //0x010E 552 strcpy (msgname, "WM_IME_ENDCOMPOSITION"); 553 break; 554 555 case WM_IME_COMPOSITION : //0x010F 556 strcpy (msgname, "WM_IME_COMPOSITION"); 557 break; 558 559 case WM_INITDIALOG : //0x0110 560 strcpy (msgname, "WM_INITDIALOG"); 561 break; 562 563 case WM_COMMAND : //0x0111 564 strcpy (msgname, "WM_COMMAND"); 565 break; 566 567 case WM_SYSCOMMAND : //0x0112 568 strcpy (msgname, "WM_SYSCOMMAND"); 569 break; 570 571 case WM_TIMER : //0x0113 572 strcpy (msgname, "WM_TIMER"); 573 break; 574 575 case WM_HSCROLL : //0x0114 576 strcpy (msgname, "WM_HSCROLL"); 577 break; 578 579 case WM_VSCROLL : //0x0115 580 strcpy (msgname, "WM_VSCROLL"); 581 break; 582 583 case WM_INITMENU : //0x0116 584 strcpy (msgname, "WM_INITMENU"); 585 break; 586 587 case WM_INITMENUPOPUP : //0x0117 588 strcpy (msgname, "WM_INITMENUPOPUP"); 589 break; 590 591 case WM_MENUSELECT : //0x011F 592 strcpy (msgname, "WM_MENUSELECT"); 593 break; 594 595 case WM_MENUCHAR : //0x0120 596 strcpy (msgname, "WM_MENUCHAR"); 597 break; 598 599 case WM_ENTERIDLE : //0x0121 600 strcpy (msgname, "WM_ENTERIDLE"); 601 break; 602 603 604 case WM_CTLCOLORMSGBOX : //0x0132 605 strcpy (msgname, "WM_CTLCOLORMSGBOX"); 606 break; 607 608 case WM_CTLCOLOREDIT : //0x0133 609 strcpy (msgname, "WM_CTLCOLOREDIT"); 610 break; 611 612 case WM_CTLCOLORLISTBOX : //0x0134 613 strcpy (msgname, "WM_CTLCOLORLISTBOX"); 614 break; 615 616 case WM_CTLCOLORBTN : //0x0135 617 strcpy (msgname, "WM_CTLCOLORBTN"); 618 break; 619 620 case WM_CTLCOLORDLG : //0x0136 621 strcpy (msgname, "WM_CTLCOLORDLG"); 622 break; 623 624 case WM_CTLCOLORSCROLLBAR : //0x0137 625 strcpy (msgname, "WM_CTLCOLORSCROLLBAR"); 626 break; 627 628 case WM_CTLCOLORSTATIC : //0x0138 629 strcpy (msgname, "WM_CTLCOLORSTATIC"); 630 break; 631 632 case WM_MOUSEMOVE : //0x0200 633 strcpy (msgname, "WM_MOUSEMOVE"); 634 break; 635 636 case WM_LBUTTONDOWN : //0x0201 637 strcpy (msgname, "WM_LBUTTONDOWN"); 638 break; 639 640 case WM_LBUTTONUP : //0x0202 641 strcpy (msgname, "WM_LBUTTONUP"); 642 break; 643 644 case WM_LBUTTONDBLCLK : //0x0203 645 strcpy (msgname, "WM_LBUTTONDBLCLK"); 646 break; 647 648 case WM_RBUTTONDOWN : //0x0204 649 strcpy (msgname, "WM_RBUTTONDOWN"); 650 break; 651 652 case WM_RBUTTONUP : //0x0205 653 strcpy (msgname, "WM_RBUTTONUP"); 654 break; 655 656 case WM_RBUTTONDBLCLK : //0x0206 657 strcpy (msgname, "WM_RBUTTONDBLCLK"); 658 break; 659 660 case WM_MBUTTONDOWN : //0x0207 661 strcpy (msgname, "WM_MBUTTONDOWN"); 662 break; 663 664 case WM_MBUTTONUP : //0x0208 665 strcpy (msgname, "WM_MBUTTONUP"); 666 break; 667 668 case WM_MBUTTONDBLCLK : //0x0209 669 strcpy (msgname, "WM_MBUTTONDBLCLK"); 670 break; 671 672 // case WM_MOUSEWHEEL : //0x020A 673 // strcpy (msgname, "WM_MOUSEWHEEL"); 674 // break; 675 676 case WM_PARENTNOTIFY : //0x0210 677 strcpy (msgname, "WM_PARENTNOTIFY"); 678 break; 679 680 case WM_ENTERMENULOOP : //0x0211 681 strcpy (msgname, "WM_ENTERMENULOOP"); 682 break; 683 684 case WM_EXITMENULOOP : //0x0212 685 strcpy (msgname, "WM_EXITMENULOOP"); 686 break; 687 688 case WM_NEXTMENU : //0x0213 689 strcpy (msgname, "WM_NEXTMENU"); 690 break; 691 692 case WM_SIZING : //0x0214 693 strcpy (msgname, "WM_SIZING"); 694 break; 695 696 case WM_CAPTURECHANGED : //0x0215 697 strcpy (msgname, "WM_CAPTURECHANGED"); 698 break; 699 700 case WM_MOVING : //0x0216 701 strcpy (msgname, "WM_MOVING"); 702 break; 703 704 case WM_POWERBROADCAST : //0x0218 705 strcpy (msgname, "WM_POWERBROADCAST"); 706 break; 707 708 case WM_DEVICECHANGE : //0x0219 709 strcpy (msgname, "WM_DEVICECHANGE"); 710 break; 711 712 713 case WM_IME_SETCONTEXT : //0x0281 714 strcpy (msgname, "WM_IME_SETCONTEXT"); 715 break; 716 717 case WM_IME_NOTIFY : //0x0282 718 strcpy (msgname, "WM_IME_NOTIFY"); 719 break; 720 721 case WM_IME_CONTROL : //0x0283 722 strcpy (msgname, "WM_IME_CONTROL"); 723 break; 724 725 case WM_IME_COMPOSITIONFULL : //0x0284 726 strcpy (msgname, "WM_IME_COMPOSITIONFULL"); 727 break; 728 729 case WM_IME_SELECT : //0x0285 730 strcpy (msgname, "WM_IME_SELECT"); 731 break; 732 733 case WM_IME_CHAR : //0x0286 734 strcpy (msgname, "WM_IME_CHAR"); 735 break; 736 737 case WM_IME_KEYDOWN : //0x0290 738 strcpy (msgname, "WM_IME_KEYDOWN"); 739 break; 740 741 case WM_IME_KEYUP : //0x0291 742 strcpy (msgname, "WM_IME_KEYUP"); 743 break; 744 745 case WM_MDICREATE : //0x0220 746 strcpy (msgname, "WM_MDICREATE"); 747 break; 748 749 case WM_MDIDESTROY : //0x0221 750 strcpy (msgname, "WM_MDIDESTROY"); 751 break; 752 753 case WM_MDIACTIVATE : //0x0222 754 strcpy (msgname, "WM_MDIACTIVATE"); 755 break; 756 757 case WM_MDIRESTORE : //0x0223 758 strcpy (msgname, "WM_MDIRESTORE"); 759 break; 760 761 case WM_MDINEXT : //0x0224 762 strcpy (msgname, "WM_MDINEXT"); 763 break; 764 765 case WM_MDIMAXIMIZE : //0x0225 766 strcpy (msgname, "WM_MDIMAXIMIZE"); 767 break; 768 769 case WM_MDITILE : //0x0226 770 strcpy (msgname, "WM_MDITILE"); 771 break; 772 773 case WM_MDICASCADE : //0x0227 774 strcpy (msgname, "WM_MDICASCADE"); 775 break; 776 777 case WM_MDIICONARRANGE : //0x0228 778 strcpy (msgname, "WM_MDIICONARRANGE"); 779 break; 780 781 case WM_MDIGETACTIVE : //0x0229 782 strcpy (msgname, "WM_MDIGETACTIVE"); 783 break; 784 785 case WM_MDISETMENU : //0x0230 786 strcpy (msgname, "WM_MDISETMENU"); 787 break; 788 789 case WM_ENTERSIZEMOVE : //0x0231 790 strcpy (msgname, "WM_ENTERSIZEMOVE"); 791 break; 792 793 case WM_EXITSIZEMOVE : //0x0232 794 strcpy (msgname, "WM_EXITSIZEMOVE"); 795 break; 796 797 case WM_DROPFILES : //0x0233 798 strcpy (msgname, "WM_DROPFILES"); 799 break; 800 801 case WM_MDIREFRESHMENU : //0x0234 802 strcpy (msgname, "WM_MDIREFRESHMENU"); 803 break; 804 805 // case WM_MOUSEHOVER : //0x02A1 806 // strcpy (msgname, "WM_MOUSEHOVER"); 807 // break; 808 809 // case WM_MOUSELEAVE : //0x02A3 810 // strcpy (msgname, "WM_MOUSELEAVE"); 811 // break; 812 813 case WM_CUT : //0x0300 814 strcpy (msgname, "WM_CUT"); 815 break; 816 817 case WM_COPY : //0x0301 818 strcpy (msgname, "WM_COPY"); 819 break; 820 821 case WM_PASTE : //0x0302 822 strcpy (msgname, "WM_PASTE"); 823 break; 824 825 case WM_CLEAR : //0x0303 826 strcpy (msgname, "WM_CLEAR"); 827 break; 828 829 case WM_UNDO : //0x0304 830 strcpy (msgname, "WM_UNDO"); 831 break; 832 833 case WM_RENDERFORMAT : //0x0305 834 strcpy (msgname, "WM_RENDERFORMAT"); 835 break; 836 837 case WM_RENDERALLFORMATS : //0x0306 838 strcpy (msgname, "WM_RENDERALLFORMATS"); 839 break; 840 841 case WM_DESTROYCLIPBOARD : //0x0307 842 strcpy (msgname, "WM_DESTROYCLIPBOARD"); 843 break; 844 845 case WM_DRAWCLIPBOARD : //0x0308 846 strcpy (msgname, "WM_DRAWCLIPBOARD"); 847 break; 848 849 case WM_PAINTCLIPBOARD : //0x0309 850 strcpy (msgname, "WM_PAINTCLIPBOARD"); 851 break; 852 853 case WM_VSCROLLCLIPBOARD : //0x030A 854 strcpy (msgname, "WM_VSCROLLCLIPBOARD"); 855 break; 856 857 case WM_SIZECLIPBOARD : //0x030B 858 strcpy (msgname, "WM_SIZECLIPBOARD"); 859 break; 860 861 case WM_ASKCBFORMATNAME : //0x030C 862 strcpy (msgname, "WM_ASKCBFORMATNAME"); 863 break; 864 865 case WM_CHANGECBCHAIN : //0x030D 866 strcpy (msgname, "WM_CHANGECBCHAIN"); 867 break; 868 869 case WM_HSCROLLCLIPBOARD : //0x030E 870 strcpy (msgname, "WM_HSCROLLCLIPBOARD"); 871 break; 872 873 case WM_QUERYNEWPALETTE : //0x030F 874 strcpy (msgname, "WM_QUERYNEWPALETTE"); 875 break; 876 877 case WM_PALETTEISCHANGING : //0x0310 878 strcpy (msgname, "WM_PALETTEISCHANGING"); 879 break; 880 881 case WM_PALETTECHANGED : //0x0311 882 strcpy (msgname, "WM_PALETTECHANGED"); 883 break; 884 885 case WM_HOTKEY : //0x0312 886 strcpy (msgname, "WM_HOTKEY"); 887 break; 888 889 case WM_PRINT : //0x0317 890 strcpy (msgname, "WM_PRINT"); 891 break; 892 893 case WM_PRINTCLIENT : //0x0318 894 strcpy (msgname, "WM_PRINTCLIENT"); 895 break; 896 897 case WM_HANDHELDFIRST : //0x0358 898 strcpy (msgname, "WM_HANDHELDFIRST"); 899 break; 900 901 case WM_HANDHELDLAST : //0x035F 902 strcpy (msgname, "WM_HANDHELDLAST"); 903 break; 904 905 case WM_AFXFIRST : //0x0360 906 strcpy (msgname, "WM_AFXFIRST"); 907 break; 908 909 case WM_AFXLAST : //0x037F 910 strcpy (msgname, "WM_AFXLAST"); 911 break; 912 913 case WM_PENWINFIRST : //0x0380 914 strcpy (msgname, "WM_PENWINFIRST"); 915 break; 916 917 case WM_PENWINLAST : //0x038F 918 strcpy (msgname, "WM_PENWINLAST"); 919 break; 920 921 default: 922 strcpy (msgname, "Unknown Message"); 923 break; 924 } 925 } 926 927 928 void MESSAGEENDER (short x) 929 { 930 char msgname[100]; 931 char msgname2[100]; 932 UINT msg; 933 934 switch (x) 935 { 936 case true: 937 strcpy (msgname, "Exit Message: TRUE"); 938 break; 939 940 case false: 941 strcpy (msgname, "Exit Message: FALSE"); 942 break; 943 944 case MSGDEFAULT: 945 strcpy (msgname, "Exit Message: Default"); 946 break; 947 948 case MSGOTHER: 949 strcpy (msgname, "Exit Message: Other"); 950 break; 951 952 default: 953 strcpy (msgname, "Exit Message: UNKNOWN"); 954 break; 955 } 956 957 msg = POPMESSAGE(); 958 959 GETMESSAGETEXT (msg, msgname2); 960 961 fprintf (errfile, "%s\t%s\n", msgname, msgname2); 962 } 963 964 void MESSAGETRACKER (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { 965 char msgname[100]; 966 967 if (errfile == NULL) 968 { 969 errfile = fopen ("errfile.txt", "w+"); 970 } 971 972 GETMESSAGETEXT (msg, msgname); 973 974 fprintf (errfile, "Message: %-30s (%ld)\t\t Window: %lX\twParam: %lX\tlParam: %lX\n", 975 msgname, msg, hwnd, wParam, lParam); 976 977 PUSHMESSAGE (msg); 978 } 979 #else 980 #define MESSAGETRACKER(a,b,c,d) 981 #define MESSAGEENDER(x) 982 #endif 983 984 985 static boolean ccerrormessage (bigstring bs) { 986 987 char s [256]; 988 short itemnumber; 989 990 copyptocstring (bs, s); 991 992 itemnumber = MessageBox (hwndMDIClient, s, "Error Info", MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL); 993 994 return (true); 995 } /*ccerrormessage*/ 996 997 998 static boolean shellpushcancoonglobals (void) { 999 1000 short ix; 1001 1002 if (!shellfindcallbacks (idcancoonconfig, &ix)) 1003 return (false); 1004 1005 if (!shellpushglobals (nil)) /*save off old state*/ 1006 return (false); 1007 1008 shellglobals = globalsarray [ix]; 1009 1010 config = shellglobals.config; 1011 1012 return (true); 1013 } /*shellpushcancoonglobals*/ 1014 1015 1016 extern long getstatusbarheight () { 1017 /* 2005-01-30 SMD - made extern */ 1018 RECT rectStatus; 1019 1020 if (hwndStatus != NULL) { 1021 GetWindowRect(hwndStatus, &rectStatus); 1022 1023 return (rectStatus.bottom - rectStatus.top); 1024 } 1025 1026 return (0); 1027 } /*getstatusbarheight*/ 1028 1029 static long getstatusbarwidth () { 1030 RECT rectStatus; 1031 1032 if (hwndStatus != NULL) { 1033 GetWindowRect(hwndStatus, &rectStatus); 1034 1035 return (rectStatus.right - rectStatus.left); 1036 } 1037 1038 return (0); 1039 } /*getstatusbarwidth*/ 1040 1041 static boolean setstatusbartext (char * szText, long partNumber) { 1042 if (hwndStatus != NULL) { 1043 return ((boolean) SendMessage(hwndStatus, SB_SETTEXT, (WPARAM) partNumber, (LPARAM) (LPSTR) szText)); 1044 } 1045 return (false); 1046 } /*setstatusbartext*/ 1047 1048 boolean setstatusbarstring (bigstring bs, long partNumber) { 1049 boolean res; 1050 1051 nullterminate (bs); 1052 1053 releasethreadglobals(); 1054 1055 res = setstatusbartext (stringbaseaddress(bs), partNumber); 1056 1057 grabthreadglobals(); 1058 1059 return (res); 1060 } /*setstatusbarstring*/ 1061 1062 1063 boolean getstatusbarstring (bigstring bs, long partNumber) { 1064 boolean res; 1065 unsigned long longres; 1066 1067 res = true; 1068 1069 releasethreadglobals(); 1070 1071 if (hwndStatus != NULL) { 1072 longres = SendMessage(hwndStatus, SB_GETTEXT, (WPARAM) partNumber, (LPARAM) (LPSTR) stringbaseaddress(bs)); 1073 } 1074 1075 grabthreadglobals(); 1076 1077 setstringlength (bs, LOWORD(longres)); 1078 1079 return (res); 1080 } /*getstatusbarstring*/ 1081 1082 1083 static boolean setDefinedStatusBarParts (long width) { 1084 int aWidths[50]; 1085 int dec, i; 1086 int borders[4]; 1087 1088 if (hwndStatus != NULL) { 1089 SendMessage(hwndStatus, SB_GETBORDERS, 0, (LPARAM) borders); 1090 1091 // width = width - borders[1] - borders[1]; /*Account for vertical width*/ 1092 1093 aWidths[gstatuswindowparts-1] = -1; 1094 dec = gstatuswindowarray[gstatuswindowparts-1] + 13 + (borders[1]*2); 1095 1096 for (i = gstatuswindowparts-2; i >= 0; i--) { 1097 aWidths[i] = width - dec; 1098 dec = dec + gstatuswindowarray[i]; 1099 } 1100 1101 return ((boolean)SendMessage (hwndStatus, SB_SETPARTS, (WPARAM) gstatuswindowparts, (LPARAM)aWidths)); 1102 } 1103 1104 return (false); 1105 } 1106 1107 boolean setstatusbarparts (long count, long * array) { 1108 int i; 1109 boolean res; 1110 1111 for (i = 0; i < count; i++) { 1112 gstatuswindowarray[i] = array[i]; 1113 } 1114 1115 gstatuswindowparts = count; 1116 1117 releasethreadglobals(); 1118 1119 res = setDefinedStatusBarParts (getstatusbarwidth()); 1120 1121 grabthreadglobals(); 1122 1123 return (res); 1124 } /*setstatusbarparts*/ 1125 1126 1127 long getstatusbarparts (long * array) { 1128 int i; 1129 long res; 1130 int aWidths[50]; 1131 RECT r; 1132 long prior; 1133 1134 releasethreadglobals(); 1135 1136 res = SendMessage (hwndStatus, SB_GETPARTS, (WPARAM) 50, (LPARAM)aWidths); 1137 1138 if (res > 0) { 1139 SendMessage (hwndStatus, SB_GETRECT, (WPARAM) res - 1, (LPARAM) &r); 1140 } 1141 1142 grabthreadglobals(); 1143 1144 1145 prior = 0; 1146 1147 for (i = 0; i < res; i++) { 1148 if (aWidths[i] != -1) 1149 array[i] = aWidths[i] - prior; 1150 else 1151 array[i] = r.right-r.left; 1152 1153 prior = aWidths[i]; 1154 } 1155 1156 return (res); 1157 } /*getstatusbarparts*/ 1158 1159 1160 1161 1162 1163 1164 WNDPROC wndprocMDIClient; 1165 1166 LONG CALLBACK FrontierMDIWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { 1167 1168 1169 switch (msg){ 1170 case WM_WINDOWPOSCHANGING: 1171 { 1172 WINDOWPOS * wp; 1173 1174 if (hwndMDIClient != NULL) { 1175 1176 if (hwnd == hwndMDIClient) { 1177 1178 wp = (WINDOWPOS *) lParam; 1179 1180 wp->cy = wp->cy - getstatusbarheight(); 1181 } 1182 } 1183 1184 return (CallWindowProc (wndprocMDIClient, hwnd, msg, wParam, lParam)); 1185 1186 } 1187 1188 #if (FRONTIERWEB == 1) 1189 case WM_NCCALCSIZE: 1190 { 1191 LPNCCALCSIZE_PARAMS lp; 1192 long res; 1193 HWND tophwnd; 1194 int flNoMaxedWindow; 1195 1196 res = CallWindowProc (wndprocMDIClient, hwnd, msg, wParam, lParam); 1197 1198 //RAB 2/21/2001: If there is a maxed window do not size HTML control 1199 flNoMaxedWindow = true; 1200 1201 tophwnd = GetTopWindow (hwndMDIClient); 1202 1203 if (IsZoomed (tophwnd)) { 1204 flNoMaxedWindow = false; 1205 } 1206 1207 if (wParam && flNoMaxedWindow) { 1208 lp = (LPNCCALCSIZE_PARAMS) lParam; 1209 1210 SetWindowPos (hwndHTMLControl, HWND_BOTTOM, 0, 0, lp->rgrc[0].right, lp->rgrc[0].bottom, 0); 1211 } 1212 1213 return (res); 1214 } 1215 1216 case WM_SIZE: 1217 { 1218 HWND tophwnd; 1219 1220 if (hwndHTMLControl != NULL) { 1221 //RAB 2/21/2001: If there is a maxed window do not size HTML control 1222 tophwnd = GetTopWindow (hwndMDIClient); 1223 1224 if (! IsZoomed (tophwnd)) { 1225 SetWindowPos (hwndHTMLControl, HWND_BOTTOM, 0, 0, LOWORD(lParam), HIWORD (lParam), 0); 1226 } 1227 } 1228 break; 1229 } 1230 1231 case WM_VSCROLL: 1232 case WM_HSCROLL: 1233 { 1234 RECT r; 1235 1236 if (hwndHTMLControl != NULL) { 1237 1238 // GetClientRect (shellframewindow, &r); 1239 GetClientRect (hwndMDIClient, &r); 1240 1241 SetWindowPos (hwndHTMLControl, HWND_BOTTOM, 0, 0, r.right, r.bottom, SWP_NOSIZE | SWP_NOZORDER); 1242 } 1243 break; 1244 } 1245 #endif 1246 } 1247 return (CallWindowProc (wndprocMDIClient, hwnd, msg, wParam, lParam)); 1248 1249 } 1250 1251 1252 1253 1254 1255 static boolean registerChildWindowClass (short idicon, CHAR *classname) { 1256 1257 WNDCLASS wc; 1258 wc.style = CS_DBLCLKS; 1259 // wc.style = CS_OWNDC; 1260 wc.lpfnWndProc = (WNDPROC) FrontierOPWndProc; 1261 wc.cbClsExtra = 0; 1262 wc.cbWndExtra = OPWindowExtraByteCount; 1263 wc.hInstance = hInst; 1264 wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(idicon)); 1265 wc.hCursor = NULL; // 5.0a8 dmb - was: LoadCursor(NULL,IDC_ARROW); 1266 wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); 1267 wc.lpszMenuName = NULL; 1268 wc.lpszClassName = classname; 1269 1270 return (RegisterClass(&wc) != 0); 1271 } /*registerChildWindowClass*/ 1272 1273 static boolean registerHTMLChildWindowClass () { 1274 1275 WNDCLASS wc; 1276 wc.style = CS_DBLCLKS; 1277 wc.lpfnWndProc = (WNDPROC) htmlControlWndProc; 1278 wc.cbClsExtra = 0; 1279 wc.cbWndExtra = OPWindowExtraByteCount; 1280 wc.hInstance = hInst; 1281 wc.hIcon = NULL; 1282 wc.hCursor = NULL; 1283 wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); 1284 wc.lpszMenuName = NULL; 1285 wc.lpszClassName = szChildHTML; 1286 1287 return (RegisterClass(&wc) != 0); 1288 } /*registerHTMLChildWindowClass*/ 1289 1290 1291 BOOL InitializeApplication() { 1292 1293 WNDCLASS wc; 1294 char bsfatfile [] = "\x0c" "Fatpage_File"; 1295 char bsfrontierdoc [] = "\x18" "Frontier Document [FATP]"; 1296 tyfilespec fs; 1297 bigstring bsopen; 1298 1299 getapplicationfilespec (NULL, &fs); 1300 1301 copystring (fsname (&fs), bsopen); 1302 1303 pushstring ("\x04 %1\0", bsopen); 1304 1305 #ifdef PIKE /*7.0b24 PBS -- register OPML file type and icon.*/ 1306 1307 registerFileType ("\x05" ".opml", "\x04" "OPML", "\x0b" "text/x-opml", "\x1c" "Radio UserLand OPML Document", fsname(&fs), -1 * ID_OPML_ICON, bsopen); 1308 1309 #else 1310 registerFileType ("\x04" ".fat", bsfatfile, "\x09" "text/fatp", bsfrontierdoc, fsname(&fs), -1 * ID_FATPAGE_ICON, bsopen); 1311 registerFileType ("\x05" ".fatp", bsfatfile, "\x09" "text/fatp", NULL, NULL, -1 * ID_FATPAGE_ICON, NULL); 1312 registerFileType ("\x05" ".root", "\x0c" "FrontierRoot", NULL, "\x18" "Frontier Object Database", fsname(&fs), -1 * ID_ROOT_ICON, bsopen); 1313 registerFileType ("\x05" ".2clk", "\x0c" "Frontier2Clk", NULL, "\x17" "Frontier Desktop Script", fsname(&fs), -1 * ID_2CLK_ICON, bsopen); 1314 1315 registerFileType ("\x05" ".FTwp", "\x0a" "FrontierWP", NULL, "\x14" "Frontier WP Document", fsname(&fs), -1 * ID_WP_ICON, bsopen); 1316 registerFileType ("\x05" ".FTop", "\x0f" "FrontierOutline", NULL, "\x10" "Frontier Outline", fsname(&fs), -1 * ID_OP_ICON, bsopen); 1317 registerFileType ("\x05" ".FTsc", "\x0e" "FrontierScript", NULL, "\x0f" "Frontier Script", fsname(&fs), -1 * ID_SCRIPT_ICON, bsopen); 1318 registerFileType ("\x05" ".FTmb", "\x0c" "FrontierMenu", NULL, "\x0d" "Frontier Menu", fsname(&fs), -1 * ID_MENU_ICON, bsopen); 1319 registerFileType ("\x05" ".FTtb", "\x0d" "FrontierTable", NULL, "\x0e" "Frontier Table", fsname(&fs), -1 * ID_TABLE_ICON, bsopen); 1320 registerFileType ("\x05" ".FTds", "\x15" "FrontierDesktopScript", NULL, "\x17" "Frontier Desktop Script", fsname(&fs), -1 * ID_DESKTOPSCRIPT_ICON, bsopen); 1321 #endif 1322 1323 /* 9/24/01 RAB */ 1324 hIconApp = LoadIcon(hInst,MAKEINTRESOURCE(ID_FRONTIER_ICON)); 1325 1326 //#ifdef PIKE 1327 hTrayIconApp = LoadIcon(hInst,MAKEINTRESOURCE(ID_FRONTIERTRAY_ICON)); 1328 //#endif 1329 1330 1331 /* Register the frame class */ 1332 wc.style = CS_DBLCLKS; 1333 wc.lpfnWndProc = (WNDPROC) FrontierFrameWndProc; 1334 wc.cbClsExtra = 0; 1335 wc.cbWndExtra = 4; 1336 wc.hInstance = hInst; 1337 wc.hIcon = hIconApp; 1338 wc.hCursor = NULL; // 5.0a8 dmb - was: LoadCursor(NULL,IDC_ARROW); 1339 wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1); 1340 wc.lpszMenuName = IDMULTIPAD; 1341 wc.lpszClassName = szFrame; 1342 1343 if (!RegisterClass (&wc) ) 1344 return (FALSE); 1345 1346 /* Register the MDI child classes */ /*7.0fc1 PBS: use Frontier icon*/ 1347 if (!registerChildWindowClass (/*ID_NOTE_ICON*/ ID_FRONTIER_ICON, szChild1)) /*Class for generic windows (About, QuickScript).*/ 1348 return (false); 1349 1350 if (!registerChildWindowClass (ID_OP_ICON, szChildFTop)) 1351 return (false); 1352 1353 if (!registerChildWindowClass (ID_WP_ICON, szChildFTwp)) 1354 return (false); 1355 1356 if (!registerChildWindowClass (ID_TABLE_ICON, szChildFTtb)) 1357 return (false); 1358 1359 if (!registerChildWindowClass (ID_MENU_ICON, szChildFTmb)) 1360 return (false); 1361 1362 if (!registerChildWindowClass (ID_SCRIPT_ICON, szChildFTsc)) 1363 return (false); 1364 1365 if (!registerChildWindowClass (ID_ROOT_ICON, szChildRoot)) 1366 return (false); 1367 1368 registerHTMLChildWindowClass (); 1369 1370 return TRUE; 1371 } /*InitializeApplication*/ 1372 1373 /* 1374 static void showenv (void) { 1375 1376 LPTSTR lpszVariable; 1377 LPVOID lpvEnv; 1378 1379 // Get a pointer to the environment block. 1380 1381 lpvEnv = GetEnvironmentStrings(); 1382 1383 // Variable strings are separated by NULL byte, and the block is 1384 // terminated by a NULL byte. 1385 1386 for (lpszVariable = (LPTSTR) lpvEnv; *lpszVariable; lpszVariable++) 1387 { 1388 while (*lpszVariable) 1389 putchar(*lpszVariable++); 1390 putchar('\n'); 1391 } 1392 1393 FreeEnvironmentStrings (lpvEnv); //2003-05-18 AR 1394 }*/ /*showenv*/ 1395 1396 1397 /**************************************************************************** 1398 * * 1399 * FUNCTION : InitializeInstance () * 1400 * * 1401 * PURPOSE : Performs a per-instance initialization of Frontier. It * 1402 * also creates the frame and an MDI window. * 1403 * * 1404 * RETURNS : TRUE - If initialization was successful. * 1405 * FALSE - otherwise. * 1406 * * 1407 ****************************************************************************/ 1408 BOOL InitializeInstance(LPSTR lpCmdLine, INT nCmdShow) 1409 { 1410 extern HWND hwndMDIClient; 1411 CHAR sz[80]; 1412 HDC hdc; 1413 HMENU hmenu; 1414 unsigned long x, y, nWidth, nHeight; 1415 DWORD style; 1416 1417 #if FRONTIERWEB == 1 1418 bigstring bsresult; 1419 char * initialURL; 1420 RECT r; 1421 #endif 1422 1423 /* Get the base window title */ 1424 LoadString (hInst, IDS_APPNAME, sz, sizeof(sz)); 1425 1426 //showenv (); /*2003-05-18 AR: this is debugging code, commented out*/ 1427 1428 if (! getProfileLong ("\x06" "FrameX", &x)) 1429 x = CW_USEDEFAULT; 1430 1431 if (! getProfileLong ("\x06" "FrameY", &y)) 1432 x = CW_USEDEFAULT; //yes X; y will be ignored 1433 1434 if (! getProfileLong ("\x06" "FrameW", &nWidth)) 1435 nWidth = CW_USEDEFAULT; 1436 1437 if (! getProfileLong ("\x06" "FrameH", &nHeight)) 1438 nWidth = CW_USEDEFAULT; //yes nWidth; nHeight will be ignored 1439 1440 if (getProfileLong ("\x0a" "FrameStyle", &style)) 1441 nCmdShow = style; 1442 else 1443 style = 0; 1444 1445 //#ifdef PIKE 1446 nCmdShow = SW_HIDE; /* 9/24/01 RAB */ 1447 //#endif 1448 1449 style = style | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; 1450 1451 /* If the command line string is empty, nullify the pointer to it 1452 ** else copy command line into our data segment 1453 */ 1454 if ( lpCmdLine && !(*lpCmdLine)) 1455 pCmdLine = NULL; 1456 else { 1457 pCmdLine = (CHAR *) LocalAlloc(LPTR, lstrlen(lpCmdLine) + 1); 1458 if (pCmdLine) 1459 lstrcpy(pCmdLine, lpCmdLine); 1460 } 1461 1462 /* Create the frame */ 1463 shellframewindow = CreateWindow (szFrame, 1464 sz, 1465 style, 1466 x, 1467 y, 1468 nWidth, 1469 nHeight, 1470 NULL, 1471 NULL, 1472 hInst, 1473 NULL); 1474 1475 if ((!shellframewindow) || (!hwndMDIClient)) 1476 return FALSE; 1477 1478 DeleteMenu (GetMenu (shellframewindow), 0, MF_BYPOSITION); // destroy the dummy menu 1479 1480 /* Load main menu accelerators */ 1481 if (!(hAccel = LoadAccelerators (hInst, IDMULTIPAD))) 1482 return FALSE; 1483 1484 // Do the Frontier/Shell startup 1485 if (!shellinit ()) 1486 return (false); 1487 1488 langipcself = getcurrentprocessid(); 1489 1490 grabthreadglobals (); 1491 1492 if (!frontierstart ()) { 1493 1494 shellshutdown (); 1495 1496 return (false); 1497 } 1498 1499 findreplacewindow = NULL; /*just ensure that this is NULL */ 1500 1501 1502 wndprocMDIClient = (WNDPROC) SetWindowLong (hwndMDIClient, GWL_WNDPROC, (long)FrontierMDIWndProc); 1503 1504 #if (FRONTIERWEB==1) 1505 GetClientRect (shellframewindow, &r); 1506 1507 hwndHTMLControl = CreateMDIWindow (szChildHTML, NULL, WS_CHILD , 0, 0, 1508 r.right, r.bottom, hwndMDIClient, hInst, 0); 1509 1510 if (langrunstringnoerror ("\x26" "system.callbacks.htmlControlStartup ()", bsresult)) { /*7.0b39 PBS: call system.callbacks.htmlControlStartup*/ 1511 nullterminate (bsresult); 1512 initialURL = bsresult+1; 1513 } 1514 else { 1515 initialURL = "about:blank"; 1516 } 1517 1518 /* 1519 hwndStatus = GetDlgItem(m_hwnd, ID_STATUSBAR); 1520 GetWindowRect(hwndStatus, &rectStatus); 1521 statusHeight = rectStatus.bottom - rectStatus.top; 1522 MoveWindow( hwndStatus, 1523 0, 1524 height - statusHeight, 1525 width, 1526 statusHeight, 1527 TRUE); 1528 1529 if(m_pContainer) 1530 m_pContainer->setLocation(0, 0, width, height-statusHeight); 1531 */ 1532 1533 if ((*(gwebappInfo.webappSetup))(hInst, hwndHTMLControl, hwndStatus, initialURL)) 1534 gwebappInfo.flactive = true; 1535 1536 #endif 1537 1538 /* Display the frame window */ 1539 ShowWindow (shellframewindow, nCmdShow); 1540 UpdateWindow (shellframewindow); 1541 1542 // ShowWindow (hwndHTMLControl, nCmdShow); 1543 ShowWindow (hwndHTMLControl, SW_SHOWNOACTIVATE); /*7.0 RAB: fix for minimized HTML control window*/ 1544 1545 UpdateWindow (hwndHTMLControl); 1546 1547 /* if we allocated a buffer then free it */ 1548 if (pCmdLine) { 1549 1550 LocalFree((LOCALHANDLE) pCmdLine); 1551 1552 pCmdLine = NULL; 1553 } 1554 1555 releasethreadglobals (); 1556 1557 flinstanceinitialized = true; 1558 1559 return TRUE; 1560 UNREFERENCED_PARAMETER(hmenu); 1561 UNREFERENCED_PARAMETER(hdc); 1562 } /*InitializeInstance*/ 1563 1564 1565 1566 BOOL WinProcessMouseEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1567 { 1568 EventRecord ev; 1569 POINT winpt; 1570 1571 ev.hwnd = hwnd; 1572 ev.winmsg = msg; 1573 ev.wparam = wParam; 1574 ev.lparam = lParam; 1575 ev.part = HTCLIENT; 1576 1577 ev.message = (long) hwnd; 1578 ev.when = gettickcount (); 1579 1580 switch (msg) { 1581 case WM_LBUTTONDOWN: 1582 case WM_LBUTTONDBLCLK: 1583 ev.what = mouseDown; 1584 ev.where.h = LOWORD(lParam); 1585 ev.where.v = HIWORD(lParam); 1586 ev.modifiers = wParam; 1587 break; 1588 1589 case WM_RBUTTONDOWN: 1590 case WM_RBUTTONDBLCLK: 1591 ev.what = rmouseDown; 1592 ev.where.h = LOWORD(lParam); 1593 ev.where.v = HIWORD(lParam); 1594 ev.modifiers = wParam; 1595 break; 1596 1597 case WM_MBUTTONDOWN: 1598 case WM_MBUTTONDBLCLK: 1599 ev.what = cmouseDown; 1600 ev.where.h = LOWORD(lParam); 1601 ev.where.v = HIWORD(lParam); 1602 ev.modifiers = wParam; 1603 break; 1604 1605 case WM_NCLBUTTONDOWN: 1606 case WM_NCLBUTTONDBLCLK: 1607 ev.what = mouseDown; 1608 ev.part = wParam; 1609 1610 winpt.x = LOWORD(lParam); 1611 winpt.y = HIWORD(lParam); 1612 1613 ScreenToClient (hwnd, &winpt); 1614 1615 ev.where.h = (short) winpt.x; 1616 ev.where.v = (short) winpt.y; 1617 1618 ev.modifiers = 0; 1619 break; 1620 1621 case WM_NCRBUTTONDOWN: 1622 case WM_NCRBUTTONDBLCLK: 1623 ev.what = rmouseDown; 1624 ev.part = wParam; 1625 1626 winpt.x = LOWORD(lParam); 1627 winpt.y = HIWORD(lParam); 1628 1629 ScreenToClient (hwnd, &winpt); 1630 1631 ev.where.h = (short) winpt.x; 1632 ev.where.v = (short) winpt.y; 1633 1634 ev.modifiers = 0; 1635 break; 1636 1637 case WM_NCMBUTTONDOWN: 1638 case WM_NCMBUTTONDBLCLK: 1639 ev.what = cmouseDown; 1640 ev.part = wParam; 1641 1642 winpt.x = LOWORD(lParam); 1643 winpt.y = HIWORD(lParam); 1644 1645 ScreenToClient (hwnd, &winpt); 1646 1647 ev.where.h = (short) winpt.x; 1648 ev.where.v = (short) winpt.y; 1649 1650 ev.modifiers = 0; 1651 break; 1652 1653 default: 1654 ev.what = mouseDown; 1655 ev.where.h = LOWORD(lParam); 1656 ev.where.v = HIWORD(lParam); 1657 ev.modifiers = wParam; 1658 break; 1659 } 1660 1661 return (shellprocessevent (&ev)); 1662 } 1663 1664 BOOL WinProcessKeyboardEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1665 { 1666 EventRecord ev; 1667 1668 ev.hwnd = hwnd; 1669 ev.winmsg = msg; 1670 ev.wparam = wParam; 1671 ev.lparam = lParam; 1672 ev.part = HTCLIENT; 1673 1674 ev.what = keyDown; 1675 ev.message = wParam; 1676 ev.when = gettickcount (); 1677 ev.where.h = 0; 1678 ev.where.v = 0; 1679 ev.modifiers = lParam; 1680 return (shellprocessevent (&ev)); 1681 } 1682 1683 BOOL WinProcessPaintEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1684 { 1685 EventRecord ev; 1686 1687 ev.hwnd = hwnd; 1688 ev.winmsg = msg; 1689 ev.wparam = wParam; 1690 ev.lparam = lParam; 1691 ev.part = HTCLIENT; 1692 1693 ev.what = updateEvt; 1694 ev.message = (long) hwnd; 1695 ev.when = gettickcount (); 1696 ev.where.h = 0; 1697 ev.where.v = 0; 1698 ev.modifiers = wParam; 1699 return (shellprocessevent (&ev)); 1700 } 1701 1702 BOOL WinProcessCommandEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1703 { 1704 EventRecord ev; 1705 1706 ev.hwnd = hwnd; 1707 ev.winmsg = msg; 1708 ev.wparam = wParam; 1709 ev.lparam = lParam; 1710 ev.part = HTCLIENT; 1711 1712 ev.what = menuEvt; 1713 ev.message = (long) hwnd; 1714 ev.when = gettickcount (); 1715 ev.where.h = 0; 1716 ev.where.v = 0; 1717 ev.modifiers = (((LOWORD(wParam) / 100) * 100) << 16) + (LOWORD(wParam)); 1718 1719 keyboardpeek (&keyboardstatus); 1720 1721 return (shellprocessevent (&ev)); 1722 } 1723 1724 BOOL WinProcessScrollEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, boolean isvert) 1725 { 1726 EventRecord ev; 1727 1728 ev.hwnd = hwnd; 1729 ev.winmsg = msg; 1730 ev.wparam = wParam; 1731 ev.lparam = lParam; 1732 ev.part = HTCLIENT; 1733 1734 ev.what = scrollEvt; 1735 ev.message = (long) hwnd; 1736 ev.when = gettickcount (); 1737 ev.where.h = HIWORD (wParam); 1738 ev.where.v = LOWORD (wParam); 1739 ev.modifiers = isvert; 1740 1741 keyboardpeek (&keyboardstatus); 1742 1743 return (shellprocessevent (&ev)); 1744 } 1745 1746 BOOL WinProcessActivateEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1747 { 1748 EventRecord ev; 1749 1750 ev.hwnd = hwnd; 1751 ev.winmsg = msg; 1752 ev.wparam = wParam; 1753 ev.lparam = lParam; 1754 ev.part = HTCLIENT; 1755 1756 ev.what = activateEvt; 1757 ev.message = (long) hwnd; 1758 ev.when = gettickcount (); 1759 ev.where.h = 0; 1760 ev.where.v = 0; 1761 if (GET_WM_MDIACTIVATE_FACTIVATE(hwnd, wParam, lParam)) 1762 ev.modifiers = activeFlag; 1763 else 1764 ev.modifiers = 0; 1765 1766 return (shellprocessevent (&ev)); 1767 } 1768 1769 BOOL WinProcessNCActivateEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1770 { 1771 EventRecord ev; 1772 1773 ev.hwnd = hwnd; 1774 ev.winmsg = msg; 1775 ev.wparam = wParam; 1776 ev.lparam = lParam; 1777 ev.part = HTCLIENT; 1778 1779 ev.what = activateEvt; 1780 ev.message = (long) hwnd; 1781 ev.when = gettickcount (); 1782 ev.where.h = 0; 1783 ev.where.v = 0; 1784 if (wParam) 1785 ev.modifiers = activeFlag; 1786 else 1787 ev.modifiers = 0; 1788 1789 return (shellprocessevent (&ev)); 1790 } /*WinProcessNCActivateEvent*/ 1791 1792 1793 BOOL WinProcessActivateAppEvent (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { 1794 1795 /* 1796 5.0a22 dmb: added 1797 */ 1798 1799 EventRecord ev; 1800 tyjugglermessage jmsg; 1801 1802 ev.hwnd = hwnd; 1803 ev.winmsg = msg; 1804 ev.wparam = wParam; 1805 ev.lparam = lParam; 1806 1807 *((long *)&jmsg) = 0; 1808 jmsg.eventtype = 1; 1809 jmsg.flresume = (BOOL) wParam; 1810 1811 ev.what = jugglerEvt; 1812 ev.message = *(long *) &jmsg; 1813 ev.when = gettickcount (); 1814 ev.where.h = 0; 1815 ev.where.v = 0; 1816 1817 return (shellprocessevent (&ev)); 1818 } /*WinProcessActivateAppEvent*/ 1819 1820 1821 static BOOL WinMapSpecialKey (WPARAM *wParam) { 1822 1823 switch (*wParam) { 1824 1825 case VK_LEFT: 1826 *wParam = chleftarrow; 1827 break; 1828 1829 case VK_RIGHT: 1830 *wParam = chrightarrow; 1831 break; 1832 1833 case VK_UP: 1834 *wParam = chuparrow; 1835 break; 1836 1837 case VK_DOWN: 1838 *wParam = chdownarrow; 1839 break; 1840 1841 case VK_PRIOR: 1842 *wParam = chpageup; 1843 break; 1844 1845 case VK_NEXT: 1846 *wParam = chpagedown; 1847 break; 1848 1849 case VK_HOME: 1850 *wParam = chhome; 1851 break; 1852 1853 case VK_END: 1854 *wParam = chend; 1855 break; 1856 1857 case VK_INSERT: 1858 *wParam = chleftarrow; 1859 break; 1860 1861 case VK_DELETE: 1862 *wParam = chdelete; 1863 break; 1864 1865 case VK_F1: 1866 *wParam = chhelp; 1867 break; 1868 1869 case VK_F2: 1870 *wParam = chenter; 1871 break; 1872 1873 default: 1874 return FALSE; 1875 } 1876 1877 return TRUE; 1878 } /*WinMapSpecialKey*/ 1879 1880 1881 /**************************************************************************** 1882 * * 1883 * FUNCTION : QueryCloseAllChildren() * 1884 * * 1885 * PURPOSE : Asks the child windows if it is ok to close up app. Nothing* 1886 * is destroyed at this point. The z-order is not changed. * 1887 * * 1888 * RETURNS : TRUE - If all children agree to the query. * 1889 * FALSE- If any one of them disagrees. * 1890 * * 1891 ****************************************************************************/ 1892 1893 BOOL QueryCloseAllChildren() { 1894 boolean fl; 1895 1896 grabthreadglobals (); 1897 1898 keyboardpeek (&keyboardstatus); 1899 1900 fl = shellquit (); 1901 1902 releasethreadglobals (); 1903 1904 return (fl); 1905 } 1906 1907 1908 /**************************************************************************** 1909 * * 1910 * FUNCTION : QueryCloseChild (hwnd) * 1911 * * 1912 * PURPOSE : If the child MDI is unsaved, allow the user to save, not * 1913 * save, or cancel the close operation. * 1914 * * 1915 * RETURNS : TRUE - if user chooses save or not save, or if the file * 1916 * has not changed. * 1917 * FALSE - otherwise. * 1918 * * 1919 ****************************************************************************/ 1920 1921 BOOL QueryCloseChild(register HWND hwnd) 1922 { 1923 boolean fl; 1924 1925 grabthreadglobals (); 1926 1927 keyboardpeek (&keyboardstatus); 1928 1929 if (keyboardstatus.floptionkey) 1930 fl = shellcloseall (getfrontwindow (), true); 1931 else 1932 fl = shellclose (getfrontwindow (), true); 1933 1934 releasethreadglobals (); 1935 1936 return (fl); 1937 } 1938 1939 1940 1941 1942 LPSTR GetCmdLine (void) { 1943 1944 LPSTR lpCmdLine, lpT; 1945 1946 #if defined(_MAC) 1947 lpCmdLine = NULL; 1948 #else 1949 lpCmdLine = GetCommandLine(); 1950 #endif 1951 1952 // on Win32, lpCmdLine's first string includes its own name, remove this 1953 // to make it exactly like the windows command line. 1954 1955 if (*lpCmdLine) { 1956 lpT = strchr(lpCmdLine, ' '); // skip self name 1957 if (lpT) { 1958 lpCmdLine = lpT; 1959 while (*lpCmdLine == ' ') { 1960 lpCmdLine++; // skip spaces to end or first cmd 1961 } 1962 } 1963 else { 1964 lpCmdLine += strlen(lpCmdLine); // point to NULL 1965 } 1966 } 1967 return(lpCmdLine); 1968 } /*GetCmdLine*/ 1969 1970 1971 boolean openwindowsparamlinefiles (void) { 1972 1973 /* 1974 7.0b26 PBS: updated with two fixes from Bob: 1975 1976 1. Strip leading and trailing quotes in the path -- fixes Win2K bug. 1977 1978 2. Get full path name of file instead of 8.3 name -- fixes Win98/NT4 bug. 1979 1980 8.0b46: Deal with folder "" not found errors when person double-clicks on the 1981 app and it's already running. 1982 */ 1983 1984 bigstring bspath; 1985 bigstring bsnewfile; 1986 tyfilespec fs; 1987 short len; 1988 LPTSTR lpFilePart; 1989 char buffer[1001]; 1990 DWORD newLen; 1991 WIN32_FIND_DATA info; 1992 HANDLE hinfo; 1993 1994 if (pCmdLine) { 1995 1996 if (strcmpi (pCmdLine, "-Embedding") == 0) 1997 return (false); 1998 1999 copyctopstring (pCmdLine, bspath); 2000 2001 /*7.0b26: Delete leading and trailing quotes.*/ 2002 2003 if ((lastchar(bspath) == '"') && (getstringcharacter (bspath, 0) == '"')) { 2004 2005 setstringlength (bspath, stringlength(bspath) - 1); /*trailing "*/ 2006 2007 deletestring (bspath, 1, 1); /*leading "*/ 2008 } 2009 2010 len = stringlength (bspath); 2011 2012 if (len == 0) { /*8.0b46: user has double-clicked on the app icon*/ 2013 2014 bigstring bsresult; 2015 2016 grabthreadglobals (); 2017 2018 langrunstringnoerror ("\x28" "system.callbacks.systemTrayIcon2Click ()", bsresult); 2019 2020 releasethreadglobals (); 2021 2022 #ifndef PIKE 2023 ShowWindow (shellframewindow, SW_SHOW); /*Show the window.*/ 2024 2025 activateapplication (NULL); /*Bring to front*/ 2026 #endif 2027 2028 return (true); 2029 } /*if*/ 2030 2031 nullterminate (bspath); 2032 2033 /*7.0b26: Get full path name, not 8.3 name.*/ 2034 2035 newLen = GetFullPathName (stringbaseaddress(bspath), 1000, buffer, &lpFilePart); 2036 2037 if ((newLen > 0) && (newLen < 1000)) { 2038 hinfo = FindFirstFile (buffer, &info); 2039 2040 if (hinfo != INVALID_HANDLE_VALUE) { 2041 *lpFilePart = 0; 2042 copyctopstring (buffer, bspath); 2043 2044 copyctopstring (info.cFileName, bsnewfile); 2045 2046 pushstring (bsnewfile, bspath); 2047 2048 FindClose (hinfo); 2049 } 2050 } 2051 2052 pathtofilespec (bspath, &fs); 2053 2054 return (shellopenfile (&fs, false, nil)); 2055 } 2056 2057 return (false); 2058 } /*openwindowsparamlinefiles*/ 2059 2060 2061 /*boolean openwindowsparamlinefiles (void) { 2062 2063 bigstring bspath; 2064 tyfilespec fs; 2065 short len; 2066 boolean flquoteatbeginning = false; 2067 boolean flquoteatend = false; 2068 2069 if (pCmdLine) { 2070 2071 if (strcmpi (pCmdLine, "-Embedding") == 0) 2072 return (false); 2073 2074 copyctopstring (pCmdLine, bspath); 2075 2076 len = stringlength (bspath); 2077 2078 pathtofilespec (bspath, &fs); 2079 2080 return (shellopenfile (&fs, false, nil)); 2081 } 2082 2083 return (false); 2084 } /*openwindowsparamlinefiles*/ 2085 2086 /**************************************************************************** 2087 * * 2088 * FUNCTION : FrontierFrameWndProc (hwnd, msg, wParam, lParam ) * 2089 * * 2090 * PURPOSE : The window function for the "frame" window, which controls * 2091 * the menu and encompasses all the MDI child windows. Does * 2092 * the major part of the message processing. Specifically, in * 2093 * response to: * 2094 * * 2095 * WM_CREATE : Creates and displays the "frame". * 2096 * * 2097 * WM_INITMENU : Sets up the state of the menu. * 2098 * * 2099 * WM_WININICHANGE & : If default printer characteristics* 2100 * WM_DEVMODECHANGE have been changed, reinitialises * 2101 * printer DC. * 2102 * * 2103 * WM_COMMAND : Passes control to a command- * 2104 * handling function. * 2105 * * 2106 * WM_CLOSE : Quits the app. if all the child * 2107 * windows agree. * 2108 * * 2109 * WM_QUERYENDSESSION : Checks that all child windows * 2110 * agree to quit. * 2111 * * 2112 * WM_DESTROY : Destroys frame window and quits * 2113 * app. * 2114 * * 2115 ****************************************************************************/ 2116 LONG CALLBACK FrontierFrameWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { 2117 2118 /* 2119 5.0.2 dmb/rab: grabthreadglobals for frontieropenfile code 2120 2121 5.0.2b20 dmb: don't create new find/replace window if one is already open 2122 2123 5.1.5b7 dmb: don't accept frontieropenfile if we're not done initializing 2124 */ 2125 2126 if (msg == wm_frontieropenfile) { 2127 2128 if (lParam) { 2129 bigstring inputFile; 2130 int n; 2131 boolean flinitted = flinstanceinitialized; 2132 2133 getProfileString ("\x0b" "DeskTopFile", inputFile); 2134 2135 n = stringlength (inputFile); 2136 2137 pCmdLine = (CHAR *) LocalAlloc(LPTR, n + 1); 2138 2139 if (pCmdLine) { 2140 2141 if (flinitted) 2142 grabthreadglobals (); 2143 2144 copyptocstring (inputFile, pCmdLine); 2145 2146 activateapplication (NULL); 2147 2148 if (flinitted) 2149 openwindowsparamlinefiles (); 2150 2151 LocalFree((LOCALHANDLE) pCmdLine); 2152 2153 pCmdLine = NULL; 2154 2155 if (flinitted) 2156 releasethreadglobals (); 2157 } 2158 } 2159 2160 return 0; 2161 } 2162 2163 if (msg == wm_startsearch) { 2164 2165 if (findreplacewindow == NULL) 2166 findreplacewindow = FindText ((FINDREPLACE *) lParam); 2167 else 2168 windowbringtofront (findreplacewindow); 2169 2170 return (0); 2171 } 2172 2173 if (msg == wm_startreplace) { 2174 2175 if (findreplacewindow == NULL) 2176 findreplacewindow = ReplaceText ((FINDREPLACE *) lParam); 2177 else 2178 windowbringtofront (findreplacewindow); 2179 2180 return (0); 2181 } 2182 2183 2184 if (msg == wm_findmsgstring) { 2185 2186 shellprocessfindmessage ((FINDREPLACE *) lParam); 2187 2188 return (0); 2189 } 2190 2191 2192 switch (msg){ 2193 /* case WM_WINDOWPOSCHANGING: 2194 { 2195 WINDOWPOS * wp; 2196 2197 if (hwndMDIClient != NULL) { 2198 2199 if (hwnd == hwndMDIClient) { 2200 2201 wp = (WINDOWPOS *) lParam; 2202 2203 wp->flags |= SWP_NOZORDER; 2204 } 2205 } 2206 2207 #if (FRONTIERWEB == 1) 2208 doweb (hwnd, msg, wParam, lParam); 2209 #endif 2210 2211 return DefFrameProc (hwnd,hwndMDIClient,msg,wParam,lParam); 2212 } 2213 */ 2214 2215 case 0x020A: { /*WM_MOUSEWHEEL:*/ 2216 2217 short delta; 2218 WindowPtr w = getfrontwindow (); 2219 tydirection dir = down; 2220 2221 if (w != nil) { 2222 2223 delta = (short) HIWORD (wParam); 2224 2225 delta = delta / 120; /*WHEEL_DELTA == 120*/ 2226 2227 if (delta < 0) 2228 dir = up; 2229 2230 grabthreadglobals (); 2231 2232 shellpushglobals (w); 2233 2234 (*shellglobals.scrollroutine) (dir, false, abs (delta)); 2235 2236 shellpopglobals (); 2237 2238 releasethreadglobals (); 2239 } /*if*/ 2240 2241 break; 2242 } 2243 2244 //#ifdef PIKE 2245 case FWM_SYSTRAYICON: 2246 { 2247 // RECT r; 2248 2249 if (lParam == WM_LBUTTONDBLCLK) { 2250 2251 bigstring bsresult; 2252 2253 grabthreadglobals (); 2254 2255 langrunstringnoerror ("\x28" "system.callbacks.systemTrayIcon2Click ()", bsresult); 2256 2257 releasethreadglobals (); 2258 2259 #ifndef PIKE 2260 ShowWindow (shellframewindow, SW_SHOW); /*Show the window.*/ 2261 2262 activateapplication (NULL); /*Bring to front*/ 2263 #endif 2264 } 2265 2266 if (lParam == WM_RBUTTONUP) { 2267 2268 grabthreadglobals (); 2269 2270 rundockmenu (); 2271 2272 releasethreadglobals (); 2273 } 2274 2275 return DefFrameProc (hwnd,hwndMDIClient,msg,wParam,lParam); 2276 } 2277 //#endif 2278 2279 2280 case WM_SIZE: 2281 { 2282 long statusHeight; 2283 unsigned short width; 2284 unsigned short height; 2285 2286 width = LOWORD(lParam); 2287 2288 height = HIWORD(lParam); 2289 2290 statusHeight = getstatusbarheight(); 2291 2292 if (hwndStatus != NULL) { 2293 MoveWindow( hwndStatus, 2294 0, 2295 height - statusHeight, 2296 width, 2297 statusHeight, 2298 TRUE); 2299 2300 setDefinedStatusBarParts (width); 2301 } 2302 2303 if (hwndMDIClient != NULL) { 2304 2305 SetWindowPos (hwndMDIClient, HWND_BOTTOM, 0, 0, width, height - statusHeight, SWP_NOZORDER); 2306 } 2307 2308 return DefFrameProc (hwnd,hwndMDIClient,msg,wParam,lParam); 2309 } 2310 2311 case WM_CREATE: 2312 { 2313 CLIENTCREATESTRUCT ccs; 2314 HDC hdc; 2315 2316 /* Find window menu where children will be listed */ 2317 ccs.hWindowMenu = GetSubMenu (GetMenu(hwnd),WINDOWMENU); 2318 ccs.idFirstChild = IDM_WINDOWCHILD; 2319 2320 hwndStatus = CreateStatusWindow( WS_CHILD | 2321 WS_VISIBLE | 2322 WS_CLIPSIBLINGS | 2323 CCS_BOTTOM | 2324 SBARS_SIZEGRIP , 2325 NULL, 2326 hwnd, 2327 1001); 2328 2329 /* Create the MDI client filling the client area */ 2330 hwndMDIClient = CreateWindow ("mdiclient", 2331 NULL, 2332 WS_CHILD | WS_CLIPCHILDREN | 2333 /*WS_VSCROLL | WS_HSCROLL | */MDIS_ALLCHILDSTYLES, 2334 0, 2335 0, 2336 0, 2337 0, 2338 hwnd, 2339 (HMENU)0xCAC, 2340 hInst, 2341 (LPSTR)&ccs); 2342 2343 2344 ShowWindow (hwndMDIClient,SW_SHOW); 2345 2346 /* Check if printer can be initialized */ 2347 if (hdc = GetPrinterDC (TRUE)){ 2348 DeleteDC (hdc); 2349 } 2350 2351 hwndNextViewer = SetClipboardViewer (hwnd); 2352 2353 if (hwndNextViewer == NULL) 2354 if (GetLastError() != ERROR_SUCCESS) 2355 hwndNextViewer = (HWND) -1; 2356 2357 #if (FRONTIERWEB == 1) 2358 // doweb (hwnd, msg, wParam, lParam); 2359 #endif 2360 2361 break; 2362 } 2363 2364 // case WM_INITMENU: 2365 /* Set up the menu state */ 2366 // InitializeMenu ((HMENU)wParam); 2367 // shellinitmenus(); 2368 // break; 2369 2370 case WM_WININICHANGE: 2371 case WM_DEVMODECHANGE: 2372 { 2373 /* If control panel changes default printer characteristics, 2374 * reinitialize our printer information... 2375 */ 2376 HDC hdc; 2377 2378 if (hdc = GetPrinterDC (TRUE)) 2379 { 2380 DeleteDC (hdc); 2381 } 2382 break; 2383 } 2384 break; 2385 2386 case WM_PAINT: { 2387 PAINTSTRUCT ps; 2388 BeginPaint (hwnd, &ps); 2389 EndPaint (hwnd, &ps); 2390 } 2391 break; 2392 2393 case WM_COMMAND: 2394 /* Direct all menu selection or accelerator commands to another 2395 * function 2396 */ 2397 // setport(GetDC(hwndActive)); 2398 WinProcessCommandEvent (hwndActive, msg, wParam, lParam); 2399 // ReleaseDC(hwndActive, getport()); 2400 // setport (NULL); 2401 2402 #if (FRONTIERWEB == 1) 2403 // doweb (hwnd, msg, wParam, lParam); 2404 #endif 2405 2406 return DefFrameProc (hwnd,hwndMDIClient,msg,wParam,lParam); 2407 break; 2408 2409 case WM_CLOSE: 2410 2411 //#ifdef PIKE 2412 ShowWindow (hwnd, SW_HIDE); 2413 break; 2414 //#else 2415 2416 2417 2418 /* grabthreadglobals (); 2419 2420 keyboardpeek (&keyboardstatus); 2421 2422 #ifdef PIKE 2423 2424 if (pikequit ()) 2425 2426 shellquit (); 2427 2428 #else 2429 2430 shellquit(); 2431 2432 #endif 2433 2434 releasethreadglobals (); 2435 2436 #if (FRONTIERWEB == 1) 2437 // doweb (hwnd, msg, wParam, lParam); 2438 #endif 2439 2440 break; 2441 //#endif*/ 2442 2443 case WM_QUERYENDSESSION: 2444 /* Before session ends, check that all files are saved */ 2445 return QueryCloseAllChildren (); 2446 2447 case WM_DESTROY: { 2448 WINDOWPLACEMENT w; 2449 2450 //Save the Frame position 2451 w.length = sizeof(WINDOWPLACEMENT); 2452 2453 if (GetWindowPlacement (hwnd, &w)) { 2454 setProfileLong ("\x06" "FrameX", w.rcNormalPosition.left); 2455 setProfileLong ("\x06" "FrameY", w.rcNormalPosition.top); 2456 setProfileLong ("\x06" "FrameW", w.rcNormalPosition.right - w.rcNormalPosition.left); 2457 setProfileLong ("\x06" "FrameH", w.rcNormalPosition.bottom - w.rcNormalPosition.top); 2458 setProfileLong ("\x0a" "FrameStyle", w.showCmd); 2459 } 2460 2461 if (hwndNextViewer != (HWND) -1) 2462 ChangeClipboardChain(hwnd, hwndNextViewer); 2463 2464 #if (FRONTIERWEB == 1) 2465 // doweb (hwnd, msg, wParam, lParam); 2466 #endif 2467 2468 PostQuitMessage (0); 2469 } 2470 break; 2471 2472 case WM_QUIT: 2473 // we never get here; the thread exits before sending it to this proc. 2474 // seems weird, but consistent with the docs 2475 break; 2476 2477 case WM_CHANGECBCHAIN: 2478 2479 // If the next window is closing, repair the chain. 2480 if ((HWND) wParam == hwndNextViewer) 2481 hwndNextViewer = (HWND) lParam; 2482 2483 // Otherwise, pass the message to the next link. 2484 else if (hwndNextViewer != NULL) 2485 SendMessage(hwndNextViewer, msg, wParam, lParam); 2486 2487 break; 2488 2489 case WM_DRAWCLIPBOARD: 2490 handlescrapdisposed (); //it needs to be refreshed 2491 2492 if ((HWND) wParam == hwndNextViewer) 2493 hwndNextViewer = (HWND) lParam; 2494 2495 if ((hwndNextViewer != (HWND) NULL) && (lParam != (LPARAM) NULL)) 2496 SendMessage(hwndNextViewer, msg, wParam, lParam); 2497 2498 break; 2499 2500 case WM_RENDERFORMAT: 2501 shellexportscrap (win2shellscraptype (wParam)); 2502 break; 2503 2504 case WM_RENDERALLFORMATS: 2505 shellwritescrap (allscraptypes); 2506 break; 2507 2508 case WM_DESTROYCLIPBOARD: 2509 shelldisposescrap (); 2510 break; 2511 2512 case wm_destroycaret: 2513 DestroyCaret (); 2514 break; 2515 2516 case wm_processAccept: 2517 fwsNetEventAcceptSocket (wParam, lParam); 2518 break; 2519 2520 case WM_ACTIVATEAPP: 2521 WinProcessActivateAppEvent (hwnd, msg, wParam, lParam); 2522 return (0); 2523 2524 default: 2525 /* use DefFrameProc() instead of DefWindowProc() since there 2526 * are things that have to be handled differently because of MDI 2527 */ 2528 2529 2530 #if (FRONTIERWEB == 1) 2531 // doweb (hwnd, msg, wParam, lParam); 2532 #endif 2533 2534 return DefFrameProc (hwnd,hwndMDIClient,msg,wParam,lParam); 2535 } 2536 return 0; 2537 } 2538 2539 2540 static boolean GetFrontierWindowInfo (HWND hwnd, hdlwindowinfo *hinfo) { 2541 2542 if (!getwindowinfo (hwnd, hinfo)) 2543 return (false); 2544 2545 if (**hinfo == NULL) // dmb: I don't understand why, but it can be so 2546 return (false); 2547 2548 return ((***hinfo).hdata != NULL); 2549 } /*GetFrontierWindowInfo*/ 2550 2551 2552 LONG CALLBACK FrontierOPWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 2553 { 2554 hdlwindowinfo hinfo; 2555 LONG retval; 2556 2557 MESSAGETRACKER(hwnd, msg, wParam, lParam); 2558 2559 switch (msg){ 2560 case WM_CREATE: { 2561 2562 ShowWindow (hwnd, SW_HIDE); 2563 /* 2564 EventRecord ev; 2565 2566 SetFocus (hwnd); 2567 2568 ev.message = hwnd; 2569 ev.what = activateEvt; 2570 ev.where.h = 0; 2571 ev.where.v = 0; 2572 if (wParam) 2573 ev.modifiers = activeFlag; 2574 else 2575 ev.modifiers = 0; 2576 2577 shellprocessevent (&ev); 2578 */ 2579 } 2580 break; 2581 2582 case WM_SIZE: 2583 if (GetFrontierWindowInfo (hwnd, &hinfo)) { 2584 RECT rr; 2585 HDC oldone; 2586 2587 #ifdef USINGSTATUSBAR 2588 //RAB: 1/20/98 - Added code to keep the status bar where it should be 2589 int cxParent = LOWORD (lParam); 2590 int cyParent = HIWORD (lParam); 2591 int x, y, cx, cy; 2592 RECT rWindow; 2593 HWND hwndStatusBar; 2594 2595 hwndStatusBar = (HWND) GetWindowLong (hwnd, 8); 2596 2597 // Keep Status Window Height the same 2598 GetWindowRect (hwndStatusBar, &rWindow); 2599 2600 cy = rWindow.bottom - rWindow.top; 2601 2602 x = 0; 2603 2604 y = cyParent - cy; 2605 2606 cx = cxParent; 2607 2608 MoveWindow (hwndStatusBar, x, y, cx, cy, TRUE); 2609 //RAB: 1/20/98 end of changes 2610 #endif 2611 2612 rr = (**hinfo).contentrect; 2613 2614 if ((rr.right != LOWORD(lParam)) || (rr.bottom != HIWORD(lParam))) { 2615 2616 oldone = getport(); 2617 // winpushport(GetDC(hwnd)); 2618 grabthreadglobals (); 2619 shellpushglobals (hwnd); 2620 2621 shelladjustaftergrow (hwnd); 2622 2623 shellpopglobals (); 2624 releasethreadglobals (); 2625 // ReleaseDC(hwnd, getport()); 2626 //setport (oldone); 2627 // winpopport(); 2628 } 2629 } 2630 2631 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2632 MESSAGEENDER (MSGDEFAULT); 2633 return (retval); 2634 2635 case WM_SYSCOMMAND: { 2636 2637 /*#ifdef PIKE /*7.0b26 PBS: standard Windows maximize behavior.*/ 2638 2639 hdlhashtable hprefs; 2640 boolean flkernelhandledmaximize = false; 2641 2642 #if (FRONTIERWEB == 1) 2643 //RAB 2/21/2001: If a window was maxed we must be sure to resize the HTML control. 2644 if ((wParam == SC_RESTORE) || (wParam == SC_MINIMIZE)) { 2645 HWND tophwnd; 2646 2647 tophwnd = GetTopWindow (hwndMDIClient); 2648 2649 if (IsZoomed (tophwnd)) { 2650 RECT r; 2651 2652 if (hwndHTMLControl != NULL) { 2653 2654 GetClientRect (hwndMDIClient, &r); 2655 2656 SetWindowPos (hwndHTMLControl, HWND_BOTTOM, 0, 0, r.right, r.bottom, SWP_NOACTIVATE | SWP_NOZORDER); 2657 } 2658 2659 } 2660 } 2661 #endif 2662 2663 if (wParam == SC_MAXIMIZE) { /*handle maximize*/ 2664 grabthreadglobals (); 2665 shellpushglobals (hwnd); 2666 2667 if (langfastaddresstotable (roottable, "\x0a" "user.prefs", &hprefs)) { 2668 2669 hdlhashnode hnode; 2670 tyvaluerecord val; 2671 2672 pushhashtable (hprefs); 2673 2674 if (hashlookup ("\x15" "flwinstandardmaximize", &val, &hnode)) { 2675 2676 if (copyvaluerecord (val, &val) && coercetoboolean (&val)) 2677 2678 if ((!val.data.flvalue) && (shellwindowinfo != NULL)) { 2679 2680 (*shellglobals.zoomwindowroutine) (shellwindowinfo, true); 2681 2682 flkernelhandledmaximize = true; 2683 } /*if*/ 2684 } /*if*/ 2685 2686 pophashtable (); 2687 } /*if*/ 2688 2689 if ((shellwindowinfo != NULL) && (!flkernelhandledmaximize)) { 2690 2691 keyboardpeek (&keyboardstatus); //6.0a13 dmb 2692 2693 if ((**shellwindowinfo).configresnum == idaboutconfig) { 2694 2695 (*shellglobals.zoomwindowroutine) (shellwindowinfo, true); 2696 2697 flkernelhandledmaximize = true; 2698 } /*if*/ 2699 } /*if*/ 2700 2701 shellpopglobals (); 2702 releasethreadglobals (); 2703 2704 if (flkernelhandledmaximize) { 2705 retval = 0; 2706 break; 2707 } /*if*/ 2708 } /*if*/ 2709 2710 /* #else 2711 2712 if (wParam == SC_MAXIMIZE) { /*handle maximize*/ 2713 /* grabthreadglobals (); 2714 shellpushglobals (hwnd); 2715 2716 if (shellwindowinfo != NULL) { 2717 2718 keyboardpeek (&keyboardstatus); //6.0a13 dmb 2719 2720 (*shellglobals.zoomwindowroutine) (shellwindowinfo, true); 2721 } 2722 2723 shellpopglobals (); 2724 releasethreadglobals (); 2725 retval = 0; 2726 break; 2727 } 2728 2729 #endif*/ 2730 2731 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2732 MESSAGEENDER (MSGDEFAULT); 2733 return (retval); 2734 } 2735 2736 case WM_MDIACTIVATE: 2737 /* If we're activating this child, remember it */ 2738 if (GET_WM_MDIACTIVATE_FACTIVATE(hwnd, wParam, lParam)){ 2739 hwndActive = hwnd; 2740 } 2741 else{ 2742 hwndActive = NULL; 2743 } 2744 2745 if (GetFrontierWindowInfo (hwnd, &hinfo)) { 2746 2747 // winpushport(GetDC(hwnd)); 2748 2749 WinProcessActivateEvent (hwnd, msg, wParam, lParam); 2750 2751 // ReleaseDC(hwnd, getport()); 2752 // winpopport (); 2753 } 2754 2755 break; 2756 2757 case WM_NCACTIVATE: 2758 if (wParam && GetFrontierWindowInfo (hwnd, &hinfo)) { 2759 2760 // winpushport(GetDC(hwnd)); 2761 2762 WinProcessNCActivateEvent (hwnd, msg, wParam, lParam); 2763 2764 // ReleaseDC(hwnd, getport()); 2765 // winpopport (); 2766 } 2767 2768 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2769 MESSAGEENDER (MSGDEFAULT); 2770 return (retval); 2771 2772 case WM_ACTIVATEAPP: 2773 WinProcessActivateAppEvent (hwnd, msg, wParam, lParam); 2774 return (0); 2775 2776 case WM_QUERYENDSESSION: 2777 /* Prompt to save the child */ 2778 retval = !QueryCloseChild (hwnd); 2779 MESSAGEENDER (MSGOTHER); 2780 return (retval); 2781 2782 case WM_CLOSE: 2783 /* If its OK to close the child, do so, else ignore */ 2784 if (QueryCloseChild (hwnd)) 2785 { 2786 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2787 MESSAGEENDER (MSGDEFAULT); 2788 return (retval); 2789 } 2790 else 2791 break; 2792 2793 case WM_SETFOCUS: 2794 /* See of editor needs focus **/ 2795 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2796 MESSAGEENDER (MSGDEFAULT); 2797 return (retval); 2798 2799 case WM_LBUTTONDOWN: 2800 case WM_RBUTTONDOWN: 2801 // setport(GetDC(hwnd)); 2802 2803 setmousedoubleclickstatus(false); 2804 WinProcessMouseEvent (hwnd, msg, wParam, lParam); 2805 // ReleaseDC(hwnd, getport()); 2806 // setport (NULL); 2807 break; 2808 2809 case WM_LBUTTONDBLCLK: 2810 case WM_RBUTTONDBLCLK: 2811 // setport(GetDC(hwnd)); 2812 setmousedoubleclickstatus(true); 2813 WinProcessMouseEvent (hwnd, msg, wParam, lParam); 2814 // ReleaseDC(hwnd, getport()); 2815 // setport (NULL); 2816 break; 2817 2818 // For the normal left mouse button do not trap or otherwise interfere 2819 // with the normal NC behavior. 2820 //case WM_NCLBUTTONDOWN: 2821 //case WM_NCLBUTTONDBLCLK: 2822 2823 2824 case WM_NCRBUTTONDOWN: 2825 case WM_NCMBUTTONDOWN: 2826 if ((wParam == HTERROR) || (wParam == HTNOWHERE) || (wParam == HTTRANSPARENT)) { 2827 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2828 MESSAGEENDER (MSGDEFAULT); 2829 return (retval); 2830 } 2831 2832 WinProcessMouseEvent (hwnd, msg, wParam, lParam); 2833 break; 2834 2835 case WM_NCRBUTTONDBLCLK: 2836 case WM_NCMBUTTONDBLCLK: 2837 if ((wParam == HTERROR) || (wParam == HTNOWHERE) || (wParam == HTTRANSPARENT)) { 2838 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2839 MESSAGEENDER (MSGDEFAULT); 2840 return (retval); 2841 } 2842 2843 setmousedoubleclickstatus(true); 2844 WinProcessMouseEvent (hwnd, msg, wParam, lParam); 2845 break; 2846 2847 case WM_KEYDOWN: 2848 if (!WinMapSpecialKey (&wParam)) 2849 { 2850 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2851 MESSAGEENDER (MSGDEFAULT); 2852 return (retval); 2853 } 2854 // fall through to WM_CHAR case with updated wParam 2855 2856 case WM_CHAR: 2857 // 5.0a24 rab: why are we trapping this - blocks Alt-space for menu etc. case WM_SYSCHAR: 2858 // setport(GetDC(hwnd)); 2859 WinProcessKeyboardEvent (hwnd, msg, wParam, lParam); 2860 // ReleaseDC(hwnd, getport()); 2861 // setport (NULL); 2862 break; 2863 2864 case WM_PAINT: 2865 if (GetFrontierWindowInfo (hwnd, &hinfo)) { // window is ready for updating 2866 // PAINTSTRUCT ps; 2867 // setport(BeginPaint (hwnd, &ps)); 2868 WinProcessPaintEvent (hwnd, msg, wParam, lParam); 2869 // ValidateRect (hwnd, NULL); 2870 // EndPaint (hwnd, &ps); 2871 // setport (NULL); 2872 // ValidateRect (hwnd, NULL); 2873 break; 2874 } 2875 2876 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2877 MESSAGEENDER (MSGDEFAULT); 2878 return (retval); 2879 2880 case WM_COMMAND: 2881 // setport(GetDC(hwnd)); 2882 WinProcessCommandEvent (hwnd, msg, wParam, lParam); 2883 // ReleaseDC(hwnd, getport()); 2884 // setport (NULL); 2885 break; 2886 2887 case WM_HSCROLL: 2888 // setport(GetDC(hwnd)); 2889 WinProcessScrollEvent (hwnd, msg, wParam, lParam, false); 2890 // ReleaseDC(hwnd, getport()); 2891 // setport (NULL); 2892 break; 2893 2894 case WM_VSCROLL: 2895 // setport(GetDC(hwnd)); 2896 WinProcessScrollEvent (hwnd, msg, wParam, lParam, true); 2897 // ReleaseDC(hwnd, getport()); 2898 // setport (NULL); 2899 break; 2900 2901 default: 2902 /* Again, since the MDI default behaviour is a little different, 2903 * call DefMDIChildProc instead of DefWindowProc() 2904 */ 2905 retval = DefMDIChildProc (hwnd, msg, wParam, lParam); 2906 MESSAGEENDER (MSGDEFAULT); 2907 return (retval); 2908 } 2909 2910 MESSAGEENDER (FALSE); 2911 return FALSE; 2912 } 2913 2914 #if (MEMTRACKER == 1) 2915 extern void displaymemtrack (); 2916 #endif 2917 2918 2919 #if (FRONTIERCOM == 1) 2920 typedef int (WINAPI * tycominit) (HINSTANCE hInstance, 2921 HINSTANCE hPrevInstance, 2922 LPSTR lpCmdLine, 2923 int nCmdShow, XDLLProcTable * calltable); 2924 2925 typedef void (WINAPI * tycomclear) (); 2926 2927 //extern int WINAPI comInit(HINSTANCE hInstance, 2928 // HINSTANCE hPrevInstance, 2929 // LPSTR lpCmdLine, 2930 // int nCmdShow, XDLLProcTable * calltable); 2931 //extern int comClear (); 2932 typedef struct tyComServerInfo { 2933 tycominit cominit; 2934 tycomclear comclear; 2935 XDLLProcTable calltable; 2936 HANDLE hCOMModule; 2937 HINSTANCE hInstance; 2938 HINSTANCE hPrevInstance; 2939 LPSTR lpCmdLine; 2940 int nCmdShow; 2941 } tyComServerInfo; 2942 2943 tyComServerInfo gcomServerInfo; 2944 2945 Handle COMSYSModule() { 2946 return (gcomServerInfo.hCOMModule); 2947 } /*COMSYSModule*/ 2948 2949 2950 Handle COMStartup () { 2951 2952 gcomServerInfo.hCOMModule = LoadLibrary ("COMDLL.DLL"); 2953 2954 if (gcomServerInfo.hCOMModule == NULL) 2955 gcomServerInfo.hCOMModule = LoadLibrary ("DLLS\\COMDLL.DLL"); 2956 2957 if (gcomServerInfo.hCOMModule == NULL) 2958 gcomServerInfo.hCOMModule = LoadLibrary ("..\\DLLS\\COMDLL.DLL"); 2959 2960 if (gcomServerInfo.hCOMModule != NULL) { 2961 gcomServerInfo.cominit = (tycominit) GetProcAddress (gcomServerInfo.hCOMModule, "comInit"); 2962 gcomServerInfo.comclear = (tycominit) GetProcAddress (gcomServerInfo.hCOMModule, "comClear"); 2963 2964 if ((gcomServerInfo.cominit != NULL) && (gcomServerInfo.comclear != NULL)) { 2965 2966 fillcalltable(&gcomServerInfo.calltable); 2967 2968 (*(gcomServerInfo.cominit)) (gcomServerInfo.hInstance, gcomServerInfo.hPrevInstance, gcomServerInfo.lpCmdLine, gcomServerInfo.nCmdShow, &gcomServerInfo.calltable); 2969 } 2970 } 2971 2972 return (gcomServerInfo.hCOMModule); 2973 } /*COMStartup*/ 2974 2975 boolean COMShutdown () { 2976 if ((gcomServerInfo.cominit != NULL) && (gcomServerInfo.comclear != NULL)) 2977 (*(gcomServerInfo.comclear)) (); 2978 2979 if (gcomServerInfo.hCOMModule != NULL) 2980 FreeLibrary (gcomServerInfo.hCOMModule); 2981 2982 gcomServerInfo.cominit = NULL; 2983 gcomServerInfo.comclear = NULL; 2984 gcomServerInfo.hCOMModule = NULL; 2985 return (true); 2986 } /*COMShutdown*/ 2987 2988 #endif 2989 2990 //#ifdef PIKE 2991 2992 /* 9/24/01 RAB */ 2993 #define PACKVERSION(major,minor) MAKELONG(minor,major) 2994 2995 DWORD GetDllVersion(LPCTSTR lpszDllName) 2996 { 2997 2998 HINSTANCE hinstDll; 2999 DWORD dwVersion = 0; 3000 3001 hinstDll = LoadLibrary(lpszDllName); 3002 3003 if(hinstDll) 3004 { 3005 DLLGETVERSIONPROC pDllGetVersion; 3006 3007 pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion"); 3008 3009 /*Because some DLLs might not implement this function, you 3010 must test for it explicitly. Depending on the particular 3011 DLL, the lack of a DllGetVersion function can be a useful 3012 indicator of the version. 3013 */ 3014 if(pDllGetVersion) 3015 { 3016 DLLVERSIONINFO dvi; 3017 HRESULT hr; 3018 3019 ZeroMemory(&dvi, sizeof(dvi)); 3020 dvi.cbSize = sizeof(dvi); 3021 3022 hr = (*pDllGetVersion)(&dvi); 3023 3024 if(SUCCEEDED(hr)) 3025 { 3026 dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); 3027 } 3028 } 3029 3030 FreeLibrary(hinstDll); 3031 } 3032 return dwVersion; 3033 } 3034 3035 //#endif 3036 3037 int CALLBACK WinMain ( 3038 HINSTANCE hInstance, 3039 HINSTANCE hPrevInstance, 3040 LPSTR lpCmdLine, 3041 int nCmdShow 3042 ) 3043 { 3044 3045 //#ifdef PIKE 3046 3047 NOTIFYICONDATA statusIconData; 3048 3049 //#endif 3050 3051 #if (FRONTIERCOM == 1) 3052 gcomServerInfo.hInstance = hInstance; 3053 gcomServerInfo.hPrevInstance = hPrevInstance; 3054 gcomServerInfo.lpCmdLine = lpCmdLine; 3055 gcomServerInfo.nCmdShow = nCmdShow; 3056 3057 COMStartup(); 3058 #endif 3059 3060 #if (FRONTIERWEB == 1) 3061 webappStartup (); 3062 3063 OleInitialize(NULL); 3064 3065 InitCommonControls(); 3066 #endif 3067 3068 #ifdef PIKE /*7.0b26 PBS*/ 3069 wm_frontieropenfile = RegisterWindowMessage ("PikeOpenFile"); 3070 #else 3071 wm_frontieropenfile = RegisterWindowMessage ("FrontierOpenFile"); 3072 #endif 3073 3074 wm_findmsgstring = RegisterWindowMessage (FINDMSGSTRING); 3075 3076 wm_startreplace = RegisterWindowMessage (sz_frontierstartreplace); 3077 3078 wm_startsearch = RegisterWindowMessage (sz_frontierstartsearch); 3079 3080 #ifdef PIKE 3081 frontiermutex = CreateMutex (NULL, true, "PikeInstance"); 3082 #else 3083 frontiermutex = CreateMutex (NULL, true, "FrontierInstance"); 3084 #endif 3085 3086 if (GetLastError () == ERROR_ALREADY_EXISTS) { 3087 bigstring inputFile; 3088 3089 //5.0b9 rab: It is not allowed to share memory directly between processes 3090 //under NT so instead we just write the command line to the registry then 3091 //read it back when processing the openfile message. 3092 3093 copyctopstring (lpCmdLine, inputFile); 3094 3095 setProfileString ("\x0b" "DeskTopFile", inputFile); 3096 3097 // MessageBox (NULL, lpCmdLine, "Frontier Exists", MB_OK); 3098 3099 SendMessage (HWND_BROADCAST, wm_frontieropenfile, 0, (LPARAM) true); 3100 3101 return 0; 3102 } 3103 3104 hInst = hInstance; 3105 shellinstance = hInstance; 3106 3107 /* If this is the first instance of the app. register window classes */ 3108 if (!hPrevInstance) { 3109 if (!InitializeApplication ()) 3110 return 0; 3111 } 3112 3113 /* Create the frame and do other initialization */ 3114 if (!InitializeInstance (lpCmdLine, nCmdShow)) 3115 return 0; 3116 3117 //#ifdef PIKE 3118 3119 if(GetDllVersion(TEXT("shell32.dll")) >= PACKVERSION(5,0)) 3120 { 3121 statusIconData.cbSize = sizeof(NOTIFYICONDATA); 3122 } 3123 else 3124 { 3125 statusIconData.cbSize = sizeof(NOTIFYICONDATA);//NOTIFYICONDATA_V1_SIZE; 3126 } 3127 3128 statusIconData.hIcon = hTrayIconApp; 3129 statusIconData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; 3130 statusIconData.uID = 5335; 3131 statusIconData.hWnd = shellframewindow; 3132 statusIconData.uCallbackMessage = FWM_SYSTRAYICON; 3133 3134 #ifdef PIKE 3135 strcpy (statusIconData.szTip, "Radio UserLand"); 3136 #else 3137 strcpy (statusIconData.szTip, "UserLand Frontier"); 3138 #endif 3139 3140 Shell_NotifyIcon (NIM_ADD, &statusIconData); 3141 3142 //#endif 3143 3144 /* Enter main message loop */ 3145 shellmaineventloop (); 3146 3147 //#ifdef PIKE 3148 3149 Shell_NotifyIcon (NIM_DELETE, &statusIconData); 3150 3151 //#endif 3152 3153 #if (MEMTRACKER == 1) 3154 displaymemtrack (); 3155 #endif 3156 3157 fwsNetEventShutDown(); 3158 3159 #if (FRONTIERWEB==1) 3160 OleUninitialize(); 3161 3162 webappShutdown (); 3163 3164 #endif 3165 3166 #if (FRONTIERCOM == 1) 3167 COMShutdown (); 3168 #endif 3169 3170 #if (MESSAGETRACKSYSTEM == 1) 3171 fclose (errfile); 3172 #endif 3173 3174 if (frontiermutex != NULL) 3175 verify (CloseHandle (frontiermutex)); 3176 3177 return 0; 3178 } /*WinMain*/ 3179 3180 3181 3182 BOOL fAbort; /* TRUE if the user has aborted the print job */ 3183 HWND hwndPDlg; /* Handle to the cancel print dialog */ 3184 CHAR szDevice[160]; /* Contains the device, the driver, and the port */ 3185 PSTR szDriver; /* Pointer to the driver name */ 3186 PSTR szPort; /* Port, ie, LPT1 */ 3187 PSTR szTitle; /* Global pointer to job title */ 3188 INT iPrinter = 0; /* level of available printer support. */ 3189 /* 0 - no printer available */ 3190 /* 1 - printer available */ 3191 /* 2 - driver supports 3.0 device initialization */ 3192 HANDLE hInitData=NULL; /* handle to initialization data */ 3193 3194 CHAR szExtDeviceMode[] = "EXTDEVICEMODE"; 3195 3196 /**************************************************************************** 3197 * * 3198 * FUNCTION : GetPrinterDC () * 3199 * * 3200 * PURPOSE : Creates a printer display context for the default device. * 3201 * As a side effect, it sets the szDevice and szPort variables* 3202 * It also sets iPrinter to the supported level of printing. * 3203 * * 3204 * RETURNS : HDC - A handle to printer DC. * 3205 * * 3206 ****************************************************************************/ 3207 HDC GetPrinterDC(BOOL bInformation) 3208 { 3209 HDC hdc; 3210 #if defined(_MAC) 3211 iPrinter = 0; 3212 3213 if (bInformation) 3214 hdc = CreateIC("PRINTER", NULL, NULL, NULL); 3215 else 3216 hdc = CreateDC("PRINTER", NULL, NULL, NULL); 3217 3218 if (hdc) 3219 iPrinter = 1; 3220 3221 #else 3222 3223 LPDEVMODE lpdevmode = NULL; 3224 3225 iPrinter = 0; 3226 3227 /* Get the printer information from win.ini into a buffer and 3228 * null terminate it. 3229 */ 3230 GetProfileString ( "windows", "device", "" ,szDevice, sizeof(szDevice)); 3231 for (szDriver = szDevice; *szDriver && *szDriver != ','; szDriver++) 3232 ; 3233 if (*szDriver) 3234 *szDriver++ = 0; 3235 3236 /* From the current position in the buffer, null teminate the 3237 * list of ports 3238 */ 3239 for (szPort = szDriver; *szPort && *szPort != ','; szPort++) 3240 ; 3241 if (*szPort) 3242 *szPort++ = 0; 3243 3244 /* if the device, driver and port buffers all contain meaningful data, 3245 * proceed. 3246 */ 3247 if (!*szDevice || !*szDriver || !*szPort){ 3248 *szDevice = 0; 3249 return NULL; 3250 } 3251 3252 /* Create the printer display context */ 3253 if (hInitData){ 3254 /* Get a pointer to the initialization data */ 3255 lpdevmode = (LPDEVMODE) LocalLock (hInitData); 3256 3257 if (lstrcmp (szDevice, (LPSTR)lpdevmode)){ 3258 /* User has changed the device... cancel this setup, as it is 3259 * invalid (although if we worked harder we could retain some 3260 * of it). 3261 */ 3262 lpdevmode = NULL; 3263 LocalUnlock (hInitData); 3264 LocalFree (hInitData); 3265 hInitData = NULL; 3266 } 3267 } 3268 3269 if (bInformation) 3270 hdc = CreateIC (szDriver, szDevice, szPort, lpdevmode); 3271 else 3272 hdc = CreateDC (szDriver, szDevice, szPort, lpdevmode); 3273 3274 /* Unlock initialization data */ 3275 if (hInitData) 3276 LocalUnlock (hInitData); 3277 3278 if (!hdc) 3279 return NULL; 3280 3281 3282 iPrinter = 1; 3283 3284 /* Find out if ExtDeviceMode() is supported and set flag appropriately */ 3285 if (GetProcAddress (LoadLibrary(szDriver), szExtDeviceMode)) 3286 iPrinter = 2; 3287 3288 #endif 3289 3290 return hdc; 3291 3292 } 3293 3294 3295 3296 3297 EventAvail (unsigned short mask, EventRecord * ev) 3298 { 3299 MSG msg; 3300 HWND hwnd; 3301 3302 hwnd = NULL; 3303 3304 if ((mask & mDownMask) == mDownMask) { 3305 if ((PeekMessage (&msg, hwnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE)) || 3306 (PeekMessage (&msg, hwnd, WM_RBUTTONDOWN, WM_RBUTTONDOWN, PM_NOREMOVE)) || 3307 (PeekMessage (&msg, hwnd, WM_MBUTTONDOWN, WM_MBUTTONDOWN, PM_NOREMOVE))) 3308 return (true); 3309 } 3310 3311 3312 if ((mask & mUpMask) == mUpMask) { 3313 if ((PeekMessage (&msg, hwnd, WM_LBUTTONUP, WM_LBUTTONDBLCLK, PM_NOREMOVE)) || 3314 (PeekMessage (&msg, hwnd, WM_RBUTTONUP, WM_RBUTTONDBLCLK, PM_NOREMOVE)) || 3315 (PeekMessage (&msg, hwnd, WM_MBUTTONUP, WM_MBUTTONDBLCLK, PM_NOREMOVE))) 3316 return (true); 3317 } 3318 3319 3320 if ((mask & keyDownMask) == keyDownMask) { 3321 if ((PeekMessage (&msg, hwnd, WM_KEYDOWN, WM_KEYDOWN, PM_NOREMOVE)) || 3322 (PeekMessage (&msg, hwnd, WM_SYSKEYDOWN, WM_SYSKEYDOWN, PM_NOREMOVE))) 3323 return (true); 3324 } 3325 3326 3327 if (((mask & keyUpMask) == keyUpMask) || ((mask & autoKeyMask) == autoKeyMask)) { 3328 if (PeekMessage (&msg, hwnd, WM_KEYUP, WM_KEYLAST, PM_NOREMOVE)) 3329 return (true); 3330 } 3331 3332 3333 if ((mask & updateMask) == updateMask) { 3334 if (PeekMessage (&msg, hwnd, WM_PAINT, WM_PAINT, PM_NOREMOVE)) 3335 return (true); 3336 } 3337 3338 /* diskMask */ 3339 3340 if ((mask & activMask) == activMask) { 3341 if (PeekMessage (&msg, hwnd, WM_ACTIVATE, WM_ACTIVATE, PM_NOREMOVE)) 3342 if (PeekMessage (&msg, hwnd, WM_MDIACTIVATE, WM_MDIACTIVATE, PM_NOREMOVE)) 3343 return (true); 3344 } 3345 3346 3347 if (((mask & highLevelEventMask) == highLevelEventMask) || ((mask & osMask) == osMask)){ 3348 if ((PeekMessage (&msg, hwnd, WM_NULL, WM_ACTIVATE-1, PM_NOREMOVE)) || 3349 (PeekMessage (&msg, hwnd, WM_ACTIVATE+1, WM_PAINT-1, PM_NOREMOVE)) || 3350 (PeekMessage (&msg, hwnd, WM_PAINT+1, WM_KEYFIRST-1, PM_NOREMOVE)) || 3351 (PeekMessage (&msg, hwnd, WM_KEYLAST+1, WM_COMMAND-1, PM_NOREMOVE)) || 3352 (PeekMessage (&msg, hwnd, WM_SYSCOMMAND+1, WM_MOUSEFIRST-1, PM_NOREMOVE)) || 3353 (PeekMessage (&msg, hwnd, WM_MOUSELAST+1, WM_MDIACTIVATE-1, PM_NOREMOVE)) || 3354 (PeekMessage (&msg, hwnd, WM_MDIACTIVATE+1, WM_USER-1, PM_NOREMOVE))) 3355 return (true); 3356 } 3357 3358 return (false); 3359 } 3360 3361

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.