Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

main.c File Reference

#include <windows.h>
#include <commdlg.h>
#include <dlgs.h>
#include <stdio.h>
#include <string.h>
#include <cderr.h>
#include "main.h"
#include "resource.h"

Go to the source code of this file.

Functions

BOOL WINAPI OpenFiles (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
BOOL InitApplication (HANDLE hInstance)
BOOL InitInstance (HANDLE hInstance, int nCmdShow)
LRESULT CALLBACK MainWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK EnterNew (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL WINAPI About (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK FileOpenHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL OpenNewFile (HWND hWnd)
BOOL SaveToFile (HWND hWnd)
BOOL CALLBACK FileSaveHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL SaveAs (HWND hWnd)
BOOL CALLBACK ChooseColorHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL ChooseNewColor (HWND hWnd)
BOOL CALLBACK ChooseFontHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL ChooseNewFont (HWND hWnd)
BOOL CALLBACK PrintSetupHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK PrintDlgHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
void PrintFile (HWND hWnd)
BOOL CALLBACK ReplaceTextHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK FindTextHookProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
void CallFindText (HWND hWnd)
void CallReplaceText (HWND hWnd)
void SearchFile (LPFINDREPLACE lpFR)
void ProcessCDError (DWORD dwErrorCode, HWND hWnd)

Variables

HANDLE hInst
OPENFILENAME OpenFileName
CHAR szDirName [256] = ""
CHAR szFile [256] = "\0"
CHAR szFileTitle [256]
CHAR szFilter [] = "Text Files (*.ICM)\0*.ICM\0All Files (*.*)\0*.*\0"
CHAR szSaveFilter [] = "Text Files (*.CSA)\0*.CSA\0All Files (*.*)\0*.*\0"
CHAR FileBuf [FILE_LEN]
DWORD dwFileSize
UINT FindReplaceMsg
CHAR szFindString [64] = ""
CHAR szReplaceString [64] = ""
FINDREPLACE frText
LPFINDREPLACE lpFR
CHARlpBufPtr = FileBuf
CHOOSEFONT chf
CHOOSECOLOR chsclr
COLORREF crColor
LOGFONT lf
WORD wMode = IDM_CUSTOM
WORD wAsciiMode = IDM_ASCII
WORD wIntentMode = IDM_PERCEPUAL
WORD wCSAMode = IDM_AUTO
WORD wInpDrvClrSp = IDM_INP_AUTO
WORD wCSAorCRD = IDM_CSA
HWND hDlgFR = NULL
PRINTDLG pd
BOOL AllowBinary = FALSE
DWORD Intent = 0
HWND hWnd


Function Documentation

BOOL WINAPI About HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 622 of file dec97/test/main.c.

References BOOL, EndDialog(), FALSE, and TRUE.

00627 { 00628 switch (message) 00629 { 00630 case WM_INITDIALOG: /* message: initialize dialog box */ 00631 return (TRUE); 00632 00633 case WM_COMMAND: /* message: received a command */ 00634 if (LOWORD(wParam) == IDOK /* "OK" box selected? */ 00635 || LOWORD(wParam) == IDCANCEL) { /* System menu close command? */ 00636 EndDialog(hDlg, TRUE); /* Exits the dialog box */ 00637 return (TRUE); 00638 } 00639 break; 00640 } 00641 return (FALSE); /* Didn't process a message */ 00642 00643 // avoid compiler warnings at W3 00644 lParam; 00645 }

void CallFindText HWND  hWnd  ) 
 

Definition at line 1608 of file dec97/test/main.c.

References FileBuf, FindTextHookProc(), frText, hDlgFR, hInst, hWnd, IDM_CUSTOM, IDM_HOOK, IDM_STANDARD, lpBufPtr, NULL, ProcessCDError(), szFindString, and wMode.

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 }

void CallReplaceText HWND  hWnd  ) 
 

Definition at line 1667 of file dec97/test/main.c.

References FileBuf, frText, hDlgFR, hInst, hWnd, IDM_CUSTOM, IDM_HOOK, IDM_STANDARD, lpBufPtr, NULL, ProcessCDError(), ReplaceTextHookProc(), szFindString, szReplaceString, and wMode.

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 }

