00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
#include <windows.h>
00066
#include <commdlg.h>
00067
#include <dlgs.h>
00068
#include <stdio.h>
00069
#include <string.h>
00070
#include <cderr.h>
00071
#include "main.h"
00072
#include "resource.h"
00073
00074 HANDLE
hInst;
00075 OPENFILENAME
OpenFileName;
00076 CHAR szDirName[256] =
"";
00077 CHAR szFile[256] =
"\0";
00078 CHAR szFileTitle[256];
00079
00080
00081
00082
00083
00084 CHAR szFilter[] =
"Text Files (*.ICM)\0*.ICM\0All Files (*.*)\0*.*\0";
00085 CHAR szSaveFilter[] =
"Text Files (*.CSA)\0*.CSA\0All Files (*.*)\0*.*\0";
00086
00087 CHAR FileBuf[
FILE_LEN];
00088 DWORD dwFileSize;
00089 UINT FindReplaceMsg;
00090 CHAR szFindString[64] =
"";
00091 CHAR szReplaceString[64] =
"";
00092 FINDREPLACE
frText;
00093 LPFINDREPLACE
lpFR;
00094 CHAR *
lpBufPtr =
FileBuf;
00095 CHOOSEFONT
chf;
00096 CHOOSECOLOR
chsclr;
00097 COLORREF
crColor;
00098 LOGFONT
lf;
00099 WORD
wMode =
IDM_CUSTOM;
00100 WORD
wAsciiMode =
IDM_ASCII;
00101 WORD
wIntentMode =
IDM_PERCEPUAL;
00102 WORD
wCSAMode =
IDM_AUTO;
00103 WORD
wInpDrvClrSp =
IDM_INP_AUTO;
00104 WORD
wCSAorCRD =
IDM_CSA;
00105 HWND
hDlgFR =
NULL;
00106 PRINTDLG
pd;
00107
00108 BOOL AllowBinary =
FALSE;
00109 DWORD Intent = 0;
00110 HWND
hWnd;
00111
00112
BOOL WINAPI
OpenFiles(
00113 HWND hDlg,
00114 UINT message,
00115 WPARAM wParam,
00116 LPARAM lParam);
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 int PASCAL
WinMain(
00130 HINSTANCE hInstance,
00131 HINSTANCE hPrevInstance,
00132 LPSTR lpCmdLine,
00133
int nCmdShow
00134 )
00135 {
00136
00137 MSG
msg;
00138
00139
if (!hPrevInstance)
00140
if (!
InitApplication(hInstance))
00141
return (
FALSE);
00142
00143
hInst = hInstance;
00144
00145
00146
00147
if (!
InitInstance(hInstance, nCmdShow))
00148
return (
FALSE);
00149
00150
00151
FindReplaceMsg =
RegisterWindowMessage( (LPSTR) FINDMSGSTRING );
00152
00153
00154
00155
while (
GetMessage(&
msg,
00156
NULL,
00157 0,
00158 0))
00159
if ( !
hDlgFR || !
IsWindow(
hDlgFR) || !
IsDialogMessage(
hDlgFR, &
msg ) )
00160 {
00161
TranslateMessage(&
msg);
00162
DispatchMessage(&
msg);
00163 }
00164
return (
msg.wParam);
00165
00166
00167 lpCmdLine;
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 BOOL InitApplication(HANDLE hInstance)
00186 {
00187 WNDCLASS wc;
00188
00189
00190
00191
00192 wc.style = 0;
00193 wc.lpfnWndProc = (WNDPROC)
MainWndProc;
00194
00195 wc.cbClsExtra = 0;
00196 wc.cbWndExtra = 0;
00197 wc.hInstance = hInstance;
00198 wc.hIcon = LoadIcon(
NULL,
IDI_ICON1);
00199 wc.hCursor = LoadCursor(
NULL, IDC_ARROW);
00200 wc.hbrBackground = GetStockObject(WHITE_BRUSH);
00201 wc.lpszMenuName =
"CmnDlgMenu";
00202 wc.lpszClassName =
"CmnDlgWClass";
00203
00204
00205
00206
return (
RegisterClass(&wc));
00207
00208 }
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 BOOL InitInstance(
00225 HANDLE hInstance,
00226
int nCmdShow)
00227 {
00228 HWND hWND;
00229
00230
00231
00232
00233
hInst = hInstance;
00234
00235
00236
00237 hWND = CreateWindow(
00238
"CmnDlgWClass",
00239
"CIEBASED_CDEF Color Space",
00240 WS_OVERLAPPEDWINDOW,
00241 CW_USEDEFAULT,
00242 CW_USEDEFAULT,
00243 CW_USEDEFAULT,
00244 CW_USEDEFAULT,
00245
NULL,
00246
NULL,
00247 hInstance,
00248
NULL
00249 );
00250
00251
00252
00253
if (!hWND)
00254
return (
FALSE);
00255
00256
hWnd = hWND;
00257
00258
00259
ShowWindow(
hWnd, nCmdShow);
00260
UpdateWindow(
hWnd);
00261
return (
TRUE);
00262
00263 }
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 LRESULT CALLBACK
MainWndProc(
00283 HWND hWnd,
00284 UINT message,
00285 WPARAM wParam,
00286 LPARAM lParam)
00287 {
00288 FARPROC lpProcAbout;
00289 FARPROC lpProcOpen;
00290 FARPROC lpProcEnterNew;
00291 HDC hDC;
00292 PAINTSTRUCT ps;
00293
INT nDrawX;
00294
INT nDrawY;
00295 HFONT hFont;
00296 HANDLE
Handle;
00297
static BOOL NewFont;
00298
00299
switch (message) {
00300
00301
00302
case WM_CREATE:
00303
00304 strcpy(
FileBuf,
" ");
00305
lpBufPtr =
FileBuf;
00306
dwFileSize =
strlen(
FileBuf);
00307
crColor = 0;
00308 NewFont =
FALSE;
00309
break;
00310
00311
00312
case WM_PAINT:
00313
00314 hDC =
BeginPaint (
hWnd, &ps);
00315
00316
00317
00318
00319 nDrawX = GetDeviceCaps(hDC, LOGPIXELSX) / 4;
00320 nDrawY = GetDeviceCaps(hDC, LOGPIXELSY) / 4;
00321
00322
if ( NewFont ==
TRUE )
00323 {
00324 hFont = CreateFontIndirect( &
lf );
00325
Handle = SelectObject( hDC, hFont );
00326 }
00327
00328 SetTextColor( hDC,
crColor );
00329
00330
00331 EndPaint(
hWnd, &ps );
00332
break;
00333
00334
00335
case WM_COMMAND:
00336
00337
switch( LOWORD( wParam ))
00338 {
00339
case IDM_OPENFILE:
00340 lpProcOpen = MakeProcInstance((FARPROC)
OpenFiles,
hInst);
00341
00342 DialogBox(
hInst,
00343
"OPENFILES",
00344
hWnd,
00345 (DLGPROC)lpProcOpen);
00346
00347 FreeProcInstance(lpProcOpen);
00348
break;
00349
00350
case IDM_EXIT:
00351
PostQuitMessage(0);
00352
break;
00353
00354
case IDM_CHOOSECOLOR:
00355
if (
ChooseNewColor(
hWnd ))
00356 InvalidateRect(
hWnd,
NULL,
TRUE );
00357
break;
00358
00359
case IDM_CHOOSEFONT:
00360
if (NewFont =
ChooseNewFont(
hWnd ))
00361 InvalidateRect(
hWnd,
NULL,
TRUE );
00362
00363
break;
00364
00365
case IDM_FINDTEXT:
00366
CallFindText(
hWnd );
00367
break;
00368
00369
case IDM_REPLACETEXT:
00370
CallReplaceText(
hWnd );
00371
break;
00372
00373
case IDM_STANDARD:
00374
00375
EnableMenuItem(
GetMenu(
hWnd),
IDM_CHOOSECOLOR,
00376 MF_BYCOMMAND | MF_ENABLED );
00377
00378
CheckMenuItem(
GetMenu(
hWnd ),
wMode, MF_UNCHECKED | MF_BYCOMMAND);
00379
00380
wMode = LOWORD(wParam);
00381
00382
CheckMenuItem(
GetMenu(
hWnd ),
wMode, MF_CHECKED | MF_BYCOMMAND);
00383
DrawMenuBar(
hWnd);
00384
break;
00385
case IDM_HOOK:
00386
case IDM_CUSTOM:
00387
00388
EnableMenuItem(
GetMenu(
hWnd),
IDM_CHOOSECOLOR,
00389 MF_BYCOMMAND | MF_GRAYED );
00390
00391
CheckMenuItem(
GetMenu(
hWnd ),
wMode, MF_UNCHECKED | MF_BYCOMMAND);
00392
00393
wMode = LOWORD(wParam);
00394
00395
CheckMenuItem(
GetMenu(
hWnd ),
wMode, MF_CHECKED | MF_BYCOMMAND);
00396
DrawMenuBar(
hWnd);
00397
break;
00398
00399
case IDM_ENTERNEW:
00400 lpProcEnterNew = MakeProcInstance((FARPROC)
EnterNew,
hInst);
00401
00402
if (DialogBox(
hInst,
00403
"EnterNewBox",
00404
hWnd,
00405 (DLGPROC)lpProcEnterNew) ==
TRUE)
00406
00407 InvalidateRect(
hWnd,
NULL,
TRUE );
00408
00409 FreeProcInstance(lpProcEnterNew);
00410
break;
00411
00412
case IDM_PERCEPUAL:
00413
Intent = 0;
00414
CheckMenuItem(
GetMenu(
hWnd ),
wIntentMode, MF_UNCHECKED | MF_BYCOMMAND);
00415
00416
wIntentMode = LOWORD(wParam);
00417
00418
CheckMenuItem(
GetMenu(
hWnd ),
wIntentMode, MF_CHECKED | MF_BYCOMMAND);
00419
DrawMenuBar(
hWnd);
00420
break;
00421
case IDM_COLOR:
00422
Intent = 1;
00423
CheckMenuItem(
GetMenu(
hWnd ),
wIntentMode, MF_UNCHECKED | MF_BYCOMMAND);
00424
00425
wIntentMode = LOWORD(wParam);
00426
00427
CheckMenuItem(
GetMenu(
hWnd ),
wIntentMode, MF_CHECKED | MF_BYCOMMAND);
00428
DrawMenuBar(
hWnd);
00429
break;
00430
case IDM_SATURATION:
00431
Intent = 2;
00432
CheckMenuItem(
GetMenu(
hWnd ),
wIntentMode, MF_UNCHECKED | MF_BYCOMMAND);
00433
00434
wIntentMode = LOWORD(wParam);
00435
00436
CheckMenuItem(
GetMenu(
hWnd ),
wIntentMode, MF_CHECKED | MF_BYCOMMAND);
00437
DrawMenuBar(
hWnd);
00438
break;
00439
00440
case IDM_ASCII:
00441
AllowBinary =
FALSE;
00442
CheckMenuItem(
GetMenu(
hWnd ),
wAsciiMode, MF_UNCHECKED | MF_BYCOMMAND);
00443
00444
wAsciiMode = LOWORD(wParam);
00445
00446
CheckMenuItem(
GetMenu(
hWnd ),
wAsciiMode, MF_CHECKED | MF_BYCOMMAND);
00447
DrawMenuBar(
hWnd);
00448
break;
00449
case IDM_BINARY:
00450
AllowBinary =
TRUE;
00451
CheckMenuItem(
GetMenu(
hWnd ),
wAsciiMode, MF_UNCHECKED | MF_BYCOMMAND);
00452
00453
wAsciiMode = LOWORD(wParam);
00454
00455
CheckMenuItem(
GetMenu(
hWnd ),
wAsciiMode, MF_CHECKED | MF_BYCOMMAND);
00456
DrawMenuBar(
hWnd);
00457
break;
00458
case IDM_AUTO:
00459
case IDM_ABC:
00460
case IDM_DEFG:
00461
CheckMenuItem(
GetMenu(
hWnd ),
wCSAMode, MF_UNCHECKED | MF_BYCOMMAND);
00462
00463
wCSAMode = LOWORD(wParam);
00464
00465
CheckMenuItem(
GetMenu(
hWnd ),
wCSAMode, MF_CHECKED | MF_BYCOMMAND);
00466
DrawMenuBar(
hWnd);
00467
break;
00468
00469
case IDM_INP_AUTO:
00470
case IDM_INP_GRAY:
00471
case IDM_INP_RGB:
00472
case IDM_INP_CMYK:
00473
CheckMenuItem(
GetMenu(
hWnd ),
wInpDrvClrSp, MF_UNCHECKED | MF_BYCOMMAND);
00474
00475
wInpDrvClrSp = LOWORD(wParam);
00476
00477
CheckMenuItem(
GetMenu(
hWnd ),
wInpDrvClrSp, MF_CHECKED | MF_BYCOMMAND);
00478
DrawMenuBar(
hWnd);
00479
break;
00480
00481
case IDM_CSA:
00482
case IDM_CRD:
00483
case IDM_PROFCRD:
00484
case IDM_INTENT:
00485
CheckMenuItem(
GetMenu(
hWnd ),
wCSAorCRD, MF_UNCHECKED | MF_BYCOMMAND);
00486
00487
wCSAorCRD = LOWORD(wParam);
00488
if ((
wCSAorCRD ==
IDM_CRD) || (
wCSAorCRD ==
IDM_INTENT))
00489 {
00490
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_AUTO, MF_BYCOMMAND | MF_GRAYED );
00491
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_GRAY, MF_BYCOMMAND | MF_GRAYED );
00492
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_RGB, MF_BYCOMMAND | MF_GRAYED );
00493
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_CMYK, MF_BYCOMMAND | MF_GRAYED );
00494
EnableMenuItem(
GetMenu(
hWnd),
IDM_AUTO, MF_BYCOMMAND | MF_GRAYED );
00495
EnableMenuItem(
GetMenu(
hWnd),
IDM_ABC, MF_BYCOMMAND | MF_GRAYED );
00496
EnableMenuItem(
GetMenu(
hWnd),
IDM_DEFG, MF_BYCOMMAND | MF_GRAYED );
00497 }
00498
else
00499 {
00500
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_AUTO, MF_BYCOMMAND | MF_ENABLED );
00501
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_GRAY, MF_BYCOMMAND | MF_ENABLED );
00502
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_RGB, MF_BYCOMMAND | MF_ENABLED );
00503
EnableMenuItem(
GetMenu(
hWnd),
IDM_INP_CMYK, MF_BYCOMMAND | MF_ENABLED );
00504
EnableMenuItem(
GetMenu(
hWnd),
IDM_AUTO, MF_BYCOMMAND | MF_ENABLED );
00505
EnableMenuItem(
GetMenu(
hWnd),
IDM_ABC, MF_BYCOMMAND | MF_ENABLED );
00506
EnableMenuItem(
GetMenu(
hWnd),
IDM_DEFG, MF_BYCOMMAND | MF_ENABLED );
00507 }
00508
00509
00510
CheckMenuItem(
GetMenu(
hWnd ),
wCSAorCRD, MF_CHECKED | MF_BYCOMMAND);
00511
DrawMenuBar(
hWnd);
00512
break;
00513
00514
case IDM_ABOUT:
00515 lpProcAbout = MakeProcInstance((FARPROC)
About,
hInst);
00516
00517 DialogBox(
hInst,
00518
"AboutBox",
00519
hWnd,
00520 (DLGPROC)lpProcAbout);
00521
00522 FreeProcInstance(lpProcAbout);
00523
break;
00524
00525
default:
00526
return (
DefWindowProc(
hWnd, message, wParam, lParam));
00527
00528 }
00529
break;
00530
00531
case WM_DESTROY:
00532
PostQuitMessage(0);
00533
break;
00534
00535
00536
default:
00537
00538
00539
if ( message ==
FindReplaceMsg )
00540 {
00541
if (
lpFR = (LPFINDREPLACE) lParam )
00542 {
00543
if (
lpFR->Flags & FR_DIALOGTERM )
00544
return (0);
00545
SearchFile(
lpFR );
00546 InvalidateRect(
hWnd,
NULL,
TRUE );
00547 }
00548
return (0);
00549 }
00550
00551
return (
DefWindowProc(
hWnd, message, wParam, lParam));
00552 }
00553
return (0);
00554 }
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570 BOOL CALLBACK
EnterNew(
00571 HWND hDlg,
00572 UINT message,
00573 WPARAM wParam,
00574 LPARAM lParam)
00575 {
00576
CHAR Buf[
FILE_LEN-1];
00577
00578
switch (message)
00579 {
00580
case WM_INITDIALOG:
00581
return (
TRUE);
00582
00583
case WM_COMMAND:
00584
if (LOWORD(wParam) == IDOK)
00585 {
00586
GetDlgItemText( hDlg,
IDEDIT, Buf,
FILE_LEN-1);
00587 strcpy(
FileBuf, Buf);
00588
lpBufPtr =
FileBuf;
00589
dwFileSize =
strlen(
FileBuf);
00590
EndDialog( hDlg,
TRUE );
00591
return (
TRUE);
00592 }
00593
else if (LOWORD(wParam) == IDCANCEL)
00594 {
00595
EndDialog(hDlg,
FALSE);
00596
return (
TRUE);
00597 }
00598
break;
00599 }
00600
return (
FALSE);
00601
00602
00603 lParam;
00604 }
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 BOOL WINAPI
About(
00623 HWND hDlg,
00624 UINT message,
00625 WPARAM wParam,
00626 LPARAM lParam)
00627 {
00628
switch (message)
00629 {
00630
case WM_INITDIALOG:
00631
return (
TRUE);
00632
00633
case WM_COMMAND:
00634
if (LOWORD(wParam) == IDOK
00635 || LOWORD(wParam) == IDCANCEL) {
00636
EndDialog(hDlg,
TRUE);
00637
return (
TRUE);
00638 }
00639
break;
00640 }
00641
return (
FALSE);
00642
00643
00644 lParam;
00645 }
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669 BOOL CALLBACK
FileOpenHookProc(
00670 HWND hDlg,
00671 UINT message,
00672 WPARAM wParam,
00673 LPARAM lParam)
00674 {
00675
00676
int hFile;
00677
CHAR szTempText[256];
00678
CHAR szString[256];
00679 OFSTRUCT OfStruct;
00680
00681
switch (message)
00682 {
00683
00684
case WM_COMMAND:
00685
if (LOWORD(wParam) == IDOK)
00686 {
00687
GetDlgItemText( hDlg, edt1, szTempText,
00688
sizeof( szTempText ) - 1);
00689
00690
if (
OpenFileName.Flags & OFN_PATHMUSTEXIST )
00691 {
00692
sprintf( szString,
"Are you sure you want to open %s?",
00693 szTempText);
00694
if ( MessageBox( hDlg, szString,
"Information",
00695 MB_YESNO ) == IDYES )
00696
00697
break;
00698
return (
TRUE);
00699 }
00700
00701
00702
if ( (
BOOL)(
SendMessage(
GetDlgItem(hDlg, chx2),
00703 BM_GETCHECK, 0, 0
L )) ==
TRUE )
00704 {
00705
00706
if ((hFile = OpenFile(szTempText,
00707 &OfStruct,
00708 OF_CREATE)) == -1)
00709 {
00710 MessageBox( hDlg,
00711
"Directory could not be created.",
00712
NULL,
00713 MB_OK );
00714
return (
FALSE);
00715 }
00716
00717 strcpy(
FileBuf,
"Empty");
00718
lpBufPtr =
FileBuf;
00719
dwFileSize =
strlen(
FileBuf);
00720
if (_lwrite( hFile, (LPSTR)&
FileBuf[0],
dwFileSize)==-1)
00721 MessageBox( hDlg,
"Error writing file.",
NULL, MB_OK );
00722
00723
00724 _lclose( hFile );
00725 }
00726
00727 }
00728
break;
00729 }
00730
return (
FALSE);
00731
00732
00733 lParam;
00734
00735 }
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755 BOOL OpenNewFile( HWND hWnd )
00756 {
00757 strcpy(
szFile,
"");
00758 strcpy(
szFileTitle,
"");
00759
00760
OpenFileName.lStructSize =
sizeof(OPENFILENAME);
00761
OpenFileName.hwndOwner =
hWnd;
00762
OpenFileName.hInstance = (HANDLE)
hInst;
00763
OpenFileName.lpstrFilter =
szFilter;
00764
OpenFileName.lpstrCustomFilter = (LPSTR)
NULL;
00765
OpenFileName.nMaxCustFilter = 0
L;
00766
OpenFileName.nFilterIndex = 1
L;
00767
OpenFileName.lpstrFile =
szFile;
00768
OpenFileName.nMaxFile =
sizeof(
szFile);
00769
OpenFileName.lpstrFileTitle =
szFileTitle;
00770
OpenFileName.nMaxFileTitle =
sizeof(
szFileTitle);
00771
OpenFileName.lpstrInitialDir =
NULL;
00772
OpenFileName.lpstrTitle =
"Open a File";
00773
OpenFileName.nFileOffset = 0;
00774
OpenFileName.nFileExtension = 0;
00775
OpenFileName.lpstrDefExt =
"*.icm";
00776
OpenFileName.lCustData = 0;
00777
00778
switch(
wMode )
00779 {
00780
case IDM_STANDARD:
00781
OpenFileName.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
00782 OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
00783
break;
00784
00785
case IDM_HOOK:
00786
OpenFileName.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
00787 OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
00788
OpenFileName.lpfnHook = (LPOFNHOOKPROC)MakeProcInstance(
FileOpenHookProc,
NULL);
00789
break;
00790
00791
case IDM_CUSTOM:
00792
OpenFileName.Flags = OFN_SHOWHELP | OFN_ENABLEHOOK |
00793 OFN_HIDEREADONLY | OFN_ENABLETEMPLATE;
00794
OpenFileName.lpfnHook = (LPOFNHOOKPROC)MakeProcInstance(
FileOpenHookProc,
NULL);
00795
OpenFileName.lpTemplateName = (LPSTR)MAKEINTRESOURCE(FILEOPENORD);
00796
break;
00797 }
00798
00799
if (GetOpenFileName(&
OpenFileName))
00800 {
00801 }
00802
else
00803 {
00804
ProcessCDError(CommDlgExtendedError(),
hWnd );
00805
return FALSE;
00806 }
00807
return TRUE;
00808 }
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826 BOOL SaveToFile( HWND hWnd )
00827 {
00828
int hFile;
00829 OFSTRUCT OfStruct;
00830 WORD wStyle;
00831
CHAR buf[256];
00832
00833
if (
OpenFileName.Flags | OFN_FILEMUSTEXIST)
00834 wStyle = OF_READWRITE;
00835
else
00836 wStyle = OF_READWRITE | OF_CREATE;
00837
00838
if ((hFile = OpenFile(
OpenFileName.lpstrFile, &OfStruct,
00839 wStyle)) == -1)
00840 {
00841
sprintf( buf,
"Could not create file %s",
OpenFileName.lpstrFile );
00842 MessageBox(
hWnd, buf,
NULL, MB_OK );
00843
return FALSE;
00844 }
00845
00846
if (_lwrite( hFile, (LPSTR)&
FileBuf[0],
dwFileSize)==-1)
00847 {
00848 MessageBox(
hWnd,
"Error writing file.",
NULL, MB_OK );
00849
return FALSE;
00850 }
00851
00852
00853 _lclose( hFile );
00854
00855
sprintf( buf,
"%s",
OpenFileName.lpstrFile );
00856 MessageBox(
hWnd, buf,
"File Saved", MB_OK );
00857
return TRUE;
00858 }
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885 BOOL CALLBACK
FileSaveHookProc(
00886 HWND hDlg,
00887 UINT message,
00888 WPARAM wParam,
00889 LPARAM lParam)
00890 {
00891
CHAR szTempText[256];
00892
CHAR szString[256];
00893
00894
switch (message)
00895 {
00896
case WM_COMMAND:
00897
if (LOWORD(wParam) == IDOK)
00898 {
00899
GetDlgItemText( hDlg, edt1, szTempText,
00900
sizeof( szTempText ) - 1);
00901
if (
OpenFileName.Flags & OFN_ENABLETEMPLATE )
00902 {
00903
00904
if ( (
BOOL)(
SendMessage(
GetDlgItem(hDlg, chx2),
00905 BM_GETCHECK, 0, 0
L )) ==
FALSE )
00906
OpenFileName.Flags |= OFN_FILEMUSTEXIST;
00907
break;
00908
00909 }
00910
else
00911 {
00912
sprintf( szString,
"Are you sure you want to save %s?",
00913 szTempText);
00914
if ( MessageBox( hDlg, szString,
"Information",
00915 MB_YESNO ) == IDYES )
00916
break;
00917
return(
TRUE);
00918 }
00919
00920 }
00921
break;
00922 }
00923
return (
FALSE);
00924
00925
00926 lParam;
00927
00928 }
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948 BOOL SaveAs( HWND hWnd )
00949 {
00950
int i;
00951
00952
00953
00954
00955
for ( i = lstrlen(
OpenFileName.lpstrFileTitle); i > 0; i--)
00956 {
00957
if (
OpenFileName.lpstrFileTitle[i] ==
'.')
break;
00958 }
00959 i ++;
00960
if (
wCSAorCRD ==
IDM_CSA)
00961 {
00962
OpenFileName.lpstrFileTitle[i++] =
'C';
00963
OpenFileName.lpstrFileTitle[i++] =
'S';
00964
OpenFileName.lpstrFileTitle[i++] =
'A';
00965
OpenFileName.lpstrFileTitle[i] = 0;
00966 }
00967
else if ((
wCSAorCRD ==
IDM_CRD) ||
00968 (
wCSAorCRD ==
IDM_PROFCRD))
00969 {
00970
OpenFileName.lpstrFileTitle[i++] =
'C';
00971
OpenFileName.lpstrFileTitle[i++] =
'R';
00972
OpenFileName.lpstrFileTitle[i++] =
'D';
00973
OpenFileName.lpstrFileTitle[i] = 0;
00974 }
00975
else
00976 {
00977
OpenFileName.lpstrFileTitle[i++] =
'I';
00978
OpenFileName.lpstrFileTitle[i++] =
'N';
00979
OpenFileName.lpstrFileTitle[i++] =
'T';
00980
OpenFileName.lpstrFileTitle[i] = 0;
00981 }
00982 strcpy(
OpenFileName.lpstrFile,
OpenFileName.lpstrFileTitle);
00983
00984
OpenFileName.lStructSize =
sizeof(OPENFILENAME);
00985
OpenFileName.hwndOwner =
hWnd;
00986
OpenFileName.hInstance = (HANDLE)
hInst;
00987
OpenFileName.lpstrFilter =
szSaveFilter;
00988
OpenFileName.lpstrCustomFilter = (LPSTR)
NULL;
00989
OpenFileName.nMaxCustFilter = 0
L;
00990
OpenFileName.nFilterIndex = 1
L;
00991
OpenFileName.nMaxFile =
sizeof(
szFile);
00992
OpenFileName.nMaxFileTitle =
sizeof(
szFileTitle);
00993
OpenFileName.lpstrInitialDir =
NULL;
00994
OpenFileName.lpstrTitle =
"Save File As";
00995
OpenFileName.nFileOffset = 0;
00996
OpenFileName.nFileExtension = 0;
00997
OpenFileName.lpstrDefExt =
"*.csa";
00998
OpenFileName.lCustData = 0;
00999
01000
switch(
wMode )
01001 {
01002
case IDM_STANDARD:
01003
OpenFileName.Flags = 0
L;
01004
OpenFileName.lpfnHook = (LPOFNHOOKPROC)(FARPROC)
NULL;
01005
OpenFileName.lpTemplateName = (LPSTR)
NULL;
01006
break;
01007
01008
case IDM_HOOK:
01009
OpenFileName.Flags = OFN_ENABLEHOOK;
01010
OpenFileName.lpfnHook = (LPOFNHOOKPROC)MakeProcInstance(
FileSaveHookProc,
NULL);
01011
OpenFileName.lpTemplateName = (LPSTR)
NULL;
01012
break;
01013
01014
case IDM_CUSTOM:
01015
OpenFileName.Flags = OFN_ENABLEHOOK | OFN_ENABLETEMPLATE;
01016
OpenFileName.lpfnHook = (LPOFNHOOKPROC)MakeProcInstance(
FileSaveHookProc,
NULL);
01017
OpenFileName.lpTemplateName = (LPSTR)MAKEINTRESOURCE(FILEOPENORD);
01018
break;
01019 }
01020
01021
if ( GetSaveFileName( &
OpenFileName ))
01022 {
01023
return (
TRUE);
01024 }
01025
else
01026 {
01027
ProcessCDError(CommDlgExtendedError(),
hWnd );
01028
return FALSE;
01029 }
01030
01031
return (
FALSE);
01032 }
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055 BOOL CALLBACK
ChooseColorHookProc(
01056 HWND hDlg,
01057 UINT message,
01058 WPARAM wParam,
01059 LPARAM lParam)
01060 {
01061
01062
switch (message)
01063 {
01064
case WM_COMMAND:
01065
if (LOWORD(wParam) == IDOK)
01066 {
01067
if (MessageBox( hDlg,
"Are you sure you want to change the color?",
01068
"Information", MB_YESNO ) == IDYES )
01069
break;
01070
return (
TRUE);
01071
01072 }
01073
break;
01074 }
01075
return (
FALSE);
01076
01077
01078 lParam;
01079
01080 }
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100 BOOL ChooseNewColor( HWND hWnd )
01101 {
01102
01103
DWORD dwColor;
01104
DWORD dwCustClrs[16];
01105
BOOL fSetColor =
FALSE;
01106
int i;
01107
01108
01109
for (i=0; i < 15; i++)
01110 dwCustClrs[i] = RGB( 255, 255, 255);
01111
01112 dwColor = RGB( 0, 0, 0 );
01113
01114
chsclr.lStructSize =
sizeof(CHOOSECOLOR);
01115
chsclr.hwndOwner =
hWnd;
01116
chsclr.hInstance = (HANDLE)
hInst;
01117
chsclr.rgbResult = dwColor;
01118
chsclr.lpCustColors = (LPDWORD)dwCustClrs;
01119
chsclr.lCustData = 0
L;
01120
01121
switch(
wMode )
01122 {
01123
case IDM_HOOK:
01124
case IDM_CUSTOM:
01125
chsclr.Flags = CC_PREVENTFULLOPEN | CC_ENABLEHOOK;
01126
chsclr.lpfnHook = (LPCCHOOKPROC)MakeProcInstance(
ChooseColorHookProc,
NULL);
01127
chsclr.lpTemplateName = (LPSTR)
NULL;
01128
break;
01129
01130
case IDM_STANDARD:
01131
chsclr.Flags = CC_PREVENTFULLOPEN;
01132
chsclr.lpfnHook = (LPCCHOOKPROC)(FARPROC)
NULL;
01133
chsclr.lpTemplateName = (LPSTR)
NULL;
01134
break;
01135
01136
01137 }
01138
01139
if ( fSetColor = ChooseColor( &
chsclr ))
01140 {
01141
crColor =
chsclr.rgbResult;
01142
return (
TRUE);
01143 }
01144
else
01145 {
01146
ProcessCDError(CommDlgExtendedError(),
hWnd );
01147
return FALSE;
01148 }
01149 }
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175 BOOL CALLBACK
ChooseFontHookProc(
01176 HWND hDlg,
01177 UINT message,
01178 WPARAM wParam,
01179 LPARAM lParam)
01180 {
01181
01182
switch (message)
01183 {
01184
case WM_INITDIALOG:
01185
if (
chf.Flags & CF_ENABLETEMPLATE)
01186 {
01187
ShowWindow(
GetDlgItem(hDlg, stc4), SW_HIDE);
01188
ShowWindow(
GetDlgItem(hDlg, cmb4), SW_HIDE);
01189 }
01190
break;
01191
01192
case WM_COMMAND:
01193
if (LOWORD(wParam) == IDOK)
01194 {
01195
if (MessageBox( hDlg,
"Are you sure you want to change the font?",
01196
"Information", MB_YESNO ) == IDYES )
01197
break;
01198
return (
TRUE);
01199
01200 }
01201
break;
01202 }
01203
return (
FALSE);
01204
01205
01206 lParam;
01207
01208 }
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228 BOOL ChooseNewFont( HWND hWnd )
01229 {
01230
01231 HDC hDC;
01232
01233 hDC =
GetDC(
hWnd );
01234
chf.hDC = CreateCompatibleDC( hDC );
01235
ReleaseDC(
hWnd, hDC );
01236
chf.lStructSize =
sizeof(CHOOSEFONT);
01237
chf.hwndOwner =
hWnd;
01238
chf.lpLogFont = &
lf;
01239
chf.Flags = CF_SCREENFONTS | CF_EFFECTS;
01240
chf.rgbColors = RGB(0, 255, 255);
01241
chf.lCustData = 0;
01242
chf.hInstance = (HANDLE)
hInst;
01243
chf.lpszStyle = (LPSTR)
NULL;
01244
chf.nFontType = SCREEN_FONTTYPE;
01245
chf.nSizeMin = 0;
01246
chf.nSizeMax = 0;
01247
01248
switch(
wMode )
01249 {
01250
case IDM_STANDARD:
01251
chf.Flags = CF_SCREENFONTS | CF_EFFECTS;
01252
chf.lpfnHook = (LPCFHOOKPROC)(FARPROC)
NULL;
01253
chf.lpTemplateName = (LPSTR)
NULL;
01254
break;
01255
01256
case IDM_HOOK:
01257
chf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_ENABLEHOOK;
01258
chf.lpfnHook = (LPCFHOOKPROC)MakeProcInstance(
ChooseFontHookProc,
NULL);
01259
chf.lpTemplateName = (LPSTR)
NULL;
01260
break;
01261
01262
case IDM_CUSTOM:
01263
chf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_ENABLEHOOK |
01264 CF_ENABLETEMPLATE;
01265
chf.lpfnHook = (LPCFHOOKPROC)MakeProcInstance(
ChooseFontHookProc,
NULL);
01266
chf.lpTemplateName = (LPSTR)MAKEINTRESOURCE(FORMATDLGORD31);
01267
break;
01268 }
01269
01270
01271
if( ChooseFont( &
chf ) ==
FALSE )
01272 {
01273 DeleteDC( hDC );
01274
ProcessCDError(CommDlgExtendedError(),
hWnd );
01275
return FALSE;
01276 }
01277
01278
01279 DeleteDC( hDC );
01280
01281
return (
TRUE);
01282 }
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304 BOOL CALLBACK
PrintSetupHookProc(
01305 HWND hDlg,
01306 UINT message,
01307 WPARAM wParam,
01308 LPARAM lParam)
01309 {
01310
01311
switch (message)
01312 {
01313
case WM_INITDIALOG:
01314
if (
pd.Flags & PD_ENABLESETUPTEMPLATE )
01315 {
01316
ShowWindow(
GetDlgItem(hDlg, psh1), SW_HIDE );
01317
return(
TRUE);
01318 }
01319 MessageBox( hDlg,
01320
"Hook installed.",
01321
"Information", MB_OK );
01322
return (
TRUE);
01323 }
01324
return (
FALSE);
01325
01326
01327 lParam;
01328 wParam;
01329 }
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355 BOOL CALLBACK
PrintDlgHookProc(
01356 HWND hDlg,
01357 UINT message,
01358 WPARAM wParam,
01359 LPARAM lParam)
01360 {
01361
01362
switch (message)
01363 {
01364
case WM_INITDIALOG:
01365
if (
pd.Flags & PD_ENABLEPRINTTEMPLATE )
01366 {
01367
ShowWindow(
GetDlgItem(hDlg, chx1), SW_HIDE );
01368
ShowWindow(
GetDlgItem(hDlg, chx2), SW_HIDE );
01369
return(
TRUE);
01370 }
01371 MessageBox( hDlg,
01372
"Hook installed.",
01373
"Information", MB_OK );
01374
return (
TRUE);
01375
01376
case WM_COMMAND:
01377
if (LOWORD(wParam) == IDOK)
01378 {
01379
if (MessageBox( hDlg,
"Are you sure you want to print?",
01380
"Information", MB_YESNO ) == IDYES )
01381
break;
01382
return (
TRUE);
01383
01384 }
01385
break;
01386 }
01387
return (
FALSE);
01388
01389
01390 lParam;
01391
01392 }
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418 void PrintFile( HWND hWnd )
01419 {
01420
01421
01422
01423
pd.lStructSize =
sizeof(PRINTDLG);
01424
pd.hwndOwner =
hWnd;
01425
pd.hDevMode = (HANDLE)
NULL;
01426
pd.hDevNames = (HANDLE)
NULL;
01427
pd.nFromPage = 0;
01428
pd.nToPage = 0;
01429
pd.nMinPage = 0;
01430
pd.nMaxPage = 0;
01431
pd.nCopies = 0;
01432
pd.hInstance = (HANDLE)
hInst;
01433
01434
01435
switch(
wMode )
01436 {
01437
case IDM_STANDARD:
01438
pd.Flags = PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION | PD_PRINTSETUP;
01439
pd.lpfnSetupHook = (LPSETUPHOOKPROC)(FARPROC)
NULL;
01440
pd.lpSetupTemplateName = (LPSTR)
NULL;
01441
pd.lpfnPrintHook = (LPPRINTHOOKPROC)(FARPROC)
NULL;
01442
pd.lpPrintTemplateName = (LPSTR)
NULL;
01443
break;
01444
01445
case IDM_HOOK:
01446
pd.Flags = PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION |
01447 PD_ENABLEPRINTHOOK | PD_ENABLESETUPHOOK | PD_PRINTSETUP;
01448
pd.lpfnSetupHook = (LPSETUPHOOKPROC)MakeProcInstance(
PrintSetupHookProc,
NULL);
01449
pd.lpSetupTemplateName = (LPSTR)
NULL;
01450
pd.lpfnPrintHook = (LPPRINTHOOKPROC)MakeProcInstance(
PrintDlgHookProc,
NULL);
01451
pd.lpPrintTemplateName = (LPSTR)
NULL;
01452
break;
01453
01454
case IDM_CUSTOM:
01455
pd.Flags = PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION |
01456 PD_ENABLEPRINTHOOK | PD_ENABLEPRINTTEMPLATE |
01457 PD_ENABLESETUPHOOK | PD_ENABLESETUPTEMPLATE | PD_PRINTSETUP;
01458
pd.lpfnSetupHook = (LPSETUPHOOKPROC)MakeProcInstance(
PrintSetupHookProc,
NULL);
01459
pd.lpSetupTemplateName = (LPSTR)MAKEINTRESOURCE(PRNSETUPDLGORD);
01460
pd.lpfnPrintHook = (LPPRINTHOOKPROC)MakeProcInstance(
PrintDlgHookProc,
NULL);
01461
pd.lpPrintTemplateName = (LPSTR)MAKEINTRESOURCE(PRINTDLGORD);
01462
break;
01463
01464 }
01465
01466
01467
if (PrintDlg(&
pd) ==
TRUE)
01468 {
01469 Escape(
pd.hDC, STARTDOC, 8,
"Test-Doc",
NULL);
01470
01471
01472 TextOut(
pd.hDC, 5, 5,
FileBuf,
strlen(
FileBuf));
01473
01474 Escape(
pd.hDC, NEWFRAME, 0,
NULL,
NULL);
01475 Escape(
pd.hDC, ENDDOC, 0,
NULL,
NULL );
01476 DeleteDC(
pd.hDC);
01477
if (
pd.hDevMode)
01478 GlobalFree(
pd.hDevMode);
01479
if (
pd.hDevNames)
01480 GlobalFree(
pd.hDevNames);
01481 }
01482
else
01483
ProcessCDError(CommDlgExtendedError(),
hWnd );
01484 }
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506 BOOL CALLBACK
ReplaceTextHookProc(
01507 HWND hDlg,
01508 UINT message,
01509 WPARAM wParam,
01510 LPARAM lParam)
01511 {
01512
switch (message)
01513 {
01514
case WM_INITDIALOG:
01515
if (
frText.Flags & FR_ENABLETEMPLATE )
01516 {
01517
ShowWindow(
GetDlgItem(hDlg, psh2), SW_HIDE );
01518
ShowWindow(
GetDlgItem(hDlg, chx1), SW_HIDE );
01519
ShowWindow(
GetDlgItem(hDlg, chx2), SW_HIDE );
01520 }
01521 MessageBox( hDlg,
01522
"Hook installed.",
01523
"Information", MB_OK );
01524
return (
TRUE);
01525
01526
01527
default:
01528
break;
01529 }
01530
return (
FALSE);
01531
01532
01533 lParam;
01534 wParam;
01535 }
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556 BOOL CALLBACK
FindTextHookProc(
01557 HWND hDlg,
01558 UINT message,
01559 WPARAM wParam,
01560 LPARAM lParam)
01561 {
01562
01563
switch (message)
01564 {
01565
case WM_INITDIALOG:
01566
if (
frText.Flags & FR_ENABLETEMPLATE )
01567 {
01568
ShowWindow(
GetDlgItem(hDlg, chx1), SW_HIDE);
01569
ShowWindow(
GetDlgItem(hDlg, grp1), SW_HIDE);
01570
ShowWindow(
GetDlgItem(hDlg, chx2), SW_HIDE);
01571
ShowWindow(
GetDlgItem(hDlg, rad1), SW_HIDE);
01572
ShowWindow(
GetDlgItem(hDlg, rad2), SW_HIDE);
01573 }
01574 MessageBox( hDlg,
01575
"Hook installed.",
01576
"Information", MB_OK );
01577
return (
TRUE);
01578
01579
01580
default:
01581
break;
01582 }
01583
return (
FALSE);
01584
01585
01586 lParam;
01587 wParam;
01588 }
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608 void CallFindText( HWND hWnd )
01609 {
01610
01611
frText.lStructSize =
sizeof(
frText );
01612
frText.hwndOwner =
hWnd;
01613
frText.hInstance = (HANDLE)
hInst;
01614
frText.lpstrFindWhat =
szFindString;
01615
frText.lpstrReplaceWith = (LPSTR)
NULL;
01616
frText.wFindWhatLen =
sizeof(
szFindString);
01617
frText.wReplaceWithLen = 0;
01618
frText.lCustData = 0;
01619
lpBufPtr =
FileBuf;
01620
01621
switch(
wMode )
01622 {
01623
case IDM_STANDARD:
01624
frText.Flags = FR_NOMATCHCASE | FR_NOUPDOWN | FR_NOWHOLEWORD;
01625
frText.lpfnHook = (LPFRHOOKPROC)(FARPROC)
NULL;
01626
frText.lpTemplateName = (LPSTR)
NULL;
01627
break;
01628
01629
case IDM_HOOK:
01630
frText.Flags = FR_NOMATCHCASE | FR_NOUPDOWN | FR_NOWHOLEWORD |
01631 FR_ENABLEHOOK;
01632
frText.lpfnHook = (LPFRHOOKPROC)MakeProcInstance(
FindTextHookProc,
NULL);
01633
frText.lpTemplateName = (LPSTR)
NULL;
01634
break;
01635
01636
case IDM_CUSTOM:
01637
frText.Flags = FR_NOMATCHCASE | FR_NOUPDOWN | FR_NOWHOLEWORD |
01638 FR_ENABLEHOOK | FR_ENABLETEMPLATE;
01639
frText.lpfnHook = (LPFRHOOKPROC)MakeProcInstance(
FindTextHookProc,
NULL);
01640
frText.lpTemplateName = (LPSTR)MAKEINTRESOURCE(FINDDLGORD);
01641
break;
01642 }
01643
01644
if ((
hDlgFR = FindText(&
frText)) ==
NULL)
01645
ProcessCDError(CommDlgExtendedError(),
hWnd );
01646
01647 }
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667 void CallReplaceText( HWND hWnd )
01668 {
01669
frText.lStructSize =
sizeof(
frText );
01670
frText.hwndOwner =
hWnd;
01671
frText.hInstance = (HANDLE)
hInst;
01672
frText.lpstrFindWhat =
szFindString;
01673
frText.lpstrReplaceWith =
szReplaceString;
01674
frText.wFindWhatLen =
sizeof(
szFindString);
01675
frText.wReplaceWithLen =
sizeof(
szReplaceString );
01676
frText.lCustData = 0;
01677
lpBufPtr =
FileBuf;
01678
01679
switch(
wMode )
01680 {
01681
case IDM_STANDARD:
01682
frText.Flags = FR_NOMATCHCASE | FR_NOUPDOWN | FR_NOWHOLEWORD;
01683
frText.lpfnHook = (LPFRHOOKPROC)(FARPROC)
NULL;
01684
frText.lpTemplateName = (LPSTR)
NULL;
01685
break;
01686
01687
case IDM_HOOK:
01688
frText.Flags = FR_NOMATCHCASE | FR_NOUPDOWN | FR_NOWHOLEWORD |
01689 FR_ENABLEHOOK;
01690
frText.lpfnHook = (LPFRHOOKPROC)MakeProcInstance(
ReplaceTextHookProc,
NULL);
01691
frText.lpTemplateName = (LPSTR)
NULL;
01692
break;
01693
01694
case IDM_CUSTOM:
01695
frText.Flags = FR_NOMATCHCASE | FR_NOUPDOWN | FR_NOWHOLEWORD |
01696 FR_ENABLEHOOK | FR_ENABLETEMPLATE;
01697
frText.lpfnHook = (LPFRHOOKPROC)MakeProcInstance(
ReplaceTextHookProc,
NULL);
01698
frText.lpTemplateName = (LPSTR)MAKEINTRESOURCE(REPLACEDLGORD);
01699
break;
01700 }
01701
01702
if ( (
hDlgFR = ReplaceText( &
frText )) ==
NULL )
01703
ProcessCDError(CommDlgExtendedError(),
hWnd );
01704
01705 }
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725 void SearchFile( LPFINDREPLACE lpFR )
01726 {
01727
01728
CHAR Buf[
FILE_LEN];
01729
CHAR *pStr;
01730
int count, newcount;
01731
static BOOL bFoundLast =
FALSE;
01732
01733
if (
lpFR->Flags & ( FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL ) )
01734 {
01735 memset(Buf,
'\0',
FILE_LEN -1);
01736
if ( bFoundLast )
01737 {
01738
if ( (
lpBufPtr !=
FileBuf) && (
lpFR->Flags & FR_FINDNEXT) )
01739
lpBufPtr++;
01740 bFoundLast =
FALSE;
01741 }
01742
01743
if (!*
lpBufPtr || !(pStr = strstr(
lpBufPtr,
lpFR->lpstrFindWhat ) ) )
01744 {
01745
sprintf( Buf,
"'%s' not found!",
lpFR->lpstrFindWhat );
01746
lpBufPtr =
FileBuf;
01747 MessageBox(
lpFR->hwndOwner, Buf,
"No luck", MB_OK | MB_TASKMODAL);
01748 }
01749
else
01750 {
01751
if (
lpFR->Flags & FR_FINDNEXT )
01752 {
01753
sprintf( Buf,
"Found Next '%s'!\nSubstring: '%.10s'",
01754
lpFR->lpstrFindWhat, pStr );
01755
lpBufPtr = pStr;
01756 bFoundLast =
TRUE;
01757 MessageBox(
lpFR->hwndOwner, Buf,
"Success!", MB_OK | MB_TASKMODAL );
01758 }
01759
else if (
lpFR->Flags & FR_REPLACE )
01760 {
01761
01762
01763
for( count=0;
01764 *pStr &&
lpBufPtr[count] && *pStr !=
lpBufPtr[count];
01765 count++);
01766 strncpy( Buf,
lpBufPtr, count );
01767
01768 strcat( Buf,
lpFR->lpstrReplaceWith );
01769
01770 newcount = count +
strlen(
lpFR->lpstrFindWhat);
01771 strcat( Buf,
lpBufPtr+newcount);
01772 strcpy(
lpBufPtr, Buf );
01773
lpBufPtr += count +
strlen(
lpFR->lpstrReplaceWith);
01774
dwFileSize =
strlen(
FileBuf);
01775 MessageBox(
lpFR->hwndOwner,
FileBuf,
"Success!", MB_OK | MB_TASKMODAL );
01776 }
01777
else if (
lpFR->Flags & FR_REPLACEALL)
01778 {
01779
do
01780 {
01781
01782
01783 memset(Buf,
'\0',
FILE_LEN -1);
01784
for( count=0;
01785 *pStr &&
lpBufPtr[count] && *pStr !=
lpBufPtr[count];
01786 count++);
01787 strncpy( Buf,
lpBufPtr, count );
01788
01789 strcat( Buf,
lpFR->lpstrReplaceWith );
01790
01791 newcount = count +
strlen(
lpFR->lpstrFindWhat);
01792 strcat( Buf,
lpBufPtr + newcount);
01793 strcpy(
lpBufPtr, Buf );
01794
lpBufPtr += count +
strlen(
lpFR->lpstrReplaceWith);
01795 }
01796
while ( *
lpBufPtr &&
01797 (pStr = strstr(
lpBufPtr,
lpFR->lpstrFindWhat ) ) );
01798
dwFileSize =
strlen(
FileBuf);
01799
lpBufPtr =
FileBuf;
01800 MessageBox(
lpFR->hwndOwner,
FileBuf,
01801
"Success!", MB_OK | MB_TASKMODAL );
01802 }
01803
01804 }
01805 }
01806 }
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826 void ProcessCDError(DWORD dwErrorCode, HWND hWnd)
01827 {
01828 WORD wStringID;
01829
CHAR buf[256];
01830
01831
switch(dwErrorCode)
01832 {
01833
case CDERR_DIALOGFAILURE: wStringID=
IDS_DIALOGFAILURE;
break;
01834
case CDERR_STRUCTSIZE: wStringID=
IDS_STRUCTSIZE;
break;
01835
case CDERR_INITIALIZATION: wStringID=
IDS_INITIALIZATION;
break;
01836
case CDERR_NOTEMPLATE: wStringID=
IDS_NOTEMPLATE;
break;
01837
case CDERR_NOHINSTANCE: wStringID=
IDS_NOHINSTANCE;
break;
01838
case CDERR_LOADSTRFAILURE: wStringID=
IDS_LOADSTRFAILURE;
break;
01839
case CDERR_FINDRESFAILURE: wStringID=
IDS_FINDRESFAILURE;
break;
01840
case CDERR_LOADRESFAILURE: wStringID=
IDS_LOADRESFAILURE;
break;
01841
case CDERR_LOCKRESFAILURE: wStringID=
IDS_LOCKRESFAILURE;
break;
01842
case CDERR_MEMALLOCFAILURE: wStringID=
IDS_MEMALLOCFAILURE;
break;
01843
case CDERR_MEMLOCKFAILURE: wStringID=
IDS_MEMLOCKFAILURE;
break;
01844
case CDERR_NOHOOK: wStringID=
IDS_NOHOOK;
break;
01845
case PDERR_SETUPFAILURE: wStringID=
IDS_SETUPFAILURE;
break;
01846
case PDERR_PARSEFAILURE: wStringID=
IDS_PARSEFAILURE;
break;
01847
case PDERR_RETDEFFAILURE: wStringID=
IDS_RETDEFFAILURE;
break;
01848
case PDERR_LOADDRVFAILURE: wStringID=
IDS_LOADDRVFAILURE;
break;
01849
case PDERR_GETDEVMODEFAIL: wStringID=
IDS_GETDEVMODEFAIL;
break;
01850
case PDERR_INITFAILURE: wStringID=
IDS_INITFAILURE;
break;
01851
case PDERR_NODEVICES: wStringID=
IDS_NODEVICES;
break;
01852
case PDERR_NODEFAULTPRN: wStringID=
IDS_NODEFAULTPRN;
break;
01853
case PDERR_DNDMMISMATCH: wStringID=
IDS_DNDMMISMATCH;
break;
01854
case PDERR_CREATEICFAILURE: wStringID=
IDS_CREATEICFAILURE;
break;
01855
case PDERR_PRINTERNOTFOUND: wStringID=
IDS_PRINTERNOTFOUND;
break;
01856
case CFERR_NOFONTS: wStringID=
IDS_NOFONTS;
break;
01857
case FNERR_SUBCLASSFAILURE: wStringID=
IDS_SUBCLASSFAILURE;
break;
01858
case FNERR_INVALIDFILENAME: wStringID=
IDS_INVALIDFILENAME;
break;
01859
case FNERR_BUFFERTOOSMALL: wStringID=
IDS_BUFFERTOOSMALL;
break;
01860
01861
case 0:
01862
return;
01863
01864
default:
01865 wStringID=
IDS_UNKNOWNERROR;
01866 }
01867
01868 LoadString(
NULL, wStringID, buf,
sizeof(buf));
01869 MessageBox(
hWnd, buf,
NULL, MB_OK);
01870
return;
01871 }
01872
01873
01874
01875 BOOL WINAPI
OpenFiles(
01876 HWND hDlg,
01877 UINT message,
01878 WPARAM wParam,
01879 LPARAM lParam)
01880 {
01881
int Length;
01882
char DevProfileName[
FILE_LEN];
01883
char TargetProfileName[
FILE_LEN];
01884
char OutputFileName[
FILE_LEN];
01885 WORD InpClrSp;
01886
01887
switch (message)
01888 {
01889
case WM_INITDIALOG:
01890
return (
TRUE);
01891
01892
case WM_COMMAND:
01893
switch (LOWORD(wParam))
01894 {
01895
case IDC_BUTTON1:
01896
if (
OpenNewFile(
hWnd ) ==
TRUE )
01897
SendDlgItemMessage(hDlg,
IDC_EDIT1, WM_SETTEXT, 0, (
long)(
OpenFileName.lpstrFile));
01898
break;
01899
case IDC_BUTTON2:
01900
if (
OpenNewFile(
hWnd ) ==
TRUE )
01901
SendDlgItemMessage(hDlg,
IDC_EDIT2, WM_SETTEXT, 0, (
long)(
OpenFileName.lpstrFile));
01902
break;
01903
case IDC_BUTTON3:
01904
if (
SaveAs(
hWnd ) ==
TRUE )
01905
SendDlgItemMessage(hDlg,
IDC_EDIT3, WM_SETTEXT, 0, (
long)(
OpenFileName.lpstrFile));
01906
break;
01907
case IDOK:
01908 Length =
SendDlgItemMessage(hDlg,
IDC_EDIT1, WM_GETTEXTLENGTH, 0, 0);
01909
SendDlgItemMessage(hDlg,
IDC_EDIT1, WM_GETTEXT, Length + 1, (
long)(DevProfileName));
01910 Length =
SendDlgItemMessage(hDlg,
IDC_EDIT2, WM_GETTEXTLENGTH, 0, 0);
01911
SendDlgItemMessage(hDlg,
IDC_EDIT2, WM_GETTEXT, Length + 1, (
long)(TargetProfileName));
01912 Length =
SendDlgItemMessage(hDlg,
IDC_EDIT3, WM_GETTEXTLENGTH, 0, 0);
01913
SendDlgItemMessage(hDlg,
IDC_EDIT3, WM_GETTEXT, Length + 1, (
long)(OutputFileName));
01914
switch (
wInpDrvClrSp)
01915 {
01916
case IDM_INP_AUTO: InpClrSp = 0;
break;
01917
case IDM_INP_GRAY: InpClrSp = 1;
break;
01918
case IDM_INP_RGB: InpClrSp = 3;
break;
01919
case IDM_INP_CMYK: InpClrSp = 4;
break;
01920
default: InpClrSp = 0;
break;
01921 }
01922
if (
wCSAorCRD ==
IDM_CSA)
01923 {
01924
ColorSpaceControl(DevProfileName, OutputFileName,
01925 InpClrSp,
Intent,
wCSAMode,
AllowBinary);
01926 }
01927
else if (
wCSAorCRD ==
IDM_CRD)
01928 {
01929
CreateCRDControl(DevProfileName, OutputFileName,
01930
Intent,
AllowBinary);
01931 }
01932
else if (
wCSAorCRD ==
IDM_PROFCRD)
01933 {
01934
CreateProfCRDControl(DevProfileName,
01935 TargetProfileName, OutputFileName,
01936
Intent,
AllowBinary);
01937 }
01938
else
01939 {
01940
CreateINTENTControl(DevProfileName, OutputFileName,
Intent);
01941 }
01942
01943
case IDCANCEL:
01944
EndDialog(hDlg,
TRUE);
01945
return (
TRUE);
01946 }
01947
break;
01948 }
01949
return (
FALSE);
01950
01951
01952 lParam;
01953 }