BOOL CALLBACK ChooseColorHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 1055 of file dec97/test/main.c.

References BOOL, FALSE, and TRUE.

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 // avoid compiler warnings at W3 01078 lParam; 01079 01080 }

BOOL CALLBACK ChooseFontHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 1175 of file dec97/test/main.c.

References BOOL, chf, FALSE, GetDlgItem(), ShowWindow, and TRUE.

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 // avoid compiler warnings at W3 01206 lParam; 01207 01208 }

BOOL ChooseNewColor HWND  hWnd  ) 
 

Definition at line 1100 of file dec97/test/main.c.

References BOOL, ChooseColorHookProc(), chsclr, crColor, DWORD, FALSE, hInst, hWnd, IDM_CUSTOM, IDM_HOOK, IDM_STANDARD, L, NULL, ProcessCDError(), TRUE, and wMode.

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 = 0L; 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 }

BOOL ChooseNewFont HWND  hWnd  ) 
 

Definition at line 1228 of file dec97/test/main.c.

References BOOL, chf, ChooseFontHookProc(), FALSE, GetDC, hInst, hWnd, IDM_CUSTOM, IDM_HOOK, IDM_STANDARD, lf, NULL, ProcessCDError(), ReleaseDC(), TRUE, and wMode.

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 }

BOOL CALLBACK EnterNew HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 570 of file dec97/test/main.c.

References BOOL, CHAR, dwFileSize, EndDialog(), FALSE, FILE_LEN, FileBuf, GetDlgItemText(), IDEDIT, lpBufPtr, strlen(), and TRUE.

00575 { 00576 CHAR Buf[FILE_LEN-1]; 00577 00578 switch (message) 00579 { 00580 case WM_INITDIALOG: /* message: initialize dialog box */ 00581 return (TRUE); 00582 00583 case WM_COMMAND: /* message: received a 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 { /* System menu close command? */ 00595 EndDialog(hDlg, FALSE); /* Exits the dialog box */ 00596 return (TRUE); 00597 } 00598 break; 00599 } 00600 return (FALSE); /* Didn't process a message */ 00601 00602 // avoid compiler warnings at W3 00603 lParam; 00604 }

BOOL CALLBACK FileOpenHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 669 of file dec97/test/main.c.

References BOOL, CHAR, dwFileSize, FALSE, FileBuf, GetDlgItem(), GetDlgItemText(), L, lpBufPtr, NULL, OpenFileName, SendMessage(), sprintf(), strlen(), and TRUE.

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 // check to see if the Create File box has been checked 00702 if ( (BOOL)(SendMessage( GetDlgItem(hDlg, chx2), 00703 BM_GETCHECK, 0, 0L )) == TRUE ) 00704 { 00705 // if so, create the file 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 // close the file 00724 _lclose( hFile ); 00725 } 00726 00727 } 00728 break; 00729 } 00730 return (FALSE); 00731 00732 // avoid compiler warnings at W3 00733 lParam; 00734 00735 }

BOOL CALLBACK FileSaveHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 885 of file dec97/test/main.c.

References BOOL, CHAR, FALSE, GetDlgItem(), GetDlgItemText(), L, OpenFileName, SendMessage(), sprintf(), and TRUE.

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 // check to see if the Create File box has been checked 00904 if ( (BOOL)(SendMessage( GetDlgItem(hDlg, chx2), 00905 BM_GETCHECK, 0, 0L )) == 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 // avoid compiler warnings at W3 00926 lParam; 00927 00928 }

BOOL CALLBACK FindTextHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 1556 of file dec97/test/main.c.

References BOOL, FALSE, frText, GetDlgItem(), ShowWindow, and TRUE.

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 // avoid compiler warnings at W3 01586 lParam; 01587 wParam; 01588 }

BOOL InitApplication HANDLE  hInstance  ) 
 

Definition at line 185 of file dec97/test/main.c.

References BOOL, IDI_ICON1, MainWndProc(), NULL, and RegisterClass.

00186 { 00187 WNDCLASS wc; 00188 00189 /* Fill in window class structure with parameters that describe the */ 00190 /* main window. */ 00191 00192 wc.style = 0; /* Class style(s). */ 00193 wc.lpfnWndProc = (WNDPROC)MainWndProc; /* Function to retrieve messages for */ 00194 /* windows of this class. */ 00195 wc.cbClsExtra = 0; /* No per-class extra data. */ 00196 wc.cbWndExtra = 0; /* No per-window extra data. */ 00197 wc.hInstance = hInstance; /* Application that owns the class. */ 00198 wc.hIcon = LoadIcon(NULL, IDI_ICON1); 00199 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 00200 wc.hbrBackground = GetStockObject(WHITE_BRUSH); 00201 wc.lpszMenuName = "CmnDlgMenu"; /* Name of menu resource in .RC file. */ 00202 wc.lpszClassName = "CmnDlgWClass"; /* Name used in call to CreateWindow. */ 00203 00204 /* Register the window class and return success/failure code. */ 00205 00206 return (RegisterClass(&wc)); 00207 00208 }

BOOL InitInstance HANDLE  hInstance,
int  nCmdShow
 

Definition at line 224 of file dec97/test/main.c.

References BOOL, FALSE, hInst, hWnd, NULL, ShowWindow, TRUE, and UpdateWindow().

00227 { 00228 HWND hWND; /* Main window handle. */ 00229 00230 /* Save the instance handle in static variable, which will be used in */ 00231 /* many subsequence calls from this application to Windows. */ 00232 00233 hInst = hInstance; 00234 00235 /* Create a main window for this application instance. */ 00236 00237 hWND = CreateWindow( 00238 "CmnDlgWClass", /* See RegisterClass() call. */ 00239 "CIEBASED_CDEF Color Space", /* Text for window title bar. */ 00240 WS_OVERLAPPEDWINDOW, /* Window style. */ 00241 CW_USEDEFAULT, /* Default horizontal position. */ 00242 CW_USEDEFAULT, /* Default vertical position. */ 00243 CW_USEDEFAULT, /* Default width. */ 00244 CW_USEDEFAULT, /* Default height. */ 00245 NULL, /* Overlapped windows have no parent. */ 00246 NULL, /* Use the window class menu. */ 00247 hInstance, /* This instance owns this window. */ 00248 NULL /* Pointer not needed. */ 00249 ); 00250 00251 /* If window could not be created, return "failure" */ 00252 00253 if (!hWND) 00254 return (FALSE); 00255 00256 hWnd = hWND; 00257 /* Make the window visible; update its client area; and return "success" */ 00258 00259 ShowWindow(hWnd, nCmdShow); /* Show the window */ 00260 UpdateWindow(hWnd); /* Sends WM_PAINT message */ 00261 return (TRUE); /* Returns the value from PostQuitMessage */ 00262 00263 }

LRESULT CALLBACK MainWndProc HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 282 of file dec97/test/main.c.

References About(), AllowBinary, BeginPaint, BOOL, CallFindText(), CallReplaceText(), CheckMenuItem(), ChooseNewColor(), ChooseNewFont(), crColor, DefWindowProc(), DrawMenuBar(), dwFileSize, EnableMenuItem(), EnterNew(), FALSE, FileBuf, FindReplaceMsg, GetMenu(), Handle, hInst, hWnd, IDM_ABC, IDM_ABOUT, IDM_ASCII, IDM_AUTO, IDM_BINARY, IDM_CHOOSECOLOR, IDM_CHOOSEFONT, IDM_COLOR, IDM_CRD, IDM_CSA, IDM_CUSTOM, IDM_DEFG, IDM_ENTERNEW, IDM_EXIT, IDM_FINDTEXT, IDM_HOOK, IDM_INP_AUTO, IDM_INP_CMYK, IDM_INP_GRAY, IDM_INP_RGB, IDM_INTENT, IDM_OPENFILE, IDM_PERCEPUAL, IDM_PROFCRD, IDM_REPLACETEXT, IDM_SATURATION, IDM_STANDARD, INT, Intent, lf, lpBufPtr, lpFR, NULL, OpenFiles(), PostQuitMessage(), SearchFile(), strlen(), TRUE, wAsciiMode, wCSAMode, wCSAorCRD, wInpDrvClrSp, wIntentMode, and wMode.

00287 { 00288 FARPROC lpProcAbout; /* pointer to the "About" function */ 00289 FARPROC lpProcOpen; 00290 FARPROC lpProcEnterNew; /* pointer to the "EnterNew" function */ 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 //initialize the output on the screen 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 /* Set up a display context to begin painting */ 00314 hDC = BeginPaint (hWnd, &ps); 00315 00316 /* Initialize drawing position to 1/4 inch from the top */ 00317 /* and from the left of the top, left corner of the */ 00318 /* client area of the main windows. */ 00319 nDrawX = GetDeviceCaps(hDC, LOGPIXELSX) / 4; /* 1/4 inch */ 00320 nDrawY = GetDeviceCaps(hDC, LOGPIXELSY) / 4; /* 1/4 inch */ 00321 00322 if ( NewFont == TRUE ) 00323 { 00324 hFont = CreateFontIndirect( &lf ); 00325 Handle = SelectObject( hDC, hFont ); 00326 } 00327 00328 SetTextColor( hDC, crColor ); 00329 00330 // end painting and release hDC 00331 EndPaint( hWnd, &ps ); 00332 break; 00333 00334 00335 case WM_COMMAND: /* message: command from application menu */ 00336 00337 switch( LOWORD( wParam )) 00338 { 00339 case IDM_OPENFILE: 00340 lpProcOpen = MakeProcInstance((FARPROC)OpenFiles, hInst); 00341 00342 DialogBox(hInst, /* current instance */ 00343 "OPENFILES", /* resource to use */ 00344 hWnd, /* parent handle */ 00345 (DLGPROC)lpProcOpen); /* About() instance address */ 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 // enable the ChooseColor() option 00375 EnableMenuItem(GetMenu(hWnd), IDM_CHOOSECOLOR, 00376 MF_BYCOMMAND | MF_ENABLED ); 00377 // uncheck previous selection 00378 CheckMenuItem( GetMenu( hWnd ), wMode, MF_UNCHECKED | MF_BYCOMMAND); 00379 //reset mode 00380 wMode = LOWORD(wParam); 00381 //check new selection 00382 CheckMenuItem( GetMenu( hWnd ), wMode, MF_CHECKED | MF_BYCOMMAND); 00383 DrawMenuBar( hWnd); 00384 break; 00385 case IDM_HOOK: 00386 case IDM_CUSTOM: 00387 // disable the ChooseColor() option 00388 EnableMenuItem(GetMenu(hWnd), IDM_CHOOSECOLOR, 00389 MF_BYCOMMAND | MF_GRAYED ); 00390 // uncheck previous selection 00391 CheckMenuItem( GetMenu( hWnd ), wMode, MF_UNCHECKED | MF_BYCOMMAND); 00392 //reset mode 00393 wMode = LOWORD(wParam); 00394 //check new selection 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, /* current instance */ 00403 "EnterNewBox", /* resource to use */ 00404 hWnd, /* parent handle */ 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 //reset mode 00416 wIntentMode = LOWORD(wParam); 00417 //check new selection 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 //reset mode 00425 wIntentMode = LOWORD(wParam); 00426 //check new selection 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 //reset mode 00434 wIntentMode = LOWORD(wParam); 00435 //check new selection 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 //reset mode 00444 wAsciiMode = LOWORD(wParam); 00445 //check new selection 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 //reset mode 00453 wAsciiMode = LOWORD(wParam); 00454 //check new selection 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 //reset mode 00463 wCSAMode = LOWORD(wParam); 00464 //check new selection 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 //reset mode 00475 wInpDrvClrSp = LOWORD(wParam); 00476 //check new selection 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 //reset mode 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 //check new selection 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, /* current instance */ 00518 "AboutBox", /* resource to use */ 00519 hWnd, /* parent handle */ 00520 (DLGPROC)lpProcAbout); /* About() instance address */ 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: /* message: window being destroyed */ 00532 PostQuitMessage(0); 00533 break; 00534 00535 00536 default: 00537 // Handle the special findreplace message (FindReplaceMsg) which 00538 // was registered at initialization time. 00539 if ( message == FindReplaceMsg ) 00540 { 00541 if ( lpFR = (LPFINDREPLACE) lParam ) 00542 { 00543 if (lpFR->Flags & FR_DIALOGTERM ) // terminating dialog 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 }

BOOL WINAPI OpenFiles HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

BOOL OpenNewFile HWND  hWnd  ) 
 

Definition at line 755 of file dec97/test/main.c.

References BOOL, FALSE, FileOpenHookProc(), hInst, hWnd, IDM_CUSTOM, IDM_HOOK, IDM_STANDARD, L, NULL, OpenFileName, ProcessCDError(), szFile, szFileTitle, szFilter, TRUE, and wMode.

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 = 0L; 00766 OpenFileName.nFilterIndex = 1L; 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 }

BOOL CALLBACK PrintDlgHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 1355 of file dec97/test/main.c.

References BOOL, FALSE, GetDlgItem(), pd, ShowWindow, and TRUE.

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 // avoid compiler warnings at W3 01390 lParam; 01391 01392 }

void PrintFile HWND  hWnd  ) 
 

Definition at line 1418 of file dec97/test/main.c.

References FileBuf, hInst, hWnd, IDM_CUSTOM, IDM_HOOK, IDM_STANDARD, NULL, pd, PrintDlgHookProc(), PrintSetupHookProc(), ProcessCDError(), strlen(), TRUE, and wMode.

01419 { 01420 01421 01422 // initialize PRINTDLG structure 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 //print a test page if successful 01467 if (PrintDlg(&pd) == TRUE) 01468 { 01469 Escape(pd.hDC, STARTDOC, 8, "Test-Doc", NULL); 01470 01471 //Print text 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 }

BOOL CALLBACK PrintSetupHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 1304 of file dec97/test/main.c.

References BOOL, FALSE, GetDlgItem(), pd, ShowWindow, and TRUE.

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 // avoid compiler warnings at W3 01327 lParam; 01328 wParam; 01329 }

void ProcessCDError DWORD  dwErrorCode,
HWND  hWnd
 

Definition at line 1826 of file dec97/test/main.c.

References CDERR_DIALOGFAILURE, CDERR_FINDRESFAILURE, CDERR_INITIALIZATION, CDERR_LOADRESFAILURE, CDERR_LOADSTRFAILURE, CDERR_LOCKRESFAILURE, CDERR_MEMALLOCFAILURE, CDERR_MEMLOCKFAILURE, CDERR_NOHINSTANCE, CDERR_NOHOOK, CDERR_NOTEMPLATE, CDERR_STRUCTSIZE, CFERR_NOFONTS, CHAR, FNERR_BUFFERTOOSMALL, FNERR_INVALIDFILENAME, FNERR_SUBCLASSFAILURE, hWnd, IDS_BUFFERTOOSMALL, IDS_CREATEICFAILURE, IDS_DIALOGFAILURE, IDS_DNDMMISMATCH, IDS_FINDRESFAILURE, IDS_GETDEVMODEFAIL, IDS_INITFAILURE, IDS_INITIALIZATION, IDS_INVALIDFILENAME, IDS_LOADDRVFAILURE, IDS_LOADRESFAILURE, IDS_LOADSTRFAILURE, IDS_LOCKRESFAILURE, IDS_MEMALLOCFAILURE, IDS_MEMLOCKFAILURE, IDS_NODEFAULTPRN, IDS_NODEVICES, IDS_NOFONTS, IDS_NOHINSTANCE, IDS_NOHOOK, IDS_NOTEMPLATE, IDS_PARSEFAILURE, IDS_PRINTERNOTFOUND, IDS_RETDEFFAILURE, IDS_SETUPFAILURE, IDS_STRUCTSIZE, IDS_SUBCLASSFAILURE, IDS_UNKNOWNERROR, NULL, PDERR_CREATEICFAILURE, PDERR_DNDMMISMATCH, PDERR_GETDEVMODEFAIL, PDERR_INITFAILURE, PDERR_LOADDRVFAILURE, PDERR_NODEFAULTPRN, PDERR_NODEVICES, PDERR_PARSEFAILURE, PDERR_PRINTERNOTFOUND, PDERR_RETDEFFAILURE, and PDERR_SETUPFAILURE.

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: //User may have hit CANCEL or we got a *very* random error 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 }

BOOL CALLBACK ReplaceTextHookProc HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 1506 of file dec97/test/main.c.

References BOOL, FALSE, frText, GetDlgItem(), ShowWindow, and TRUE.

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 // avoid compiler warnings at W3 01533 lParam; 01534 wParam; 01535 }

BOOL SaveAs HWND  hWnd  ) 
 

Definition at line 948 of file dec97/test/main.c.

References BOOL, FALSE, FileSaveHookProc(), hInst, hWnd, IDM_CRD, IDM_CSA, IDM_CUSTOM, IDM_HOOK, IDM_PROFCRD, IDM_STANDARD, L, NULL, OpenFileName, ProcessCDError(), szFile, szFileTitle, szSaveFilter, TRUE, wCSAorCRD, and wMode.

00949 { 00950 int i; 00951 00952 // strcpy( szFile, ""); 00953 // strcpy( szFileTitle, ""); 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 = 0L; 00990 OpenFileName.nFilterIndex = 1L; 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 = 0L; 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 }

BOOL SaveToFile HWND  hWnd  ) 
 

Definition at line 826 of file dec97/test/main.c.

References BOOL, CHAR, dwFileSize, FALSE, FileBuf, hWnd, NULL, OpenFileName, sprintf(), and TRUE.

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 // write it's contents into a file 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 // close the file 00853 _lclose( hFile ); 00854 00855 sprintf( buf, "%s", OpenFileName.lpstrFile ); 00856 MessageBox( hWnd, buf, "File Saved", MB_OK ); 00857 return TRUE; 00858 }

void SearchFile LPFINDREPLACE  lpFR  ) 
 

Definition at line 1725 of file dec97/test/main.c.

References BOOL, CHAR, dwFileSize, FALSE, FILE_LEN, FileBuf, lpBufPtr, lpFR, sprintf(), strlen(), and TRUE.

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 // replace string specified in the replace with found string 01762 // copy up to found string into new buffer 01763 for( count=0; 01764 *pStr && lpBufPtr[count] && *pStr != lpBufPtr[count]; 01765 count++); 01766 strncpy( Buf, lpBufPtr, count ); 01767 // concatenate new string 01768 strcat( Buf, lpFR->lpstrReplaceWith ); 01769 // copy rest of string (less the found string) 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 // replace string specified in the replace with found string 01782 // copy up to found string into new buffer 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 // concatenate new string 01789 strcat( Buf, lpFR->lpstrReplaceWith ); 01790 // copy rest of string (less the found string) 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 }

int PASCAL WinMain HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpCmdLine,
int  nCmdShow
 

Definition at line 129 of file dec97/test/main.c.

References DispatchMessage(), FALSE, FindReplaceMsg, GetMessage(), hDlgFR, hInst, InitApplication(), InitInstance(), IsDialogMessage, IsWindow(), msg, NULL, RegisterWindowMessage(), and TranslateMessage().

00135 { 00136 00137 MSG msg; /* message */ 00138 00139 if (!hPrevInstance) /* Other instances of app running? */ 00140 if (!InitApplication(hInstance)) /* Initialize shared things */ 00141 return (FALSE); /* Exits if unable to initialize */ 00142 00143 hInst = hInstance; 00144 00145 /* Perform initializations that apply to a specific instance */ 00146 00147 if (!InitInstance(hInstance, nCmdShow)) 00148 return (FALSE); 00149 00150 // register window message for FindText() and ReplaceText() hook procs 00151 FindReplaceMsg = RegisterWindowMessage( (LPSTR) FINDMSGSTRING ); 00152 00153 /* Acquire and dispatch messages until a WM_QUIT message is received. */ 00154 00155 while (GetMessage(&msg, /* message structure */ 00156 NULL, /* handle of window receiving the message */ 00157 0, /* lowest message to examine */ 00158 0)) /* highest message to examine */ 00159 if ( !hDlgFR || !IsWindow(hDlgFR) || !IsDialogMessage( hDlgFR, &msg ) ) 00160 { 00161 TranslateMessage(&msg); /* Translates virtual key codes */ 00162 DispatchMessage(&msg); /* Dispatches message to window */ 00163 } 00164 return (msg.wParam); /* Returns the value from PostQuitMessage */ 00165 00166 // avoid compiler warnings at W3 00167 lpCmdLine; 00168 }


Variable Documentation

BOOL AllowBinary = FALSE
 

Definition at line 108 of file dec97/test/main.c.

CHOOSEFONT chf
 

Definition at line 95 of file dec97/test/main.c.

CHOOSECOLOR chsclr
 

Definition at line 96 of file dec97/test/main.c.

COLORREF crColor
 

Definition at line 97 of file dec97/test/main.c.

DWORD dwFileSize
 

Definition at line 88 of file dec97/test/main.c.

CHAR FileBuf[FILE_LEN]
 

Definition at line 87 of file dec97/test/main.c.

UINT FindReplaceMsg
 

Definition at line 89 of file dec97/test/main.c.

FINDREPLACE frText
 

Definition at line 92 of file dec97/test/main.c.

HWND hDlgFR = NULL
 

Definition at line 105 of file dec97/test/main.c.

HANDLE hInst
 

Definition at line 74 of file dec97/test/main.c.

HWND hWnd
 

Definition at line 110 of file dec97/test/main.c.

DWORD Intent = 0
 

Definition at line 109 of file dec97/test/main.c.

LOGFONT lf
 

Definition at line 98 of file dec97/test/main.c.

CHAR* lpBufPtr = FileBuf
 

Definition at line 94 of file dec97/test/main.c.

LPFINDREPLACE lpFR
 

Definition at line 93 of file dec97/test/main.c.

OPENFILENAME OpenFileName
 

Definition at line 75 of file dec97/test/main.c.

PRINTDLG pd
 

Definition at line 106 of file dec97/test/main.c.

CHAR szDirName[256] = ""
 

Definition at line 76 of file dec97/test/main.c.

CHAR szFile[256] = "\0"
 

Definition at line 77 of file dec97/test/main.c.

CHAR szFileTitle[256]
 

Definition at line 78 of file dec97/test/main.c.

CHAR szFilter[] = "Text Files (*.ICM)\0*.ICM\0All Files (*.*)\0*.*\0"
 

Definition at line 84 of file dec97/test/main.c.

CHAR szFindString[64] = ""
 

Definition at line 90 of file dec97/test/main.c.

CHAR szReplaceString[64] = ""
 

Definition at line 91 of file dec97/test/main.c.

CHAR szSaveFilter[] = "Text Files (*.CSA)\0*.CSA\0All Files (*.*)\0*.*\0"
 

Definition at line 85 of file dec97/test/main.c.

WORD wAsciiMode = IDM_ASCII
 

Definition at line 100 of file dec97/test/main.c.

WORD wCSAMode = IDM_AUTO
 

Definition at line 102 of file dec97/test/main.c.

WORD wCSAorCRD = IDM_CSA
 

Definition at line 104 of file dec97/test/main.c.

WORD wInpDrvClrSp = IDM_INP_AUTO
 

Definition at line 103 of file dec97/test/main.c.

WORD wIntentMode = IDM_PERCEPUAL
 

Definition at line 101 of file dec97/test/main.c.

WORD wMode = IDM_CUSTOM
 

Definition at line 99 of file dec97/test/main.c.


Generated on Sat May 15 19:44:35 2004 for test by doxygen 1.3.7